diff --git a/tools/pynuttx/nxgdb/thread.py b/tools/pynuttx/nxgdb/thread.py index d5e6be469db4f..04326529989b4 100644 --- a/tools/pynuttx/nxgdb/thread.py +++ b/tools/pynuttx/nxgdb/thread.py @@ -251,8 +251,7 @@ def invoke(self, args, from_tty): if tcb["task_state"] == gdb.parse_and_eval("TSTATE_WAIT_SEM"): mutex = tcb["waitobj"].cast(utils.lookup_type("sem_t").pointer()) if mutex["flags"] & SEM_TYPE_MUTEX: - mutex = tcb["waitobj"].cast(utils.lookup_type("mutex_t").pointer()) - statename = f"Waiting,Mutex:{mutex['holder']}" + statename = f"Waiting,Mutex:{utils.mutex_get_holder(mutex)}" try: """Maybe tcb not have name member, or name is not utf-8""" @@ -488,7 +487,7 @@ def cast2ptr(x, t): ) waiter = ( - str(int(cast2ptr(tcb["waitobj"], "mutex_t")["holder"])) + str(utils.mutex_get_holder(cast2ptr(tcb["waitobj"], "sem_t"))) if tcb["waitobj"] and cast2ptr(tcb["waitobj"], "sem_t")["flags"] & get_macro("SEM_TYPE_MUTEX") else "" diff --git a/tools/pynuttx/nxgdb/utils.py b/tools/pynuttx/nxgdb/utils.py index 3aa8e6416cf92..71548de04e637 100644 --- a/tools/pynuttx/nxgdb/utils.py +++ b/tools/pynuttx/nxgdb/utils.py @@ -811,6 +811,12 @@ def get_task_name(tcb): return "" +# sem +def mutex_get_holder(sem): + NXSEM_MBLOCKING_BIT = 1 << 31 + return sem["val"]["mholder"] & ~NXSEM_MBLOCKING_BIT + + def switch_inferior(inferior): state = suppress_cli_notifications(True)