forked from Imagelibrary/littlefs
scripts: Resolve DW_AT_abstract_origin during dwarf collection
Sometimes I feel like dwarf-info is designed to be as error-prone as possible. In this case, DW_AT_abstract_origin indicates that one dwarf entry should inherit the attributes of another. If you don't know this, it's easy to miss relevant dwarf entries due to missing name fields, etc. Expanding DW_AT_abstract_origin lazily would be tricky due to how our DwarfInfo class is structured, so instead I am just expanding DW_AT_abstract_origins during collect_dwarf_info. Note this doesn't handle recursive DW_AT_abstract_origins, but there is at least an assert. --- It does seem like DW_AT_abstract_origin is intended to be limited to "Inline instances of inline subprograms" and "Out-of-line instances of inline subprograms" according to the DWARF5 spec, but it's unclear if this is a rule or suggestion... This hasn't been an issue for existing scripts, but is needed from some ongoing stack.py rework. Otherwise we don't find "out-of-line instances of inline subprograms" (optimized functions?) correctly.
This commit is contained in:
@@ -507,6 +507,18 @@ def collect_dwarf_info(obj_path, tags=None, *,
|
||||
if proc.returncode != 0:
|
||||
raise sp.CalledProcessError(proc.returncode, proc.args)
|
||||
|
||||
# resolve abstract origins
|
||||
for entry in info.values():
|
||||
if 'DW_AT_abstract_origin' in entry:
|
||||
off = int(entry['DW_AT_abstract_origin'].strip('<>'), 0)
|
||||
origin = info[off]
|
||||
assert 'DW_AT_abstract_origin' not in origin, (
|
||||
"Recursive abstract origin?")
|
||||
|
||||
for k, v in origin.ats.items():
|
||||
if k not in entry.ats:
|
||||
entry.ats[k] = v
|
||||
|
||||
return DwarfInfo(info)
|
||||
|
||||
def collect(obj_paths, *,
|
||||
|
||||
Reference in New Issue
Block a user