[Lldb-commits] [lldb] 9defb3b - [lldb] Prevent underflow in crashlog.py

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon May 16 15:00:47 PDT 2022


Author: Jonas Devlieghere
Date: 2022-05-16T15:00:36-07:00
New Revision: 9defb3b4b4a3ab5a95c449471aaa930cf63a7106

URL: https://github.com/llvm/llvm-project/commit/9defb3b4b4a3ab5a95c449471aaa930cf63a7106
DIFF: https://github.com/llvm/llvm-project/commit/9defb3b4b4a3ab5a95c449471aaa930cf63a7106.diff

LOG: [lldb] Prevent underflow in crashlog.py

Avoid a OverflowError (an underflow really) when the pc is zero. This
can happen for "unknown frames" where the crashlog generator reports a
zero pc. We could omit them altogether, but if they're part of the
crashlog it seems fair to display them in lldb as well.

rdar://92686666

Differential revision: https://reviews.llvm.org/D125716

Added: 
    

Modified: 
    lldb/examples/python/crashlog.py

Removed: 
    


################################################################################
diff  --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 49c9a92497eb1..a20798ab11940 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -114,14 +114,12 @@ def dump_symbolicated(self, crash_log, options):
             for frame_idx, frame in enumerate(self.frames):
                 disassemble = (
                     this_thread_crashed or options.disassemble_all_threads) and frame_idx < options.disassemble_depth
-                if frame_idx == 0:
-                    symbolicated_frame_addresses = crash_log.symbolicate(
-                        frame.pc & crash_log.addr_mask, options.verbose)
-                else:
-                    # Any frame above frame zero and we have to subtract one to
-                    # get the previous line entry
-                    symbolicated_frame_addresses = crash_log.symbolicate(
-                        (frame.pc & crash_log.addr_mask) - 1, options.verbose)
+
+                # Any frame above frame zero and we have to subtract one to
+                # get the previous line entry.
+                pc = frame.pc & crash_log.addr_mask
+                pc = pc if frame_idx == 0 or pc == 0 else pc - 1
+                symbolicated_frame_addresses = crash_log.symbolicate(pc, options.verbose)
 
                 if symbolicated_frame_addresses:
                     symbolicated_frame_address_idx = 0


        


More information about the lldb-commits mailing list