[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250503123234.2407184-2-illia@yshyn.com>
Date: Sat, 3 May 2025 14:32:31 +0200
From: Illia Ostapyshyn <illia@...yn.com>
To: linux-kernel@...r.kernel.org,
workflows@...r.kernel.org,
linux-doc@...r.kernel.org
Cc: Jan Kiszka <jan.kiszka@...mens.com>,
Kieran Bingham <kbingham@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Florian Rommel <mail@...rommel.de>,
Jonathan Corbet <corbet@....net>,
Alex Shi <alexs@...nel.org>,
Yanteng Si <si.yanteng@...ux.dev>,
Dongliang Mu <dzm91@...t.edu.cn>,
Hu Haowen <2023002089@...k.tyut.edu.cn>,
Brendan Jackman <jackmanb@...gle.com>,
Illia Ostapyshyn <illia@...yn.com>
Subject: [PATCH 1/2] scripts/gdb: Fix kgdb probing on single-core systems
When requested the list of threads via qfThreadInfo, gdb_cmd_query in
kernel/debug/gdbstub.c first returns "shadow" threads for CPUs followed
by the actual tasks in the system. Extended qThreadExtraInfo queries
yield "shadowCPU%d" as the name for the CPU core threads.
This behavior is used by get_gdbserver_type() to probe for KGDB by
matching the name for the thread 2 against "shadowCPU". This breaks
down on single-core systems, where thread 2 is the first nonshadow
thread. Request the name for thread 1 instead.
As GDB assigns thread IDs in the order of their appearance, it is safe
to assume shadowCPU0 at ID 1 as long as CPU0 is not hotplugged.
Before:
(gdb) info threads
Id Target Id Frame
1 Thread 4294967294 (shadowCPU0) kgdb_breakpoint ()
* 2 Thread 1 (swapper/0) kgdb_breakpoint ()
3 Thread 2 (kthreadd) 0x0000000000000000 in ?? ()
...
(gdb) p $lx_current().comm
Sorry, obtaining the current CPU is not yet supported with this gdb server.
After:
(gdb) info threads
Id Target Id Frame
1 Thread 4294967294 (shadowCPU0) kgdb_breakpoint ()
* 2 Thread 1 (swapper/0) kgdb_breakpoint ()
3 Thread 2 (kthreadd) 0x0000000000000000 in ?? ()
...
(gdb) p $lx_current().comm
$1 = "swapper/0\000\000\000\000\000\000"
Signed-off-by: Illia Ostapyshyn <illia@...yn.com>
---
scripts/gdb/linux/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index 03ebdccf5f69..877404e92dbb 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -200,7 +200,7 @@ def get_gdbserver_type():
def probe_kgdb():
try:
- thread_info = gdb.execute("info thread 2", to_string=True)
+ thread_info = gdb.execute("info thread 1", to_string=True)
return "shadowCPU" in thread_info
except gdb.error:
return False
--
2.47.2
Powered by blists - more mailing lists