aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/Shell/ScriptInterpreter/Python/Crashlog
diff options
context:
space:
mode:
authorMed Ismail Bennani <ismail@bennani.ma>2023-08-18 20:47:35 +0100
committerMed Ismail Bennani <ismail@bennani.ma>2023-08-18 20:50:39 +0100
commit4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df (patch)
treeed1f1c9974654bdb76ce86460013a92f0d71b65e /lldb/test/Shell/ScriptInterpreter/Python/Crashlog
parent3054a0c4bc50856156f26b528895ddcfba4210fa (diff)
downloadllvm-4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df.zip
llvm-4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df.tar.gz
llvm-4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df.tar.bz2
[lldb/crashlog] Add support for Last Exception Backtrace
This patch adds support to the "Last Exception Backtrace" to the `crashlog` command. This metadata is homologous to the "Application Specific Backtrace", however the format is closer to a regular stack frame. Since the thread that "contains" the "Last Exception Backtrace" doesn't really exist, this information is displayed when requesting an extended backtrace of the crashed thread, similarly to the "Application Specific Backtrace". To achieve that, this patch includes some refactors and fixes to the existing "Application Specific Backtrace" handling. rdar://113046509 Differential Revision: https://reviews.llvm.org/D157851 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/test/Shell/ScriptInterpreter/Python/Crashlog')
-rw-r--r--lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt1
-rw-r--r--lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/leb.txt131
-rw-r--r--lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test52
3 files changed, 183 insertions, 1 deletions
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
index 8d151a3..1880b83 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
@@ -37,7 +37,6 @@
"asi" : {"CoreFoundation":["*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 10 beyond bounds [0 .. 3]'"],"libsystem_c.dylib":["abort() called"],"libc++abi.dylib":["terminating with uncaught exception of type NSException"]},
"asiBacktraces" : ["0 CoreFoundation 0x00000001a0a58418 __exceptionPreprocess + 176\n1 libobjc.A.dylib 0x00000001a05a2ea8 objc_exception_throw + 60\n2 CoreFoundation 0x00000001a0b3dcc4 -[__NSCFString characterAtIndex:].cold.1 + 0\n3 CoreFoundation 0x00000001a0b46af4 -[__NSArrayI getObjects:range:].cold.1 + 0\n4 CoreFoundation 0x00000001a09a12a4 __CFPropertyListIsArrayPlistAux + 0\n5 asi 0x00000001047e3ed0 main + 128\n6 dyld 0x00000001a05d3e50 start + 2544"],
"extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":4,"task_for_pid":4},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
- "lastExceptionBacktrace" : [{"imageOffset":1033228,"symbol":"__exceptionPreprocess","symbolLocation":164,"imageIndex":5},{"imageOffset":110248,"symbol":"objc_exception_throw","symbolLocation":60,"imageIndex":4},{"imageOffset":1973444,"symbol":"-[__NSCFString characterAtIndex:].cold.1","symbolLocation":0,"imageIndex":5},{"imageOffset":2009844,"symbol":"-[__NSArrayI getObjects:range:].cold.1","symbolLocation":0,"imageIndex":5},{"imageOffset":283300,"symbol":"__CFPropertyListIsArrayPlistAux","symbolLocation":0,"imageIndex":5},{"imageOffset":16080,"symbol":"main","symbolLocation":128,"imageIndex":6},{"imageOffset":24144,"symbol":"start","symbolLocation":2544,"imageIndex":7}],
"faultingThread" : 0,
"threads" : [{"triggered":true,"id":1767667,"threadState":{"x":[{"value":0},{"value":0},{"value":0},{"value":0},{"value":6988476661},{"value":6096540848},{"value":110},{"value":512},{"value":502518818286880576},{"value":502518810403597248},{"value":512},{"value":11},{"value":11},{"value":2095104},{"value":2043},{"value":2195963912},{"value":328},{"value":8604857144},{"value":0},{"value":6},{"value":8522738816,"symbolLocation":0,"symbol":"_main_thread"},{"value":259},{"value":8522739040,"symbolLocation":224,"symbol":"_main_thread"},{"value":105553117118464},{"value":8528036928,"symbolLocation":0,"symbol":"gProcessInfo"},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6988750060},"cpsr":{"value":1073745920},"fp":{"value":6096540704},"sp":{"value":6096540672},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6988526116,"matchesCrashFrame":1},"far":{"value":5452680264}},"queue":"com.apple.main-thread","frames":[{"imageOffset":37412,"symbol":"__pthread_kill","symbolLocation":8,"imageIndex":0},{"imageOffset":27884,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":1},{"imageOffset":496328,"symbol":"abort","symbolLocation":180,"imageIndex":2},{"imageOffset":72472,"symbol":"abort_message","symbolLocation":132,"imageIndex":3},{"imageOffset":6668,"symbol":"demangling_terminate_handler()","symbolLocation":336,"imageIndex":3},{"imageOffset":145252,"symbol":"_objc_terminate()","symbolLocation":144,"imageIndex":4},{"imageOffset":69300,"symbol":"std::__terminate(void (*)())","symbolLocation":20,"imageIndex":3},{"imageOffset":80940,"symbol":"__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*)","symbolLocation":36,"imageIndex":3},{"imageOffset":80856,"symbol":"__cxa_throw","symbolLocation":140,"imageIndex":3},{"imageOffset":110600,"symbol":"objc_exception_throw","symbolLocation":412,"imageIndex":4},{"imageOffset":1973444,"symbol":"_CFThrowFormattedException","symbolLocation":108,"imageIndex":5},{"imageOffset":2009844,"symbol":"__boundsFail","symbolLocation":92,"imageIndex":5},{"imageOffset":283300,"symbol":"-[__NSArrayI objectAtIndex:]","symbolLocation":60,"imageIndex":5},{"imageOffset":16080,"symbol":"main","symbolLocation":128,"imageIndex":6},{"imageOffset":24144,"symbol":"start","symbolLocation":2544,"imageIndex":7}]}],
"usedImages" : [
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/leb.txt b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/leb.txt
new file mode 100644
index 0000000..8d151a3
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/leb.txt
@@ -0,0 +1,131 @@
+{"app_name":"asi","timestamp":"2022-10-07 11:31:53.00 -0700","app_version":"","slice_uuid":"2cee52c2-2d9c-3e64-bdd0-c43ccd1b37ec","build_version":"","platform":1,"share_with_app_devs":0,"is_first_party":1,"bug_type":"309","os_version":"macOS 13.0","roots_installed":0,"incident_id":"E62DF457-8BBC-4E92-AECA-11D1B55246E3","name":"asi"}
+{
+ "uptime" : 90000,
+ "procRole" : "Unspecified",
+ "version" : 2,
+ "userID" : 501,
+ "deployVersion" : 210,
+ "modelCode" : "Mac13,1",
+ "coalitionID" : 495,
+ "osVersion" : {
+ "train" : "macOS 13.0",
+ "build" : "",
+ "releaseType" : ""
+ },
+ "captureTime" : "2022-10-07 11:31:52.6211 -0700",
+ "incident" : "E62DF457-8BBC-4E92-AECA-11D1B55246E3",
+ "pid" : 96535,
+ "translated" : false,
+ "cpuType" : "ARM-64",
+ "roots_installed" : 0,
+ "bug_type" : "309",
+ "procLaunch" : "2022-10-07 11:31:52.4969 -0700",
+ "procStartAbsTime" : 2167631132529,
+ "procExitAbsTime" : 2167634104978,
+ "procName" : "asi",
+ "procPath" : "\/Users\/USER\/*\/asi",
+ "parentProc" : "zsh",
+ "parentPid" : 96199,
+ "coalitionName" : "com.apple.Terminal",
+ "crashReporterKey" : "533C17C1-DBB1-4134-1FDE-68346F18AAA2",
+ "responsiblePid" : 615,
+ "responsibleProc" : "Terminal",
+ "wakeTime" : 1351,
+ "sleepWakeUUID" : "AD23E0A0-A4A5-4B6B-925F-2FC3665C17BF",
+ "sip" : "enabled",
+ "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
+ "asi" : {"CoreFoundation":["*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 10 beyond bounds [0 .. 3]'"],"libsystem_c.dylib":["abort() called"],"libc++abi.dylib":["terminating with uncaught exception of type NSException"]},
+ "asiBacktraces" : ["0 CoreFoundation 0x00000001a0a58418 __exceptionPreprocess + 176\n1 libobjc.A.dylib 0x00000001a05a2ea8 objc_exception_throw + 60\n2 CoreFoundation 0x00000001a0b3dcc4 -[__NSCFString characterAtIndex:].cold.1 + 0\n3 CoreFoundation 0x00000001a0b46af4 -[__NSArrayI getObjects:range:].cold.1 + 0\n4 CoreFoundation 0x00000001a09a12a4 __CFPropertyListIsArrayPlistAux + 0\n5 asi 0x00000001047e3ed0 main + 128\n6 dyld 0x00000001a05d3e50 start + 2544"],
+ "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":4,"task_for_pid":4},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
+ "lastExceptionBacktrace" : [{"imageOffset":1033228,"symbol":"__exceptionPreprocess","symbolLocation":164,"imageIndex":5},{"imageOffset":110248,"symbol":"objc_exception_throw","symbolLocation":60,"imageIndex":4},{"imageOffset":1973444,"symbol":"-[__NSCFString characterAtIndex:].cold.1","symbolLocation":0,"imageIndex":5},{"imageOffset":2009844,"symbol":"-[__NSArrayI getObjects:range:].cold.1","symbolLocation":0,"imageIndex":5},{"imageOffset":283300,"symbol":"__CFPropertyListIsArrayPlistAux","symbolLocation":0,"imageIndex":5},{"imageOffset":16080,"symbol":"main","symbolLocation":128,"imageIndex":6},{"imageOffset":24144,"symbol":"start","symbolLocation":2544,"imageIndex":7}],
+ "faultingThread" : 0,
+ "threads" : [{"triggered":true,"id":1767667,"threadState":{"x":[{"value":0},{"value":0},{"value":0},{"value":0},{"value":6988476661},{"value":6096540848},{"value":110},{"value":512},{"value":502518818286880576},{"value":502518810403597248},{"value":512},{"value":11},{"value":11},{"value":2095104},{"value":2043},{"value":2195963912},{"value":328},{"value":8604857144},{"value":0},{"value":6},{"value":8522738816,"symbolLocation":0,"symbol":"_main_thread"},{"value":259},{"value":8522739040,"symbolLocation":224,"symbol":"_main_thread"},{"value":105553117118464},{"value":8528036928,"symbolLocation":0,"symbol":"gProcessInfo"},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6988750060},"cpsr":{"value":1073745920},"fp":{"value":6096540704},"sp":{"value":6096540672},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6988526116,"matchesCrashFrame":1},"far":{"value":5452680264}},"queue":"com.apple.main-thread","frames":[{"imageOffset":37412,"symbol":"__pthread_kill","symbolLocation":8,"imageIndex":0},{"imageOffset":27884,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":1},{"imageOffset":496328,"symbol":"abort","symbolLocation":180,"imageIndex":2},{"imageOffset":72472,"symbol":"abort_message","symbolLocation":132,"imageIndex":3},{"imageOffset":6668,"symbol":"demangling_terminate_handler()","symbolLocation":336,"imageIndex":3},{"imageOffset":145252,"symbol":"_objc_terminate()","symbolLocation":144,"imageIndex":4},{"imageOffset":69300,"symbol":"std::__terminate(void (*)())","symbolLocation":20,"imageIndex":3},{"imageOffset":80940,"symbol":"__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*)","symbolLocation":36,"imageIndex":3},{"imageOffset":80856,"symbol":"__cxa_throw","symbolLocation":140,"imageIndex":3},{"imageOffset":110600,"symbol":"objc_exception_throw","symbolLocation":412,"imageIndex":4},{"imageOffset":1973444,"symbol":"_CFThrowFormattedException","symbolLocation":108,"imageIndex":5},{"imageOffset":2009844,"symbol":"__boundsFail","symbolLocation":92,"imageIndex":5},{"imageOffset":283300,"symbol":"-[__NSArrayI objectAtIndex:]","symbolLocation":60,"imageIndex":5},{"imageOffset":16080,"symbol":"main","symbolLocation":128,"imageIndex":6},{"imageOffset":24144,"symbol":"start","symbolLocation":2544,"imageIndex":7}]}],
+ "usedImages" : [
+ {
+ "source" : "P",
+ "arch" : "arm64e",
+ "base" : 6988488704,
+ "size" : 233468,
+ "uuid" : "15147572-bf8d-359e-a6bb-97f4489e7f78",
+ "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
+ "name" : "libsystem_kernel.dylib"
+ },
+ {
+ "source" : "P",
+ "arch" : "arm64e",
+ "base" : 6988722176,
+ "size" : 53244,
+ "uuid" : "19a65066-147a-37e1-be56-bd78821ef285",
+ "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
+ "name" : "libsystem_pthread.dylib"
+ },
+ {
+ "source" : "P",
+ "arch" : "arm64e",
+ "base" : 6987440128,
+ "size" : 528372,
+ "uuid" : "cd2fafb3-239f-3929-9b9d-ed1768c25159",
+ "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
+ "name" : "libsystem_c.dylib"
+ },
+ {
+ "source" : "P",
+ "arch" : "arm64e",
+ "base" : 6988390400,
+ "size" : 98300,
+ "uuid" : "88025d90-bb66-34a8-8628-91ec5b3fb900",
+ "path" : "\/usr\/lib\/libc++abi.dylib",
+ "name" : "libc++abi.dylib"
+ },
+ {
+ "source" : "P",
+ "arch" : "arm64e",
+ "base" : 6985121792,
+ "size" : 286112,
+ "uuid" : "9a019b6d-aeb6-3a3e-9c74-717c18dd5d43",
+ "path" : "\/usr\/lib\/libobjc.A.dylib",
+ "name" : "libobjc.A.dylib"
+ },
+ {
+ "source" : "P",
+ "arch" : "arm64e",
+ "base" : 6989135872,
+ "CFBundleShortVersionString" : "6.9",
+ "CFBundleIdentifier" : "com.apple.CoreFoundation",
+ "size" : 5079040,
+ "uuid" : "0cb1d6ec-b4ee-33d5-9828-29db31cad6fc",
+ "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
+ "name" : "CoreFoundation",
+ "CFBundleVersion" : "1953.1"
+ },
+ {
+ "source" : "P",
+ "arch" : "arm64",
+ "base" : 4370333696,
+ "size" : 16384,
+ "uuid" : "2cee52c2-2d9c-3e64-bdd0-c43ccd1b37ec",
+ "path" : "\/Users\/USER\/*\/asi",
+ "name" : "asi"
+ },
+ {
+ "source" : "P",
+ "arch" : "arm64e",
+ "base" : 6985408512,
+ "size" : 566452,
+ "uuid" : "0d973234-ed2d-3a07-889a-46b424e29ae0",
+ "path" : "\/usr\/lib\/dyld",
+ "name" : "dyld"
+ }
+],
+ "sharedCache" : {
+ "base" : 6984761344,
+ "size" : 3405660160,
+ "uuid" : "5fe7ffdc-ba32-33ba-8827-d3d9094c6bc3"
+},
+ "vmSummary" : "ReadOnly portion of Libraries: Total=861.7M resident=0K(0%) swapped_out_or_unallocated=861.7M(100%)\nWritable regions: Total=666.4M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=666.4M(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nActivity Tracing 256K 1 \nKernel Alloc Once 32K 1 \nMALLOC 154.2M 14 \nMALLOC guard page 96K 5 \nMALLOC_MEDIUM (reserved) 120.0M 1 reserved VM address space (unallocated)\nMALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)\nSTACK GUARD 56.0M 1 \nStack 8176K 1 \n__AUTH 307K 58 \n__AUTH_CONST 3560K 142 \n__DATA 1494K 136 \n__DATA_CONST 3988K 144 \n__DATA_DIRTY 361K 58 \n__LINKEDIT 763.4M 2 \n__OBJC_CONST 289K 36 \n__OBJC_RO 65.1M 1 \n__OBJC_RW 1983K 1 \n__TEXT 98.3M 151 \ndyld private memory 256K 1 \nshared memory 80K 4 \n=========== ======= ======= \nTOTAL 1.6G 759 \nTOTAL, minus reserved VM space 1.1G 759 \n",
+ "legacyInfo" : {
+ "threadTriggered" : {
+ "queue" : "com.apple.main-thread"
+ }
+}
+}
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
new file mode 100644
index 0000000..c2f6196
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
@@ -0,0 +1,52 @@
+# REQUIRES: python, native && target-aarch64 && system-darwin
+
+# RUN: mkdir -p %t.dir
+# RUN: yaml2obj %S/Inputs/application_specific_info/asi.yaml > %t.dir/asi
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -a -i -t %t.dir/asi %S/Inputs/application_specific_info/leb.txt' \
+# RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: (lldb) process status --verbose
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT: frame #0: 0x00000001a08c7224{{.*}}[artificial]
+# CHECK: Extended Crash Information:
+# CHECK: Application Specific Information:
+# CHECK-NEXT: CoreFoundation: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 10 beyond bounds [0 .. 3]'
+# CHECK-NEXT: libc++abi.dylib: terminating with uncaught exception of type NSException
+# CHECK-NEXT: libsystem_c.dylib: abort() called
+
+
+# CHECK: (lldb) thread backtrace --extended true
+# CHECK: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT: * frame #0: 0x00000001a08c7224{{.*}}[artificial]
+# CHECK-NEXT: frame #1: 0x00000001a08fdceb{{.*}}[artificial]
+# CHECK-NEXT: frame #2: 0x00000001a08372c7{{.*}}[artificial]
+# CHECK-NEXT: frame #3: 0x00000001a08b7b17{{.*}}[artificial]
+# CHECK-NEXT: frame #4: 0x00000001a08a7a0b{{.*}}[artificial]
+# CHECK-NEXT: frame #5: 0x00000001a05ab763{{.*}}[artificial]
+# CHECK-NEXT: frame #6: 0x00000001a08b6eb3{{.*}}[artificial]
+# CHECK-NEXT: frame #7: 0x00000001a08b9c2b{{.*}}[artificial]
+# CHECK-NEXT: frame #8: 0x00000001a08b9bd7{{.*}}[artificial]
+# CHECK-NEXT: frame #9: 0x00000001a05a3007{{.*}}[artificial]
+# CHECK-NEXT: frame #10: 0x00000001a0b3dcc3{{.*}}[artificial]
+# CHECK-NEXT: frame #11: 0x00000001a0b46af3{{.*}}[artificial]
+# CHECK-NEXT: frame #12: 0x00000001a09a12a3{{.*}}[artificial]
+# CHECK-NEXT: frame #13: 0x00000001047e3ecf asi`main{{.*}}[artificial]
+# CHECK-NEXT: frame #14: 0x00000001a05d3e4f{{.*}}[artificial]
+
+# CHECK: thread #4294967295: tid = 0x0001, 0x00000001a0a5840c{{.*}}, queue = 'Application Specific Backtrace'
+# CHECK-NEXT: frame #0: 0x00000001a0a5840c{{.*}}
+# CHECK-NEXT: frame #1: 0x00000001a05a2ea7{{.*}}
+# CHECK-NEXT: frame #2: 0x00000001a0b3dcc3{{.*}}
+# CHECK-NEXT: frame #3: 0x00000001a0b46af3{{.*}}
+# CHECK-NEXT: frame #4: 0x00000001a09a12a3{{.*}}
+# CHECK-NEXT: frame #5: 0x00000001047e3ecf asi`main{{.*}}
+# CHECK-NEXT: frame #6: 0x00000001a05d3e4f
+
+
+# CHECK: (lldb) thread list
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1: tid = 0x1af8f3, 0x00000001a08c7224{{.*}}, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)