3939
4040
4141def scoped_tags (tag : str ) -> bool :
42+ """Return True if the DIE is a C++ scope component"""
4243 return tag in {
4344 "DW_TAG_structure_type" ,
4445 "DW_TAG_class_type" ,
@@ -50,23 +51,33 @@ def scoped_tags(tag: str) -> bool:
5051
5152
5253@functools .cache
53- def get_qualified_type (die : DWARFDie , split = False ) -> str | tuple [str , str ]:
54+ def get_qualified_type (die : DWARFDie , relative : DWARFDie | None = None , split = False ) -> str | tuple [str , str ]:
5455 printer = DWARFTypePrinter ()
5556 if scoped_tags (die .tag ):
5657 printer .append_scopes (die .parent )
5758
58- if not split :
59- printer . append_unqualified_name ( die )
60- return str ( printer ). strip ()
59+ def relative_scope ( ty : str , relative : DWARFDie | None = None ) -> str :
60+ if not relative or relative . tag in { "DW_TAG_compile_unit" , "DW_TAG_type_unit" , "DW_TAG_skeleton_unit" }:
61+ return ty
6162
62- inner = printer .append_unqualified_name_before (die )
63- before = str (printer ).strip ()
63+ output = ty .replace (get_qualified_type (relative ) + "::" , "" )
64+ if output != ty :
65+ return output
6466
65- printer = DWARFTypePrinter ()
66- printer .append_unqualified_name_after (die , inner )
67- after = str (printer ).strip ()
67+ return relative_scope (ty , relative .parent )
6868
69- return before , after
69+ if not split :
70+ printer .append_unqualified_name (die )
71+ ty = str (printer ).strip ()
72+ return relative_scope (ty , relative )
73+ else :
74+ inner = printer .append_unqualified_name_before (die )
75+ before = str (printer ).strip ()
76+
77+ printer = DWARFTypePrinter ()
78+ printer .append_unqualified_name_after (die , inner )
79+ after = str (printer ).strip ()
80+ return relative_scope (before , relative ), after
7081
7182
7283def float_to_str (value : float ) -> str :
0 commit comments