diff --git a/tools/gdb/nuttxgdb/thread.py b/tools/gdb/nuttxgdb/thread.py index 510a6c624a6..5c8559d8737 100644 --- a/tools/gdb/nuttxgdb/thread.py +++ b/tools/gdb/nuttxgdb/thread.py @@ -366,7 +366,11 @@ class Nxthread(gdb.Command): g_registers.restore() else: - if arg[0].isnumeric() and pidhash[int(arg[0])] != 0: + if ( + arg[0].isnumeric() + and int(arg[0]) < npidhash + and pidhash[int(arg[0])] != 0 + ): if pidhash[int(arg[0])]["task_state"] == gdb.parse_and_eval( "TSTATE_TASK_RUNNING" ):