mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

In some cases, it can happen that crashlogs doesn't have any signal in
the exception, which caused the parser to crash.

This fixes the parsing by checking if the `signal` field is in the
`exception` dictionary before trying to access it.

Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119504

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -461,14 +461,17 @@
 
     def parse_crash_reason(self, json_exception):
         exception_type = json_exception['type']
-        exception_signal = json_exception['signal']
+        exception_signal = " "
+        if 'signal' in json_exception:
+            exception_signal += "({})".format(json_exception['signal'])
+
         if 'codes' in json_exception:
             exception_extra = " ({})".format(json_exception['codes'])
         elif 'subtype' in json_exception:
             exception_extra = " ({})".format(json_exception['subtype'])
         else:
             exception_extra = ""
-        return "{} ({}){}".format(exception_type, exception_signal,
+        return "{}{}{}".format(exception_type, exception_signal,
                                   exception_extra)
 
     def parse_images(self, json_images):


Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -461,14 +461,17 @@
 
     def parse_crash_reason(self, json_exception):
         exception_type = json_exception['type']
-        exception_signal = json_exception['signal']
+        exception_signal = " "
+        if 'signal' in json_exception:
+            exception_signal += "({})".format(json_exception['signal'])
+
         if 'codes' in json_exception:
             exception_extra = " ({})".format(json_exception['codes'])
         elif 'subtype' in json_exception:
             exception_extra = " ({})".format(json_exception['subtype'])
         else:
             exception_extra = ""
-        return "{} ({}){}".format(exception_type, exception_signal,
+        return "{}{}{}".format(exception_type, exception_signal,
                                   exception_extra)
 
     def parse_images(self, json_images):
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to