45 lines
2.4 KiB
Python
45 lines
2.4 KiB
Python
# -*- python -*-
|
|
# RUN: cd %S/../../../../../examples/python && cat %s | %lldb 2>&1 > %t.out
|
|
# RUN: cat %t.out | FileCheck %S/Inputs/Assertion.check
|
|
script
|
|
import crashlog
|
|
import json
|
|
|
|
parser = crashlog.JSONCrashLogParser("", "", False)
|
|
|
|
process_info_json = json.loads('{"pid" : 287, "procName" : "mediaserverd"}')
|
|
parser.parse_process_info(process_info_json)
|
|
|
|
assert parser.crashlog.process_id == 287
|
|
assert parser.crashlog.process_identifier == "mediaserverd"
|
|
|
|
crash_reason_json = json.loads('{"type" : "EXC_BAD_ACCESS", "signal" : "SIGSEGV", "subtype" : "KERN_INVALID_ADDRESS"}')
|
|
assert parser.parse_crash_reason(crash_reason_json) == "EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS)"
|
|
|
|
crash_reason_json = json.loads('{"type" : "EXC_BAD_ACCESS", "signal" : "SIGSEGV"}')
|
|
assert parser.parse_crash_reason(crash_reason_json) == "EXC_BAD_ACCESS (SIGSEGV)"
|
|
|
|
crash_reason_json = json.loads('{"type" : "EXC_BAD_ACCESS", "signal" : "SIGSEGV", "codes" : "0x0000000000000000, 0x0000000000000000"}')
|
|
assert parser.parse_crash_reason(crash_reason_json) == "EXC_BAD_ACCESS (SIGSEGV) (0x0000000000000000, 0x0000000000000000)"
|
|
|
|
thread_state_json = json.loads('{"x":[268451845,117442566],"lr":7309751904,"cpsr":1073741824,"fp":6093236784,"sp":6093236704,"esr":1442840704,"pc":7309755088}')
|
|
registers = parser.parse_thread_registers(thread_state_json)
|
|
assert registers['x0'] == 268451845
|
|
assert registers['x1'] == 117442566
|
|
assert registers['lr'] == 7309751904
|
|
assert registers['cpsr'] ==1073741824
|
|
assert registers['fp'] == 6093236784
|
|
assert registers['sp'] == 6093236704
|
|
assert registers['esr'] == 1442840704
|
|
assert registers['pc'] == 7309755088
|
|
|
|
parser.data = json.loads('{"usedImages":[["f4d85377-f215-3da3-921e-3fe870e622e9",7309737984,"P"]],"legacyInfo":{"imageExtraInfo":[{"size":204800,"arch":"arm64e","path":"/usr/lib/system/libsystem_kernel.dylib","name":"libsystem_kernel.dylib"}]}}')
|
|
thread_json = json.loads('[{"triggered":true,"id":3835,"queue":"com.apple.bwgraph.devicevendor","frames":[[0,101472],[0,408892]]}]')
|
|
parser.parse_threads(thread_json)
|
|
assert len(parser.crashlog.threads) == 1
|
|
assert parser.crashlog.threads[0].queue == "com.apple.bwgraph.devicevendor"
|
|
assert len(parser.crashlog.threads[0].frames) == 2
|
|
assert parser.crashlog.threads[0].frames[0].pc == 7309839456
|
|
assert parser.crashlog.threads[0].frames[0].description == 101472
|
|
exit()
|