Skip to content

Commit 5000e4c

Browse files
authored
[lldb/crashlog] Fix breaking changes in textual report format (llvm#83861)
This patch should address some register parsing issue in the legacy report format. rdar://107210149 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 07b1aeb commit 5000e4c

File tree

3 files changed

+70
-4
lines changed

3 files changed

+70
-4
lines changed

lldb/examples/python/crashlog.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,10 @@ def parse_errors(self, json_data):
849849

850850
class TextCrashLogParser(CrashLogParser):
851851
parent_process_regex = re.compile(r"^Parent Process:\s*(.*)\[(\d+)\]")
852-
thread_state_regex = re.compile(r"^Thread \d+ crashed with")
852+
thread_state_regex = re.compile(r"^Thread (\d+ crashed with|State)")
853853
thread_instrs_regex = re.compile(r"^Thread \d+ instruction stream")
854-
thread_regex = re.compile(r"^Thread (\d+).*:")
855-
app_backtrace_regex = re.compile(r"^Application Specific Backtrace (\d+).*:")
854+
thread_regex = re.compile(r"^Thread (\d+).*")
855+
app_backtrace_regex = re.compile(r"^Application Specific Backtrace (\d+).*")
856856

857857
class VersionRegex:
858858
version = r"\(.+\)|(?:arm|x86_)[0-9a-z]+"
@@ -1081,7 +1081,10 @@ def parse_normal(self, line):
10811081
if thread_state_match:
10821082
self.app_specific_backtrace = False
10831083
thread_state_match = self.thread_regex.search(line)
1084-
thread_idx = int(thread_state_match.group(1))
1084+
if thread_state_match:
1085+
thread_idx = int(thread_state_match.group(1))
1086+
else:
1087+
thread_idx = self.crashlog.crashed_thread_idx
10851088
self.parse_mode = self.CrashLogParseMode.THREGS
10861089
self.thread = self.crashlog.threads[thread_idx]
10871090
return
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Process: a.out [21606]
2+
Path: /private/tmp/a.out
3+
Identifier: a.out
4+
Version: 0
5+
Code Type: X86-64 (Native)
6+
Parent Process: fish [88883]
7+
User ID: 501
8+
9+
Date/Time: 2020-11-11 14:47:34.600 -0800
10+
OS Version: macOS 11.0.1
11+
Report Version: 12
12+
Bridge OS Version: redacted
13+
Anonymous UUID: DCEF35CB-68D5-F524-FF13-060901F52EA8
14+
15+
16+
Time Awake Since Boot: 400000 seconds
17+
18+
System Integrity Protection: enabled
19+
20+
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
21+
22+
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
23+
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
24+
Exception Note: EXC_CORPSE_NOTIFY
25+
26+
Termination Signal: Segmentation fault: 11
27+
Termination Reason: Namespace SIGNAL, Code 0xb
28+
Terminating Process: exc handler [21606]
29+
30+
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
31+
0 a.out @foo@ foo + 16 (test.c:3)
32+
1 a.out @bar@
33+
2 a.out @main@ main + 20 (test.c:8)
34+
3 libdyld.dylib 0x1000000 start + 1
35+
36+
Thread State
37+
rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x00007ffee42d81d0 rdx: 0x00007ffee42d8080
38+
rdi: 0x0000000000000001 rsi: 0x00007ffee42d8070 rbp: 0x00007ffee42d8020 rsp: 0x00007ffee42d8020
39+
r8: 0x0000000000000000 r9: 0x0000000000000000 r10: 0x0000000000000000 r11: 0x0000000000000000
40+
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000000000000
41+
rip: 0x000000010b92af70 rfl: 0x0000000000010202 cr2: 0x0000000000000000
42+
43+
Logical CPU: 2
44+
Error Code: 0x00000006 (no mapping for user data write)
45+
Trap Number: 14
46+
47+
48+
Binary Images:
49+
0x100000000 - 0x200000000 +a.out (0) <@UUID@> @EXEC@
50+
0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
2+
# RUN: cp %S/Inputs/altered_threadState.crash %t.crash
3+
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}'
4+
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
5+
6+
# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
7+
8+
# CHECK: Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000000)
9+
# CHECK: [ 0] {{.*}}out`foo + 16 at test.c
10+
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
11+
# CHECK: [ 2] {{.*}}out`main + 19 at test.c
12+
# CHECK: [ 3] 0x{{[0]+}}1000000 start + 1
13+
# CHECK: rbp = 0x00007ffee42d8020

0 commit comments

Comments
 (0)