[Lldb-commits] [PATCH] D125589: [lldb] Don't swallow crashlog exceptions

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri May 13 15:47:27 PDT 2022


JDevlieghere created this revision.
JDevlieghere added a reviewer: mib.
Herald added a project: All.
JDevlieghere requested review of this revision.

crashlog.py catches every exception in order to format them. This results in both the exception name as well as the backtrace getting swallowed.

Here's an example of the current output:

  error: python exception: in method 'SBTarget_ResolveLoadAddress', argument 2 of type 'lldb::addr_t'

Compare this to the output without the custom exception handling:

  Traceback (most recent call last):
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/macosx/crashlog.py", line 929, in __call__
      SymbolicateCrashLogs(debugger, shlex.split(command))
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/macosx/crashlog.py", line 1239, in SymbolicateCrashLogs
      SymbolicateCrashLog(crash_log, options)
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/macosx/crashlog.py", line 1006, in SymbolicateCrashLog
      thread.dump_symbolicated(crash_log, options)
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/macosx/crashlog.py", line 124, in dump_symbolicated
      symbolicated_frame_addresses = crash_log.symbolicate(
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/utils/symbolication.py", line 540, in symbolicate
      if symbolicated_address.symbolicate(verbose):
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/utils/symbolication.py", line 98, in symbolicate
      sym_ctx = self.get_symbol_context()
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/utils/symbolication.py", line 77, in get_symbol_context
      sb_addr = self.resolve_addr()
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/utils/symbolication.py", line 69, in resolve_addr
      self.so_addr = self.target.ResolveLoadAddress(self.load_addr)
    File "/Users/jonas/llvm/build-ra/lib/python3.9/site-packages/lldb/__init__.py", line 10675, in ResolveLoadAddress
      return _lldb.SBTarget_ResolveLoadAddress(self, vm_addr)
  OverflowError: in method 'SBTarget_ResolveLoadAddress', argument 2 of type 'lldb::addr_t'

This patch removes the custom exception handling and lets LLDB deal with it instead.


https://reviews.llvm.org/D125589

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -925,10 +925,7 @@
         pass
 
     def __call__(self, debugger, command, exe_ctx, result):
-        try:
-            SymbolicateCrashLogs(debugger, shlex.split(command))
-        except Exception as e:
-            result.PutCString("error: python exception: %s" % e)
+        SymbolicateCrashLogs(debugger, shlex.split(command))
 
     def get_short_help(self):
         return "Symbolicate one or more darwin crash log files."
@@ -1020,11 +1017,7 @@
     if not os.path.exists(crashlog_path):
         result.PutCString("error: crashlog file %s does not exist" % crashlog_path)
 
-    try:
-        crashlog = CrashLogParser().parse(debugger, crashlog_path, False)
-    except Exception as e:
-        result.PutCString("error: python exception: %s" % e)
-        return
+    crashlog = CrashLogParser().parse(debugger, crashlog_path, False)
 
     if debugger.GetNumTargets() > 0:
         target = debugger.GetTargetAtIndex(0)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125589.429373.patch
Type: text/x-patch
Size: 1121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220513/53f8126b/attachment.bin>


More information about the lldb-commits mailing list