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 5b477aacca89102ab92e72aaa822fb740a11f6a1
Author: xuxingliang <[email protected]>
AuthorDate: Mon Sep 23 11:40:27 2024 +0800

    gdb/diag: catch gdb.error in diagnositics
    
    gdb.error could report if memory is corrupted. Save and report the 
exception and continue to next command.
    
    Signed-off-by: xuxingliang <[email protected]>
---
 tools/gdb/nuttxgdb/diagnose.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/gdb/nuttxgdb/diagnose.py b/tools/gdb/nuttxgdb/diagnose.py
index d7e081a68f..b21ae1be62 100644
--- a/tools/gdb/nuttxgdb/diagnose.py
+++ b/tools/gdb/nuttxgdb/diagnose.py
@@ -70,8 +70,20 @@ class DiagnoseReport(gdb.Command):
         for clz in commands:
             if hasattr(clz, "diagnose"):
                 command = clz()
-                gdb.write(f"Run command: {clz.__name__}\n")
-                results.append(command.diagnose())
+                name = clz.__name__.lower()
+                gdb.write(f"Run command: {name}\n")
+                try:
+                    result = command.diagnose()
+                except gdb.error as e:
+                    result = {
+                        "command": name,
+                        "error": str(e),
+                    }
+
+                    gdb.write(f"Failed: {e}\n")
+
+                result.setdefault("command", name)
+                results.append(result)
 
         gdb.write(f"Write report to {reportfile}\n")
         with open(reportfile, "w") as f:

Reply via email to