From 9881fbae2848d4e4b88295e92da0701c23e7bd28 Mon Sep 17 00:00:00 2001 From: xuxingliang Date: Wed, 18 Sep 2024 15:25:29 +0800 Subject: [PATCH] tools/gdb: fix thread command not working `thread` is a GDB prefix command. Use `define` can only change it to a user prefix command. In this case, `thread 3` is unable to pass the argument 3 to python. Use python code to register command to overwrite this behavior. It may not work with future GDB, but all is good for now. Signed-off-by: xuxingliang --- tools/gdb/nuttxgdb/thread.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/gdb/nuttxgdb/thread.py b/tools/gdb/nuttxgdb/thread.py index be28a54419..5cfccc8036 100644 --- a/tools/gdb/nuttxgdb/thread.py +++ b/tools/gdb/nuttxgdb/thread.py @@ -52,8 +52,6 @@ class Registers: # Switch to second inferior to get the original remote-register layout state = utils.suppress_cli_notifications(True) utils.switch_inferior(2) - arch = gdb.selected_inferior().architecture() - registers = arch.registers() natural_size = gdb.lookup_type("long").sizeof tcb_info = gdb.parse_and_eval("g_tcbinfo") @@ -306,9 +304,10 @@ class Nxthread(gdb.Command): """Switch to a specified thread""" def __init__(self): - super().__init__("nxthread", gdb.COMMAND_USER) if not is_thread_command_supported(): - gdb.execute("define thread\n nxthread \n end\n") + super().__init__("thread", gdb.COMMAND_USER) + else: + super().__init__("nxthread", gdb.COMMAND_USER) def invoke(self, args, from_tty): npidhash = gdb.parse_and_eval("g_npidhash")