Skip to content

Commit 7ccf3b6

Browse files
committed
[lldb] Parse and display reporting errors from JSON crashlogs
JSON crashlogs have an optional field named reportNotes that contains any potential errors encountered by the crash reporter when generating the crashlog. Parse and display them in LLDB. Differential revision: https://reviews.llvm.org/D111339 (cherry picked from commit b225c5f)
1 parent eeaf069 commit 7ccf3b6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lldb/examples/python/crashlog.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ def __init__(self, debugger, path, verbose):
330330
self.threads = list()
331331
self.backtraces = list() # For application specific backtraces
332332
self.idents = list() # A list of the required identifiers for doing all stack backtraces
333+
self.errors = list()
333334
self.crashed_thread_idx = -1
334335
self.version = -1
335336
self.target = None
@@ -433,6 +434,7 @@ def parse(self):
433434
self.parse_process_info(self.data)
434435
self.parse_images(self.data['usedImages'])
435436
self.parse_threads(self.data['threads'])
437+
self.parse_errors(self.data)
436438
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
437439
reason = self.parse_crash_reason(self.data['exception'])
438440
if thread.reason:
@@ -522,6 +524,10 @@ def parse_thread_registers(self, json_thread_state):
522524
pass
523525
return registers
524526

527+
def parse_errors(self, json_data):
528+
if 'reportNotes' in json_data:
529+
self.crashlog.errors = json_data['reportNotes']
530+
525531

526532
class CrashLogParseMode:
527533
NORMAL = 0
@@ -1061,6 +1067,11 @@ def SymbolicateCrashLog(crash_log, options):
10611067
thread.dump_symbolicated(crash_log, options)
10621068
print()
10631069

1070+
if crash_log.errors:
1071+
print("Errors:")
1072+
for error in crash_log.errors:
1073+
print(error)
1074+
10641075

10651076
def CreateSymbolicateCrashLogOptions(
10661077
command_name,

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,9 @@
170170
"threadTriggered" : {
171171
"queue" : "com.apple.main-thread"
172172
}
173-
}
173+
},
174+
"reportNotes" : [
175+
"invalid foo",
176+
"invalid bar"
177+
]
174178
}

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
1414
# CHECK: [ 2] {{.*}}out`main + 19 at test.c
1515
# CHECK: rbp = 0x00007ffeec22a530
16+
# CHECK: invalid foo
17+
# CHECK: invalid bar

0 commit comments

Comments
 (0)