scripts: Fixed incorrect files on recursive results

It's been a while since I've been hurt by Python's late-binding
variables. In this case the scope-creep of the "file" variable hid that
we didn't actually know which recursive result belonged to which file.
Instead we were just assigning whatever the most recent top-level result
was.

This is fixed by looking up the correct file in childrenof. Though this
unfortunately does add quite a bit of noise.
This commit is contained in:
Christopher Haster
2024-12-10 12:23:17 -06:00
parent c8c12ffae8
commit 4325a06277
3 changed files with 38 additions and 14 deletions

View File

@@ -546,12 +546,17 @@ def collect(obj_paths, *,
'DW_TAG_union_type'}:
children = []
for child in entry.children:
# if we have no file guess from obj path
if 'DW_AT_decl_file' in child:
file_ = files.get(int(child['DW_AT_decl_file']), '?')
else:
file_ = re.sub('(\.o)?$', '.c', obj_path, 1)
name_ = child.name
size_ = sizeof(child)
align_ = alignof(child)
children_ = childrenof(child)
children.append(StructResult(
file, name_, size_, align_,
file_, name_, size_, align_,
i=child.off,
children=children_))
# indirect type?