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 db9b5c4ceec594ece2aaa9aae20bc88ebadbec2c
Author: xuxingliang <[email protected]>
AuthorDate: Thu Sep 26 18:11:32 2024 +0800

    tools/gdb: register commands gracefully
    
    Report any error and continue to try to register next command.
    
    Signed-off-by: xuxingliang <[email protected]>
---
 tools/gdb/nuttxgdb/__init__.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/gdb/nuttxgdb/__init__.py b/tools/gdb/nuttxgdb/__init__.py
index ab80ed5411..d4b5038a1a 100644
--- a/tools/gdb/nuttxgdb/__init__.py
+++ b/tools/gdb/nuttxgdb/__init__.py
@@ -49,10 +49,18 @@ def register_commands(event):
     gdb.write('"handle SIGUSR1 "nostop" "pass" "noprint"\n')
 
     def init_gdb_commands(m: str):
-        module = importlib.import_module(f"{__package__}.{m}")
+        try:
+            module = importlib.import_module(f"{__package__}.{m}")
+        except Exception:
+            gdb.write(f"\x1b[31;1mIgnore module: {m}\n\x1b[m")
+            return
+
         for c in module.__dict__.values():
             if isinstance(c, type) and issubclass(c, gdb.Command):
-                c()
+                try:
+                    c()
+                except Exception:
+                    gdb.write(f"\x1b[31;1mIgnore command: {c}\n\x1b[m")
 
     # import utils module
     utils = importlib.import_module(f"{__package__}.utils")

Reply via email to