[Lldb-commits] [PATCH] D119504: [lldb/crashlog] Fix exception signal parsing

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 10 17:09:00 PST 2022

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.bennani at gmail.com>

  rG LLVM Github Monorepo



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'])
             exception_extra = ""
-        return "{} ({}){}".format(exception_type, exception_signal,
+        return "{}{}{}".format(exception_type, exception_signal,
     def parse_images(self, json_images):

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119504.407726.patch
Type: text/x-patch
Size: 1012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220211/f9e575a7/attachment.bin>

More information about the lldb-commits mailing list