forked from nuttx/nuttx-update
tools/gdb: allow to use info nxthreads
(gdb) info threads Id Target Id Frame * 1.1 Thread 1 (Name: CPU0 IDLE, State: 3, Pri: 0, Stack: 41eccfec, Size: 3976) 0x402cd586 in up_idle () at chip/r528_idle.c:80 1.2 Thread 2 (Name: CPU1 IDLE, State: 4, Pri: 0, Stack: 4194bb78, Size: 3976) 0x402cd586 in up_idle () at chip/r528_idle.c:80 (gdb) info nxthreads Index Tid Pid Cpu Thread Info Frame 0 0 0 0 '\000' Thread 0x419633b8 (Name: CPU0 IDLE, State: Assigned, Priority: 0, Stack: 3976) 0x402cd586 up_idle() at chip/r528_idle.c:80 *1 1 1 1 '\001' Thread 0x41963498 (Name: CPU1 IDLE, State: Running, Priority: 0, Stack: 3976) 0x402cd586 up_idle() at chip/r528_idle.c:80 (gdb) Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
parent
db1e97405a
commit
796806c65b
1 changed files with 12 additions and 9 deletions
|
@ -161,7 +161,7 @@ class Nxinfothreads(gdb.Command):
|
|||
"""Display information of all threads"""
|
||||
|
||||
def __init__(self):
|
||||
super(Nxinfothreads, self).__init__("info threads", gdb.COMMAND_USER)
|
||||
super(Nxinfothreads, self).__init__("info nxthreads", gdb.COMMAND_USER)
|
||||
|
||||
def invoke(self, args, from_tty):
|
||||
npidhash = gdb.parse_and_eval("g_npidhash")
|
||||
|
@ -252,7 +252,7 @@ class Nxthread(gdb.Command):
|
|||
"""Switch to a specified thread"""
|
||||
|
||||
def __init__(self):
|
||||
super(Nxthread, self).__init__("thread", gdb.COMMAND_USER)
|
||||
super(Nxthread, self).__init__("nxthread", gdb.COMMAND_USER)
|
||||
|
||||
def invoke(self, args, from_tty):
|
||||
npidhash = gdb.parse_and_eval("g_npidhash")
|
||||
|
@ -551,17 +551,20 @@ class Ps(gdb.Command):
|
|||
def register_commands():
|
||||
SetRegs()
|
||||
Ps()
|
||||
Nxinfothreads()
|
||||
Nxthread()
|
||||
Nxcontinue()
|
||||
Nxstep()
|
||||
|
||||
# Disable thread commands for core dump and gdb-stub.
|
||||
# In which case the recognized threads count is less or equal to the number of cpus
|
||||
# Use custom command for thread if current target does not support it.
|
||||
# The recognized threads count is less than or equal to the number of CPUs in this case.
|
||||
# For coredump and gdb-stub, use native thread commands.
|
||||
ncpus = utils.get_symbol_value("CONFIG_SMP_NCPUS") or 1
|
||||
nthreads = len(gdb.selected_inferior().threads())
|
||||
if nthreads <= ncpus:
|
||||
SetRegs()
|
||||
Nxinfothreads()
|
||||
Nxthread()
|
||||
Nxcontinue()
|
||||
Nxstep()
|
||||
# Native threads command is not available, override the threads command
|
||||
gdb.execute("define info threads\n info nxthreads \n end\n")
|
||||
gdb.execute("define thread\n nxthread \n end\n")
|
||||
|
||||
# We can't use a user command to rename continue it will recursion
|
||||
gdb.execute("define c\n nxcontinue \n end\n")
|
||||
|
|
Loading…
Reference in a new issue