Skip to content

Commit b225c5f

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
1 parent b913065 commit b225c5f

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
@@ -334,6 +334,7 @@ def __init__(self, debugger, path, verbose):
334334
self.threads = list()
335335
self.backtraces = list() # For application specific backtraces
336336
self.idents = list() # A list of the required identifiers for doing all stack backtraces
337+
self.errors = list()
337338
self.crashed_thread_idx = -1
338339
self.version = -1
339340
self.target = None
@@ -437,6 +438,7 @@ def parse(self):
437438
self.parse_process_info(self.data)
438439
self.parse_images(self.data['usedImages'])
439440
self.parse_threads(self.data['threads'])
441+
self.parse_errors(self.data)
440442
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
441443
reason = self.parse_crash_reason(self.data['exception'])
442444
if thread.reason:
@@ -528,6 +530,10 @@ def parse_thread_registers(self, json_thread_state):
528530
pass
529531
return registers
530532

533+
def parse_errors(self, json_data):
534+
if 'reportNotes' in json_data:
535+
self.crashlog.errors = json_data['reportNotes']
536+
531537

532538
class CrashLogParseMode:
533539
NORMAL = 0
@@ -1067,6 +1073,11 @@ def SymbolicateCrashLog(crash_log, options):
10671073
thread.dump_symbolicated(crash_log, options)
10681074
print()
10691075

1076+
if crash_log.errors:
1077+
print("Errors:")
1078+
for error in crash_log.errors:
1079+
print(error)
1080+
10701081

10711082
def CreateSymbolicateCrashLogOptions(
10721083
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)