Skip to content

Commit e8cf0b3

Browse files
authored
Merge pull request #2878 from apple/🍒/ganymede/a62cbd9a0211d08bace8794b435996890feb44d4
[lldb] Include thread name in crashlog.py output
2 parents 12e713d + 0ddcc2b commit e8cf0b3

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

lldb/examples/python/crashlog.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,15 @@ def parse(self):
418418
self.parse_images(self.data['usedImages'])
419419
self.parse_threads(self.data['threads'])
420420
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
421-
thread.reason = self.parse_crash_reason(self.data['exception'])
421+
reason = self.parse_crash_reason(self.data['exception'])
422+
if thread.reason:
423+
thread.reason = '{} {}'.format(thread.reason, reason)
424+
else:
425+
thread.reason = reason
422426
except (KeyError, ValueError, TypeError) as e:
423-
raise CrashLogParseException(
424-
'Failed to parse JSON crashlog: {}: {}'.format(
425-
type(e).__name__, e))
427+
raise CrashLogParseException(
428+
'Failed to parse JSON crashlog: {}: {}'.format(
429+
type(e).__name__, e))
426430

427431
return self.crashlog
428432

@@ -480,6 +484,8 @@ def parse_threads(self, json_threads):
480484
idx = 0
481485
for json_thread in json_threads:
482486
thread = self.crashlog.Thread(idx, False)
487+
if 'name' in json_thread:
488+
thread.reason = json_thread['name']
483489
if json_thread.get('triggered', False):
484490
self.crashlog.crashed_thread_idx = idx
485491
self.registers = self.parse_thread_registers(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
{
4141
"triggered": true,
4242
"id": 6152004,
43+
"name": "Crashing Thread Name",
4344
"threadState": {
4445
"r13": {
4546
"value": 0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
44
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
55

6-
# CHECK: Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000000)
6+
# CHECK: Thread[0] Crashing Thread Name EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000000)
77
# CHECK: [ 0] {{.*}}out`foo + 16 at test.c
88
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
99
# CHECK: [ 2] {{.*}}out`main + 19 at test.c

0 commit comments

Comments
 (0)