JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, aprantl.
JDevlieghere requested review of this revision.

JSON crashlogs have an optional field named `reportNotes` that contains any 
potential errors encountered by the crash reporter when generating the 
crashlog. Parse and display them in LLDB.


https://reviews.llvm.org/D111339

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
===================================================================
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -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
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
===================================================================
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
@@ -170,5 +170,9 @@
   "threadTriggered" : {
     "queue" : "com.apple.main-thread"
   }
-}
+},
+  "reportNotes" : [
+  "invalid foo",
+  "invalid bar"
+]
 }
Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -330,6 +330,7 @@
         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
@@ -433,6 +434,7 @@
             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:
@@ -523,6 +525,10 @@
                pass
         return registers
 
+    def parse_errors(self, json_data):
+       if 'reportNotes' in json_data:
+          self.crashlog.errors = json_data['reportNotes']
+
 
 class CrashLogParseMode:
     NORMAL = 0
@@ -1062,6 +1068,11 @@
         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,


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
===================================================================
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -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
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
===================================================================
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
@@ -170,5 +170,9 @@
   "threadTriggered" : {
     "queue" : "com.apple.main-thread"
   }
-}
+},
+  "reportNotes" : [
+  "invalid foo",
+  "invalid bar"
+]
 }
Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -330,6 +330,7 @@
         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
@@ -433,6 +434,7 @@
             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:
@@ -523,6 +525,10 @@
                pass
         return registers
 
+    def parse_errors(self, json_data):
+       if 'reportNotes' in json_data:
+          self.crashlog.errors = json_data['reportNotes']
+
 
 class CrashLogParseMode:
     NORMAL = 0
@@ -1062,6 +1068,11 @@
         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,
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] ... Jonas Devlieghere via Phabricator via lldb-commits

Reply via email to