Skip to content

[lldb/crashlog] Fix breaking changes in textual report format (#83861) #8334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lldb/examples/python/crashlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,10 @@ def parse_errors(self, json_data):

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

class VersionRegex:
version = r"\(.+\)|(?:arm|x86_)[0-9a-z]+"
Expand Down Expand Up @@ -1077,7 +1077,10 @@ def parse_normal(self, line):
if thread_state_match:
self.app_specific_backtrace = False
thread_state_match = self.thread_regex.search(line)
thread_idx = int(thread_state_match.group(1))
if thread_state_match:
thread_idx = int(thread_state_match.group(1))
else:
thread_idx = self.crashlog.crashed_thread_idx
self.parse_mode = self.CrashLogParseMode.THREGS
self.thread = self.crashlog.threads[thread_idx]
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Process: a.out [21606]
Path: /private/tmp/a.out
Identifier: a.out
Version: 0
Code Type: X86-64 (Native)
Parent Process: fish [88883]
User ID: 501

Date/Time: 2020-11-11 14:47:34.600 -0800
OS Version: macOS 11.0.1
Report Version: 12
Bridge OS Version: redacted
Anonymous UUID: DCEF35CB-68D5-F524-FF13-060901F52EA8


Time Awake Since Boot: 400000 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [21606]

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 a.out @foo@ foo + 16 (test.c:3)
1 a.out @bar@
2 a.out @main@ main + 20 (test.c:8)
3 libdyld.dylib 0x1000000 start + 1

Thread State
rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x00007ffee42d81d0 rdx: 0x00007ffee42d8080
rdi: 0x0000000000000001 rsi: 0x00007ffee42d8070 rbp: 0x00007ffee42d8020 rsp: 0x00007ffee42d8020
r8: 0x0000000000000000 r9: 0x0000000000000000 r10: 0x0000000000000000 r11: 0x0000000000000000
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000000000000
rip: 0x000000010b92af70 rfl: 0x0000000000010202 cr2: 0x0000000000000000

Logical CPU: 2
Error Code: 0x00000006 (no mapping for user data write)
Trap Number: 14


Binary Images:
0x100000000 - 0x200000000 +a.out (0) <@UUID@> @EXEC@
0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
# RUN: cp %S/Inputs/altered_threadState.crash %t.crash
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}'
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s

# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands

# CHECK: Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000000)
# CHECK: [ 0] {{.*}}out`foo + 16 at test.c
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
# CHECK: [ 2] {{.*}}out`main + 19 at test.c
# CHECK: [ 3] 0x{{[0]+}}1000000 start + 1
# CHECK: rbp = 0x00007ffee42d8020