New issue
Advanced search Search tips

Issue 821174 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

kgdb: debugging non-running threads doesn't work

Project Member Reported by diand...@chromium.org, Mar 12 2018

Issue description

1. Attach kgdb, as per:

https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/kernel-faq#TOC-Debugging-with-KGDB-KDB

2. In kgdb, type "info thread"

3. Switch to a sleeping thread

4. Type 'bt'

Expect: should work
Actual: on arm64, it doesn't
 
Project Member

Comment 1 by bugdroid1@chromium.org, Mar 14 2018

Labels: merge-merged-chromeos-4.4
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/e909bac3c55177b670bd370c41ed0f9b858bae99

commit e909bac3c55177b670bd370c41ed0f9b858bae99
Author: Daniel Thompson <daniel.thompson@linaro.org>
Date: Wed Mar 14 21:21:59 2018

UPSTREAM: arm64: kgdb: Match pstate size with gdbserver protocol

Current versions of gdb do not interoperate cleanly with kgdb on arm64
systems because gdb and kgdb do not use the same register description.
This patch modifies kgdb to work with recent releases of gdb (>= 7.8.1).

Compatibility with gdb (after the patch is applied) is as follows:

  gdb-7.6 and earlier  Ok
  gdb-7.7 series       Works if user provides custom target description
  gdb-7.8(.0)          Works if user provides custom target description
  gdb-7.8.1 and later  Ok

When commit 44679a4f142b ("arm64: KGDB: Add step debugging support") was
introduced it was paired with a gdb patch that made an incompatible
change to the gdbserver protocol. This patch was eventually merged into
the gdb sources:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=a4d9ba85ec5597a6a556afe26b712e878374b9dd

The change to the protocol was mostly made to simplify big-endian support
inside the kernel gdb stub. Unfortunately the gdb project released
gdb-7.7.x and gdb-7.8.0 before the protocol incompatibility was identified
and reversed:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bdc144174bcb11e808b4e73089b850cf9620a7ee

This leaves us in a position where kgdb still uses the no-longer-used
protocol; gdb-7.8.1, which restored the original behaviour, was
released on 2014-10-29.

I don't believe it is possible to detect/correct the protocol
incompatiblity which means the kernel must take a view about which
version of the gdb remote protocol is "correct". This patch takes the
view that the original/current version of the protocol is correct
and that version found in gdb-7.7.x and gdb-7.8.0 is anomalous.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>

BUG= chromium:821174 ,  chromium:630015 
TEST=kgdb still works OK

Change-Id: I80fad7279537c5ee3ec1735a26560a77e9fceb38
Signed-off-by: Douglas Anderson <dianders@chromium.org>
(cherry picked from commit 0d15ef677839dab8313fbb86c007c3175b638d03)
Reviewed-on: https://chromium-review.googlesource.com/959554
Reviewed-by: Caroline Tice <cmtice@chromium.org>

[modify] https://crrev.com/e909bac3c55177b670bd370c41ed0f9b858bae99/arch/arm64/include/asm/kgdb.h
[modify] https://crrev.com/e909bac3c55177b670bd370c41ed0f9b858bae99/arch/arm64/kernel/kgdb.c

Components: OS>Kernel
> Update the Errata under KGDB notes?

Yes, once the actual fixes land in 4.4 and 4.14.  The above just made it so that we can revert the gdb hack we have.  See chromium:630015.
Project Member

Comment 5 by bugdroid1@chromium.org, Mar 15 2018

Labels: merge-merged-chromeos-4.14
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/6b2b71c306c49b5d737286f49b22b675370eb8c1

commit 6b2b71c306c49b5d737286f49b22b675370eb8c1
Author: Douglas Anderson <dianders@chromium.org>
Date: Thu Mar 15 19:49:59 2018

FROMGIT: arm64/debug: Fix registers on sleeping tasks

This is the equivalent of commit 001bf455d206 ("ARM: 8428/1: kgdb: Fix
registers on sleeping tasks") but for arm64.  Nuff said.

...well, perhaps I could also add that task_pt_regs are userspace
registers and that's not what kgdb is supposed to be reporting.  We're
supposed to be reporting kernel registers.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>

BUG= chromium:821174 
TEST='info thread' in kgdb now works for sleeping tasks

Change-Id: I0e995418f4947c7ce6f6e803126fbe711d3aa0a6
Signed-off-by: Douglas Anderson <dianders@chromium.org>
(cherry picked from commit 24153c03d4f5dc4ac0ccd446a9636c269c1d4a02
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core)
Reviewed-on: https://chromium-review.googlesource.com/959393
Reviewed-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

[modify] https://crrev.com/6b2b71c306c49b5d737286f49b22b675370eb8c1/arch/arm64/kernel/kgdb.c

Project Member

Comment 6 by bugdroid1@chromium.org, Mar 15 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/0259948bed96b4d3ca7b3917d61e91865a35a419

commit 0259948bed96b4d3ca7b3917d61e91865a35a419
Author: Douglas Anderson <dianders@chromium.org>
Date: Thu Mar 15 22:27:42 2018

FROMGIT: arm64/debug: Fix registers on sleeping tasks

This is the equivalent of commit 001bf455d206 ("ARM: 8428/1: kgdb: Fix
registers on sleeping tasks") but for arm64.  Nuff said.

...well, perhaps I could also add that task_pt_regs are userspace
registers and that's not what kgdb is supposed to be reporting.  We're
supposed to be reporting kernel registers.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>

BUG= chromium:821174 
TEST='info thread' in kgdb now works for sleeping tasks

Change-Id: I0e995418f4947c7ce6f6e803126fbe711d3aa0a6
Signed-off-by: Douglas Anderson <dianders@chromium.org>
(cherry picked from commit 24153c03d4f5dc4ac0ccd446a9636c269c1d4a02
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core)
Reviewed-on: https://chromium-review.googlesource.com/371942
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

[modify] https://crrev.com/0259948bed96b4d3ca7b3917d61e91865a35a419/arch/arm64/kernel/kgdb.c

Status: Fixed (was: Untriaged)
Fix landed; removed errata mention from wiki.

Sign in to add a comment