From 14e7501e5cc6e7c3553f67d79d37e43397069a5c Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 7 Dec 2024 01:01:04 -0600 Subject: [PATCH] scripts: Minor stack.py fixes - Always interpret DW_AT_low_pc/high_pc/call_return_pc as hex. Clang populates these with hex digits without a 0x prefix. - Don't ignore callees with no name. Now that DW_AT_abstract_origin is fixed, a callee with no name should be an error. --- scripts/stack.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/stack.py b/scripts/stack.py index 69e06047..7b5454ae 100755 --- a/scripts/stack.py +++ b/scripts/stack.py @@ -403,7 +403,7 @@ class DwarfEntry: def addr(self): if (self.tag == 'DW_TAG_subprogram' and 'DW_AT_low_pc' in self): - return int(self['DW_AT_low_pc'], 0) + return int(self['DW_AT_low_pc'].split(':')[-1], 16) else: return None @@ -413,7 +413,7 @@ class DwarfEntry: and 'DW_AT_high_pc' in self): # this looks wrong, but high_pc does store the size, # for whatever reason - return int(self['DW_AT_high_pc'], 0) + return int(self['DW_AT_high_pc'].split(':')[-1], 16) else: return None @@ -843,7 +843,8 @@ def collect(obj_paths, *, # we change this to the last byte in the call # instruction, which is a bit weird, but should at least # map to the right stack frame - addr = int(call['DW_AT_call_return_pc'], 0) - 1 + addr = (int(call['DW_AT_call_return_pc'].split(':')[-1], 16) + - 1) off = int(call['DW_AT_call_origin'].strip('<>'), 0) # callee in locals? @@ -852,10 +853,7 @@ def collect(obj_paths, *, else: # if not, just keep track of the symbol and try to link # during the global pass - callee = info[off] - if callee.name is None: - continue - callee = callee.name + callee = info[off].name caller['calls'].append((addr, callee))