This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 852e683fa31076ef268eb65ee15f0e0e9a81cb28
Author: anjiahao <anjia...@xiaomi.com>
AuthorDate: Wed Nov 22 14:06:13 2023 +0800

    python/gdb:fix use thread command on running task bug
    
    Signed-off-by: anjiahao <anjia...@xiaomi.com>
---
 tools/gdb/thread.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/gdb/thread.py b/tools/gdb/thread.py
index b7a2d10c05..72f2fae378 100644
--- a/tools/gdb/thread.py
+++ b/tools/gdb/thread.py
@@ -276,7 +276,10 @@ class Nxthread(gdb.Command):
 
         else:
             if arg[0].isnumeric() and pidhash[int(arg[0])] != 0:
-                gdb.execute("nxsetregs g_pidhash[%s]->xcp.regs" % arg[0])
+                if pidhash[int(arg[0])]["task_state"] == 
gdb.parse_and_eval("TSTATE_TASK_RUNNING"):
+                    restore_regs()
+                else:
+                    gdb.execute("nxsetregs g_pidhash[%s]->xcp.regs" % arg[0])
             else:
                 gdb.write("Invalid thread id %s\n" % arg[0])
 
@@ -289,12 +292,23 @@ class Nxcontinue(gdb.Command):
         restore_regs()
         gdb.execute("continue")
 
+class Nxstep(gdb.Command):
+    def __init__(self):
+        super(Nxstep, self).__init__("nxstep", gdb.COMMAND_USER)
+
+    def invoke(self, args, from_tty):
+        restore_regs()
+        gdb.execute("step")
 
 # We can't use a user command to rename continue it will recursion
+
 gdb.execute("define c\n nxcontinue \n end\n")
+gdb.execute("define s\n nxstep \n end\n")
 gdb.write("\nif use thread command, please don't use 'continue', use 'c' 
instead !!!\n")
+gdb.write("if use thread command, please don't use 'step', use 's' instead 
!!!\n")
 
 Nxsetregs()
 Nxinfothreads()
 Nxthread()
 Nxcontinue()
+Nxstep()

Reply via email to