Skip to content

🍒/FBI/b225c5f7861c+b913065bf470 #3427

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 2 commits into from
Oct 18, 2021
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
21 changes: 19 additions & 2 deletions lldb/examples/python/crashlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(self, index, app_specific_backtrace):
self.registers = dict()
self.reason = None
self.queue = None
self.crashed = False
self.app_specific_backtrace = app_specific_backtrace

def dump(self, prefix):
Expand Down Expand Up @@ -160,6 +161,9 @@ def dump_symbolicated(self, crash_log, options):
print()
for reg in self.registers.keys():
print(" %-8s = %#16.16x" % (reg, self.registers[reg]))
elif self.crashed:
print()
print("No thread state (register information) available")

def add_ident(self, ident):
if ident not in self.idents:
Expand Down Expand Up @@ -330,6 +334,7 @@ def __init__(self, debugger, path, verbose):
self.threads = list()
self.backtraces = list() # For application specific backtraces
self.idents = list() # A list of the required identifiers for doing all stack backtraces
self.errors = list()
self.crashed_thread_idx = -1
self.version = -1
self.target = None
Expand Down Expand Up @@ -433,6 +438,7 @@ def parse(self):
self.parse_process_info(self.data)
self.parse_images(self.data['usedImages'])
self.parse_threads(self.data['threads'])
self.parse_errors(self.data)
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
reason = self.parse_crash_reason(self.data['exception'])
if thread.reason:
Expand Down Expand Up @@ -505,8 +511,10 @@ def parse_threads(self, json_threads):
thread.reason = json_thread['name']
if json_thread.get('triggered', False):
self.crashlog.crashed_thread_idx = idx
thread.registers = self.parse_thread_registers(
json_thread['threadState'])
thread.crashed = True
if 'threadState' in json_thread:
thread.registers = self.parse_thread_registers(
json_thread['threadState'])
thread.queue = json_thread.get('queue')
self.parse_frames(thread, json_thread.get('frames', []))
self.crashlog.threads.append(thread)
Expand All @@ -522,6 +530,10 @@ def parse_thread_registers(self, json_thread_state):
pass
return registers

def parse_errors(self, json_data):
if 'reportNotes' in json_data:
self.crashlog.errors = json_data['reportNotes']


class CrashLogParseMode:
NORMAL = 0
Expand Down Expand Up @@ -1061,6 +1073,11 @@ def SymbolicateCrashLog(crash_log, options):
thread.dump_symbolicated(crash_log, options)
print()

if crash_log.errors:
print("Errors:")
for error in crash_log.errors:
print(error)


def CreateSymbolicateCrashLogOptions(
command_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,9 @@
"threadTriggered" : {
"queue" : "com.apple.main-thread"
}
}
},
"reportNotes" : [
"invalid foo",
"invalid bar"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{"app_name":"json.test.tmp.out","timestamp":"2021-03-08 13:57:06.00 -0800","app_version":"","slice_uuid":"8f528c10-3e80-3dd6-b0be-5d558f64f7ab","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"etl_key":"3","bug_type":"309","os_version":"macOS 11.3","incident_id":"FA21DF23-3344-4E45-BF27-4B8E63B7012B","name":"json.test.tmp.out"}
{
"uptime" : 320000,
"procLaunch" : "2021-03-08 13:56:51.7232 -0800",
"procRole" : "Unspecified",
"version" : 2,
"exception" : {
"type" : "EXC_BAD_ACCESS",
"signal" : "SIGSEGV",
"subtype" : "KERN_INVALID_ADDRESS at 0x0000000000000000"
},
"userID" : 501,
"modelCode" : "iMacPro1,1",
"coalitionID" : 6086,
"osVersion" : {
"train" : "macOS 11.3",
"build" : "",
"releaseType" : ""
},
"captureTime" : "2021-03-08 13:56:51.8610 -0800",
"incident" : "FA21DF23-3344-4E45-BF27-4B8E63B7012B",
"pid" : 72932,
"cpuType" : "X86-64",
"procName" : "json.test.tmp.out",
"procPath" : "\/Users\/USER\/*\/json.test.tmp.out",
"parentProc" : "fish",
"parentPid" : 67002,
"coalitionName" : "io.alacritty",
"crashReporterKey" : "DCEF35CB-68D5-F524-FF13-060901F52EA8",
"responsiblePid" : 65465,
"responsibleProc" : "alacritty",
"bridgeVersion" : {"build":"18P4544","train":"5.3"},
"sip" : "enabled",
"isCorpse" : 1,
"termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":72932},
"asi" : {"dyld":["dyld2 mode"]},
"extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":125361,"task_for_pid":9935},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
"faultingThread" : 0,
"threads" : [
{
"triggered": true,
"id": 6152004,
"name": "Crashing Thread Name",
"queue": "com.apple.main-thread",
"frames": [
{
"imageOffset": @foo@,
"sourceLine": 3,
"sourceFile": "test.c",
"symbol": "foo",
"imageIndex": 0,
"symbolLocation": 16
},
{
"imageOffset": @bar@,
"sourceLine": 6,
"sourceFile": "test.c",
"symbol": "bar",
"imageIndex": 0,
"symbolLocation": 9
},
{
"imageOffset": @main@,
"sourceLine": 8,
"sourceFile": "test.c",
"symbol": "main",
"imageIndex": 0,
"symbolLocation": 20
},
{
"imageOffset": 89917,
"symbol": "start",
"symbolLocation": 1,
"imageIndex": 1
}
]
}
],
"usedImages" : [
{
"source" : "P",
"arch" : "x86_64",
"base" : 4355608576,
"size" : 16384,
"uuid" : "@UUID@",
"path" : "@EXEC@",
"name" : "@NAME@"
},
{
"source" : "P",
"arch" : "x86_64",
"base" : 140733734899712,
"size" : 245760,
"uuid" : "c5caf30b-0617-3b07-88c7-6319cd06f30a",
"path" : "\/usr\/lib\/system\/libdyld.dylib",
"name" : "libdyld.dylib"
}
],
"legacyInfo" : {
"threadTriggered" : {
"queue" : "com.apple.main-thread"
}
}
}
2 changes: 2 additions & 0 deletions lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
# CHECK: [ 2] {{.*}}out`main + 19 at test.c
# CHECK: rbp = 0x00007ffeec22a530
# CHECK: invalid foo
# CHECK: invalid bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RUN: %clang_host -g %S/Inputs/test.c -o %t.out

# RUN: cp %S/Inputs/no_threadState.ips %t.crash
# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s

# CHECK: Thread[0] Crashing Thread Name 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: No thread state (register information) available