forked from Imagelibrary/littlefs
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.
This commit is contained in:
@@ -403,7 +403,7 @@ class DwarfEntry:
|
|||||||
def addr(self):
|
def addr(self):
|
||||||
if (self.tag == 'DW_TAG_subprogram'
|
if (self.tag == 'DW_TAG_subprogram'
|
||||||
and 'DW_AT_low_pc' in self):
|
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:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ class DwarfEntry:
|
|||||||
and 'DW_AT_high_pc' in self):
|
and 'DW_AT_high_pc' in self):
|
||||||
# this looks wrong, but high_pc does store the size,
|
# this looks wrong, but high_pc does store the size,
|
||||||
# for whatever reason
|
# for whatever reason
|
||||||
return int(self['DW_AT_high_pc'], 0)
|
return int(self['DW_AT_high_pc'].split(':')[-1], 16)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -843,7 +843,8 @@ def collect(obj_paths, *,
|
|||||||
# we change this to the last byte in the call
|
# we change this to the last byte in the call
|
||||||
# instruction, which is a bit weird, but should at least
|
# instruction, which is a bit weird, but should at least
|
||||||
# map to the right stack frame
|
# 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)
|
off = int(call['DW_AT_call_origin'].strip('<>'), 0)
|
||||||
|
|
||||||
# callee in locals?
|
# callee in locals?
|
||||||
@@ -852,10 +853,7 @@ def collect(obj_paths, *,
|
|||||||
else:
|
else:
|
||||||
# if not, just keep track of the symbol and try to link
|
# if not, just keep track of the symbol and try to link
|
||||||
# during the global pass
|
# during the global pass
|
||||||
callee = info[off]
|
callee = info[off].name
|
||||||
if callee.name is None:
|
|
||||||
continue
|
|
||||||
callee = callee.name
|
|
||||||
|
|
||||||
caller['calls'].append((addr, callee))
|
caller['calls'].append((addr, callee))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user