This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c4f0d81f47c: [lldb/crashlog] Add support for Last Exception 
Backtrace (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D157851?vs=549854&id=551613#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157851/new/

https://reviews.llvm.org/D157851

Files:
  lldb/examples/python/crashlog.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/leb.txt
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
===================================================================
--- /dev/null
+++ 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)
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
===================================================================
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
+++ 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" : [
Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===================================================================
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -178,7 +178,7 @@
         self.idx = self.backing_thread.index
         self.tid = self.backing_thread.id
         if self.backing_thread.app_specific_backtrace:
-            self.name = "Application Specific Backtrace - " + str(self.idx)
+            self.name = "Application Specific Backtrace"
         else:
             self.name = self.backing_thread.name
         self.queue = self.backing_thread.queue
Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -586,10 +586,15 @@
             self.parse_threads(self.data["threads"])
             if "asi" in self.data:
                 self.crashlog.asi = self.data["asi"]
+            # FIXME: With the current design, we can either show the ASI or Last
+            # Exception Backtrace, not both. Is there a situation where we would
+            # like to show both ?
             if "asiBacktraces" in self.data:
                 self.parse_app_specific_backtraces(self.data["asiBacktraces"])
             if "lastExceptionBacktrace" in self.data:
-                self.crashlog.asb = self.data["lastExceptionBacktrace"]
+                self.parse_last_exception_backtraces(
+                    self.data["lastExceptionBacktrace"]
+                )
             self.parse_errors(self.data)
             thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
             reason = self.parse_crash_reason(self.data["exception"])
@@ -792,11 +797,22 @@
         return True
 
     def parse_app_specific_backtraces(self, json_app_specific_bts):
-        for idx, backtrace in enumerate(json_app_specific_bts):
-            thread = self.crashlog.Thread(idx, True, self.crashlog.process_arch)
-            thread.queue = "Application Specific Backtrace"
-            if self.parse_asi_backtrace(thread, backtrace):
-                self.crashlog.threads.append(thread)
+        thread = self.crashlog.Thread(
+            len(self.crashlog.threads), True, self.crashlog.process_arch
+        )
+        thread.queue = "Application Specific Backtrace"
+        if self.parse_asi_backtrace(thread, json_app_specific_bts[0]):
+            self.crashlog.threads.append(thread)
+        else:
+            print("error: Couldn't parse Application Specific Backtrace.")
+
+    def parse_last_exception_backtraces(self, json_last_exc_bts):
+        thread = self.crashlog.Thread(
+            len(self.crashlog.threads), True, self.crashlog.process_arch
+        )
+        thread.queue = "Last Exception Backtrace"
+        self.parse_frames(thread, json_last_exc_bts)
+        self.crashlog.threads.append(thread)
 
     def parse_thread_registers(self, json_thread_state, prefix=None):
         registers = dict()
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to