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 358261af19deb9ecda61d77106653f6712de60a0
Author: xuxingliang <xuxingli...@xiaomi.com>
AuthorDate: Tue Oct 8 11:50:22 2024 +0800

    tools/gdb: avoid direct access to tcb['name']
    
    It could be disabled at compile time. Use utils.get_task_name to handle it
    
    Signed-off-by: xuxingliang <xuxingli...@xiaomi.com>
---
 tools/gdb/nuttxgdb/stack.py  | 2 +-
 tools/gdb/nuttxgdb/thread.py | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/gdb/nuttxgdb/stack.py b/tools/gdb/nuttxgdb/stack.py
index 8315f600d4..53c936e29f 100644
--- a/tools/gdb/nuttxgdb/stack.py
+++ b/tools/gdb/nuttxgdb/stack.py
@@ -146,7 +146,7 @@ def fetch_stacks():
 
         try:
             stacks[int(tcb["pid"])] = Stack(
-                tcb["name"].string(),
+                utils.get_task_name(tcb),
                 hex(tcb["entry"]["pthread"]),  # should use main?
                 int(tcb["stack_base_ptr"]),
                 int(tcb["stack_alloc_ptr"]),
diff --git a/tools/gdb/nuttxgdb/thread.py b/tools/gdb/nuttxgdb/thread.py
index 8759024b46..be28a54419 100644
--- a/tools/gdb/nuttxgdb/thread.py
+++ b/tools/gdb/nuttxgdb/thread.py
@@ -264,7 +264,7 @@ class Nxinfothreads(gdb.Command):
                 info = (
                     "(Name: \x1b[31;1m%s\x1b[m, State: %s, Priority: %d, 
Stack: %d)"
                     % (
-                        tcb["name"].string(),
+                        utils.get_task_name(tcb),
                         statename,
                         tcb["sched_priority"],
                         tcb["adj_stack_size"],
@@ -509,7 +509,7 @@ class Ps(gdb.Command):
         ]  # exclude "0x"
 
         st = Stack(
-            tcb["name"].string(),
+            utils.get_task_name(tcb),
             hex(tcb["entry"]["pthread"]),  # should use main?
             int(tcb["stack_base_ptr"]),
             int(tcb["stack_alloc_ptr"]),
@@ -527,7 +527,7 @@ class Ps(gdb.Command):
         # For a task we need to display its cmdline arguments, while for a 
thread we display
         # pointers to its entry and argument
         cmd = ""
-        name = tcb["name"].string()
+        name = utils.get_task_name(tcb)
 
         if int(tcb["flags"] & get_macro("TCB_FLAG_TTYPE_MASK")) == int(
             get_macro("TCB_FLAG_TTYPE_PTHREAD")

Reply via email to