tools/parsetrace.py: Fix get_typesize bug in parsetrace.py
Build Documentation / build-html (push) Has been cancelled

For the following code, we need to check 'type_attr.form'.
type_attr = DIE.attributes["DW_AT_type"]
base_type_die = dwarfinfo.get_DIE_from_refaddr(xxx)

When type_attr.form==DW_FORM_ref_addr, 'type_attr.value' means
global reference (across compilation units).

When type_attr.form==DW_FORM_ref4, 'type_attr.value' means
local reference (within the same compilation unit).

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
This commit is contained in:
yukangzhi
2025-06-03 17:23:05 +08:00
committed by CeDeROM
parent fa2d2b8898
commit 9bda244be8
3 changed files with 93 additions and 3 deletions
+8 -3
View File
@@ -133,9 +133,14 @@ class SymbolTables(object):
if name == type_name:
if "DW_AT_type" in DIE.attributes:
type_attr = DIE.attributes["DW_AT_type"]
base_type_die = dwarfinfo.get_DIE_from_refaddr(
type_attr.value + CU.cu_offset
)
if type_attr.form == "DW_FORM_ref_addr":
base_type_die = dwarfinfo.get_DIE_from_refaddr(
type_attr.value
)
else:
base_type_die = dwarfinfo.get_DIE_from_refaddr(
type_attr.value + CU.cu_offset
)
if base_type_die.tag == "DW_TAG_base_type":
size = base_type_die.attributes["DW_AT_byte_size"].value
elif base_type_die.tag == "DW_TAG_typedef":