[lldb] Update crashlog script for JSON changes
Update the crashlog script for changes to the JSON schema. rdar://75122914 Differential revision: https://reviews.llvm.org/D98219
This commit is contained in:
parent
c2d2adbce9
commit
cc52ea3001
@ -415,13 +415,9 @@ class JSONCrashLogParser:
|
|||||||
|
|
||||||
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
|
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
|
||||||
thread.reason = self.parse_crash_reason(self.data['exception'])
|
thread.reason = self.parse_crash_reason(self.data['exception'])
|
||||||
thread.registers = self.parse_thread_registers(self.data['threadState'])
|
|
||||||
|
|
||||||
return self.crashlog
|
return self.crashlog
|
||||||
|
|
||||||
def get_image_extra_info(self, idx):
|
|
||||||
return self.data['legacyInfo']['imageExtraInfo'][idx]
|
|
||||||
|
|
||||||
def get_used_image(self, idx):
|
def get_used_image(self, idx):
|
||||||
return self.data['usedImages'][idx]
|
return self.data['usedImages'][idx]
|
||||||
|
|
||||||
@ -444,13 +440,12 @@ class JSONCrashLogParser:
|
|||||||
|
|
||||||
def parse_images(self, json_images):
|
def parse_images(self, json_images):
|
||||||
idx = 0
|
idx = 0
|
||||||
for json_images in json_images:
|
for json_image in json_images:
|
||||||
img_uuid = uuid.UUID(json_images[0])
|
img_uuid = uuid.UUID(json_image['uuid'])
|
||||||
low = int(json_images[1])
|
low = int(json_image['base'])
|
||||||
high = 0
|
high = int(0)
|
||||||
extra_info = self.get_image_extra_info(idx)
|
name = json_image['name']
|
||||||
name = extra_info['name']
|
path = json_image['path']
|
||||||
path = extra_info['path']
|
|
||||||
version = ""
|
version = ""
|
||||||
darwin_image = self.crashlog.DarwinImage(low, high, name, version,
|
darwin_image = self.crashlog.DarwinImage(low, high, name, version,
|
||||||
img_uuid, path,
|
img_uuid, path,
|
||||||
@ -461,16 +456,14 @@ class JSONCrashLogParser:
|
|||||||
def parse_frames(self, thread, json_frames):
|
def parse_frames(self, thread, json_frames):
|
||||||
idx = 0
|
idx = 0
|
||||||
for json_frame in json_frames:
|
for json_frame in json_frames:
|
||||||
image_id = int(json_frame[0])
|
image_id = int(json_frame['imageIndex'])
|
||||||
|
ident = self.get_used_image(image_id)['name']
|
||||||
ident = self.get_image_extra_info(image_id)['name']
|
|
||||||
thread.add_ident(ident)
|
thread.add_ident(ident)
|
||||||
if ident not in self.crashlog.idents:
|
if ident not in self.crashlog.idents:
|
||||||
self.crashlog.idents.append(ident)
|
self.crashlog.idents.append(ident)
|
||||||
|
|
||||||
frame_offset = int(json_frame[1])
|
frame_offset = int(json_frame['imageOffset'])
|
||||||
image = self.get_used_image(image_id)
|
image_addr = self.get_used_image(image_id)['base']
|
||||||
image_addr = int(image[1])
|
|
||||||
pc = image_addr + frame_offset
|
pc = image_addr + frame_offset
|
||||||
thread.frames.append(self.crashlog.Frame(idx, pc, frame_offset))
|
thread.frames.append(self.crashlog.Frame(idx, pc, frame_offset))
|
||||||
idx += 1
|
idx += 1
|
||||||
@ -481,6 +474,8 @@ class JSONCrashLogParser:
|
|||||||
thread = self.crashlog.Thread(idx, False)
|
thread = self.crashlog.Thread(idx, False)
|
||||||
if json_thread.get('triggered', False):
|
if json_thread.get('triggered', False):
|
||||||
self.crashlog.crashed_thread_idx = idx
|
self.crashlog.crashed_thread_idx = idx
|
||||||
|
self.registers = self.parse_thread_registers(
|
||||||
|
json_thread['threadState'])
|
||||||
thread.queue = json_thread.get('queue')
|
thread.queue = json_thread.get('queue')
|
||||||
self.parse_frames(thread, json_thread.get('frames', []))
|
self.parse_frames(thread, json_thread.get('frames', []))
|
||||||
self.crashlog.threads.append(thread)
|
self.crashlog.threads.append(thread)
|
||||||
@ -489,15 +484,16 @@ class JSONCrashLogParser:
|
|||||||
def parse_thread_registers(self, json_thread_state):
|
def parse_thread_registers(self, json_thread_state):
|
||||||
idx = 0
|
idx = 0
|
||||||
registers = dict()
|
registers = dict()
|
||||||
for reg in json_thread_state.get('x', []):
|
for json_reg in json_thread_state.get('x', []):
|
||||||
key = str('x{}'.format(idx))
|
key = str('x{}'.format(idx))
|
||||||
value = int(reg)
|
value = int(json_reg['value'])
|
||||||
registers[key] = value
|
registers[key] = value
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
for register in ['lr', 'cpsr', 'fp', 'sp', 'esr', 'pc']:
|
for register in ['lr', 'cpsr', 'fp', 'sp', 'esr', 'pc']:
|
||||||
if register in json_thread_state:
|
if register in json_thread_state:
|
||||||
registers[register] = int(json_thread_state[register])
|
json_reg = json_thread_state[register]
|
||||||
|
registers[register] = int(json_reg['value'])
|
||||||
|
|
||||||
return registers
|
return registers
|
||||||
|
|
||||||
|
@ -1,95 +1,172 @@
|
|||||||
{"app_name":"a.out","timestamp":"2020-11-11 16:12:18.00 -0800","app_version":"","slice_uuid":"9b76648c-9b4e-33a9-a97e-10856e911631","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"bug_type":"309","os_version":"macOS 11.0.1","incident_id":"598C4706-28B0-4D96-A2F9-AE6973BEC635","name":"a.out"}
|
{"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" : 180,
|
"uptime" : 320000,
|
||||||
"procLaunch" : "2020-11-11 16:12:12.4375 -0800",
|
"procLaunch" : "2021-03-08 13:56:51.7232 -0800",
|
||||||
"procRole" : "Unspecified",
|
"procRole" : "Unspecified",
|
||||||
|
"version" : 2,
|
||||||
"exception" : {
|
"exception" : {
|
||||||
"type" : "EXC_BAD_ACCESS",
|
"type" : "EXC_BAD_ACCESS",
|
||||||
"signal" : "SIGSEGV",
|
"signal" : "SIGSEGV",
|
||||||
"subtype" : "KERN_INVALID_ADDRESS at 0x00000000"
|
"subtype" : "KERN_INVALID_ADDRESS at 0x0000000000000000"
|
||||||
},
|
},
|
||||||
"userID" : 501,
|
"userID" : 501,
|
||||||
"modelCode" : "iMacPro1,1",
|
"modelCode" : "iMacPro1,1",
|
||||||
"coalitionID" : 471,
|
"coalitionID" : 6086,
|
||||||
"osVersion" : {
|
"osVersion" : {
|
||||||
"train" : "macOS 11.0.1",
|
"train" : "macOS 11.3",
|
||||||
"build" : "",
|
"build" : "",
|
||||||
"releaseType" : ""
|
"releaseType" : ""
|
||||||
},
|
},
|
||||||
"captureTime" : "2020-11-11 16:12:12.6267 -0800",
|
"captureTime" : "2021-03-08 13:56:51.8610 -0800",
|
||||||
"incident" : "598C4706-28B0-4D96-A2F9-AE6973BEC635",
|
"incident" : "FA21DF23-3344-4E45-BF27-4B8E63B7012B",
|
||||||
"pid" : 2187,
|
"pid" : 72932,
|
||||||
"cpuType" : "X86-64",
|
"cpuType" : "X86-64",
|
||||||
"procName" : "a.out",
|
"procName" : "json.test.tmp.out",
|
||||||
"procPath" : "\/private\/tmp\/a.out",
|
"procPath" : "\/Users\/USER\/*\/json.test.tmp.out",
|
||||||
"parentProc" : "fish",
|
"parentProc" : "fish",
|
||||||
"parentPid" : 1651,
|
"parentPid" : 67002,
|
||||||
"coalitionName" : "io.alacritty",
|
"coalitionName" : "io.alacritty",
|
||||||
"crashReporterKey" : "DCEF35CB-68D5-F524-FF13-060901F52EA8",
|
"crashReporterKey" : "DCEF35CB-68D5-F524-FF13-060901F52EA8",
|
||||||
"responsiblePid" : 428,
|
"responsiblePid" : 65465,
|
||||||
"responsibleProc" : "alacritty",
|
"responsibleProc" : "alacritty",
|
||||||
"bridgeVersion" : {"build":"","train":""},
|
"bridgeVersion" : {"build":"18P4544","train":"5.3"},
|
||||||
"sip" : "enabled",
|
"sip" : "enabled",
|
||||||
"is_corpse" : 1,
|
"isCorpse" : 1,
|
||||||
"termination" : {"reason":"Namespace SIGNAL, Code 0xb","signal":"Segmentation fault: 11","byProc":"exc handler","code":11,"namespace":"SIGNAL","byPid":2187,"flags":0},
|
"termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":72932},
|
||||||
"asi" : ["dyld2 mode"],
|
"asi" : {"dyld":["dyld2 mode"]},
|
||||||
"extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":2067},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
|
"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},
|
||||||
"threads" : [{"triggered":true,"id":22172,"queue":"com.apple.main-thread","frames":[[0,@foo@],[0,@bar@],[0,@main@],[1,87601]]}],
|
"faultingThread" : 0,
|
||||||
"threadState" : {
|
"threads" : [
|
||||||
"r13" : 0,
|
|
||||||
"rax" : 0,
|
|
||||||
"rflags" : 66054,
|
|
||||||
"cpu" : 6,
|
|
||||||
"rsi" : 140732908048520,
|
|
||||||
"r14" : 0,
|
|
||||||
"trap_description" : "(no mapping for user data write)",
|
|
||||||
"r8" : 0,
|
|
||||||
"cr2" : 0,
|
|
||||||
"rdx" : 140732908048536,
|
|
||||||
"r10" : 0,
|
|
||||||
"r9" : 0,
|
|
||||||
"r15" : 0,
|
|
||||||
"rbx" : 0,
|
|
||||||
"trap" : 14,
|
|
||||||
"err" : 6,
|
|
||||||
"r11" : 0,
|
|
||||||
"rip" : 4307689328,
|
|
||||||
"rbp" : 140732908048432,
|
|
||||||
"rsp" : 140732908048432,
|
|
||||||
"r12" : 0,
|
|
||||||
"rcx" : 140732908048880,
|
|
||||||
"flavor" : "x86_THREAD_STATE",
|
|
||||||
"rdi" : 1
|
|
||||||
},
|
|
||||||
"usedImages" : [
|
|
||||||
[
|
|
||||||
"@UUID@",
|
|
||||||
4294967296,
|
|
||||||
"P"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"6a1f593e-3705-314d-bb40-e7f9d502bf81",
|
|
||||||
140733737017344,
|
|
||||||
"P"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"legacyInfo" : {
|
|
||||||
"imageExtraInfo" : [
|
|
||||||
{
|
{
|
||||||
"size" : 16384,
|
"triggered": true,
|
||||||
|
"id": 6152004,
|
||||||
|
"threadState": {
|
||||||
|
"r13": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rax": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rflags": {
|
||||||
|
"value": 66054
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
"value": 4
|
||||||
|
},
|
||||||
|
"r14": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rsi": {
|
||||||
|
"value": 140732860114304
|
||||||
|
},
|
||||||
|
"r8": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"cr2": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rdx": {
|
||||||
|
"value": 140732860114320
|
||||||
|
},
|
||||||
|
"r10": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"r9": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"r15": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rbx": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"trap": {
|
||||||
|
"value": 14,
|
||||||
|
"description": "(no mapping for user data write)"
|
||||||
|
},
|
||||||
|
"err": {
|
||||||
|
"value": 6
|
||||||
|
},
|
||||||
|
"r11": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rip": {
|
||||||
|
"value": 4355624816
|
||||||
|
},
|
||||||
|
"rbp": {
|
||||||
|
"value": 140732860114224
|
||||||
|
},
|
||||||
|
"rsp": {
|
||||||
|
"value": 140732860114224
|
||||||
|
},
|
||||||
|
"r12": {
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"rcx": {
|
||||||
|
"value": 140732860114656
|
||||||
|
},
|
||||||
|
"flavor": "x86_THREAD_STATE",
|
||||||
|
"rdi": {
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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",
|
"arch" : "x86_64",
|
||||||
|
"base" : 4355608576,
|
||||||
|
"size" : 16384,
|
||||||
|
"uuid" : "@UUID@",
|
||||||
"path" : "@EXEC@",
|
"path" : "@EXEC@",
|
||||||
"name" : "@NAME@"
|
"name" : "@NAME@"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : 241664,
|
"source" : "P",
|
||||||
"arch" : "x86_64",
|
"arch" : "x86_64",
|
||||||
|
"base" : 140733734899712,
|
||||||
|
"size" : 245760,
|
||||||
|
"uuid" : "c5caf30b-0617-3b07-88c7-6319cd06f30a",
|
||||||
"path" : "\/usr\/lib\/system\/libdyld.dylib",
|
"path" : "\/usr\/lib\/system\/libdyld.dylib",
|
||||||
"name" : "libdyld.dylib"
|
"name" : "libdyld.dylib"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"legacyInfo" : {
|
||||||
"threadTriggered" : {
|
"threadTriggered" : {
|
||||||
"index" : 0,
|
|
||||||
"queue" : "com.apple.main-thread"
|
"queue" : "com.apple.main-thread"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
|
# 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
|
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
|
||||||
|
|
||||||
# CHECK: Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x00000000)
|
# CHECK: Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000000)
|
||||||
# CHECK: [ 0] {{.*}}out`foo + 16 at test.c
|
# CHECK: [ 0] {{.*}}out`foo + 16 at test.c
|
||||||
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
|
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
|
||||||
# CHECK: [ 2] {{.*}}out`main + 19 at test.c
|
# CHECK: [ 2] {{.*}}out`main + 19 at test.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user