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 <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang 2024-09-23 11:40:27 +08:00 committed by Xiang Xiao
parent 191dbcc4f1
commit 5b477aacca

View file

@ -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: