This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Don't swallow crashlog exceptions
ClosedPublic

Authored by JDevlieghere on May 13 2022, 3:47 PM.

Details

Summary

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.

Diff Detail

Event Timeline

JDevlieghere created this revision.May 13 2022, 3:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 3:47 PM
JDevlieghere requested review of this revision.May 13 2022, 3:47 PM
mib added inline comments.May 13 2022, 3:50 PM
lldb/examples/python/crashlog.py
1025–1027

What about printing the exception backtrace and exiting cleaning instead of crashing ?

JDevlieghere marked an inline comment as done.May 13 2022, 3:52 PM
JDevlieghere added inline comments.
lldb/examples/python/crashlog.py
1025–1027

What's the advantage?

  • LLBB's embedded python interpreter is going to catch the exception and put the crash info in the command result object.
  • When running directly under Python, the default exception handler is going to print the backtrace as well.
mib accepted this revision.May 13 2022, 3:56 PM
mib added inline comments.
lldb/examples/python/crashlog.py
1025–1027

Alright, LGTM then

This revision is now accepted and ready to land.May 13 2022, 3:56 PM
This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2022, 8:59 AM