Author: Jason Molenda Date: 2022-05-05T17:55:22-07:00 New Revision: 2be791e32af33b7ef735bb180a8a91ee501d0560
URL: https://github.com/llvm/llvm-project/commit/2be791e32af33b7ef735bb180a8a91ee501d0560 DIFF: https://github.com/llvm/llvm-project/commit/2be791e32af33b7ef735bb180a8a91ee501d0560.diff LOG: Insert crashing stack frame when call to null func ptr On arm64 targets, when the crashing pc is 0, the caller frame can be found by looking at $lr, but the crash reports don't use that trick to show the actual crashing frame. This patch adds that stack frame that lldb shows. Also fix an issue where some register names were printed as having a prefix of 'None'. Differential Revision: https://reviews.llvm.org/D125042 rdar://92631787 Added: Modified: lldb/examples/python/crashlog.py Removed: ################################################################################ diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index e0bd52d8711ef..bc34bf75f8b19 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -516,6 +516,23 @@ def parse_frames(self, thread, json_frames): image_addr = self.get_used_image(image_id)['base'] pc = image_addr + frame_offset thread.frames.append(self.crashlog.Frame(idx, pc, frame_offset)) + + # on arm64 systems, if it jump through a null function pointer, + # we end up at address 0 and the crash reporter unwinder + # misses the frame that actually faulted. + # But $lr can tell us where the last BL/BLR instruction used + # was at, so insert that address as the caller stack frame. + if idx == 0 and pc == 0 and "lr" in thread.registers: + pc = thread.registers["lr"] + for image in self.data['usedImages']: + text_lo = image['base'] + text_hi = text_lo + image['size'] + if text_lo <= pc < text_hi: + idx += 1 + frame_offset = pc - text_lo + thread.frames.append(self.crashlog.Frame(idx, pc, frame_offset)) + break + idx += 1 def parse_threads(self, json_threads): @@ -551,7 +568,7 @@ def parse_thread_registers(self, json_thread_state, prefix=None): continue try: value = int(state['value']) - registers["{}{}".format(prefix,key)] = value + registers["{}{}".format(prefix or '',key)] = value except (KeyError, ValueError, TypeError): pass return registers _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits