From 341292064db20ebdc054cd9c20ddcbf430cabf88 Mon Sep 17 00:00:00 2001 From: chenzhijia Date: Fri, 21 Feb 2025 09:44:12 +0800 Subject: [PATCH] nxgdb/utils.py: Fix source gdbinit.py script error report Registering NuttX GDB commands from /home/mi/code/stable_oh2/nuttx/tools/pynuttx/nxgdb set pagination off set python print-stack full "handle SIGUSR1 "nostop" "pass" "noprint" Load macro: /tmp/6024dea73606400ae39a7b7da42cecbf.json Please pip install debugpyIgnore module: elf, error: 'NoneType' object has no attribute 'code' Traceback (most recent call last): File "/home/mi/code/stable_oh2/nuttx/tools/pynuttx/nxgdb/_init_.py", line 54, in init_gdb_commands module = importlib.import_module(f"{_package_}.{m}") File "/usr/lib/python3.10/importlib/_init_.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/home/mi/code/stable_oh2/nuttx/tools/pynuttx/nxgdb/elf.py", line 35, in CONFIG_ARCH_USE_SEPARATED_SECTION = has_field("struct module_s", "sectalloc") File "/home/mi/code/stable_oh2/nuttx/tools/pynuttx/nxgdb/utils.py", line 488, in has_field return get_type_field(obj, field) is not None File "/home/mi/code/stable_oh2/nuttx/tools/pynuttx/nxgdb/utils.py", line 267, in get_type_field while t.code in (gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_ARRAY, gdb.TYPE_CODE_TYPEDEF): AttributeError: 'NoneType' object has no attribute 'code' No symbol g_version found in memory, skipping version check Signed-off-by: chenzhijia --- tools/pynuttx/nxgdb/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/pynuttx/nxgdb/utils.py b/tools/pynuttx/nxgdb/utils.py index cff1f0d57d..b7911796d8 100644 --- a/tools/pynuttx/nxgdb/utils.py +++ b/tools/pynuttx/nxgdb/utils.py @@ -263,6 +263,9 @@ def get_type_field(obj: Union[TypeOrStr, gdb.Value], field: str) -> gdb.Field: else: raise gdb.GdbError(f"Unsupported type {type(obj)}") + if not t: + return None + while t.code in (gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_ARRAY, gdb.TYPE_CODE_TYPEDEF): t = t.target()