[llvm] Reapply "[llvm/DWARF] Recursively resolve DW_AT_signature references"… (PR #99495)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 10:43:59 PDT 2024
================
@@ -173,7 +169,8 @@ DWARFTypePrinter::appendUnqualifiedNameBefore(DWARFDie D,
case DW_TAG_base_type:
*/
default: {
- const char *NamePtr = dwarf::toString(D.find(DW_AT_name), nullptr);
+ const char *NamePtr =
+ dwarf::toString(D.findRecursively(DW_AT_name), nullptr);
----------------
dwblaikie wrote:
Aside: GCC doesn't use this style for all type unit references, it actually uses 3 different styles depending on context
https://godbolt.org/z/Pozc4TYM1
t1, type unit referenced once `DW_AT_type [DW_FORM_ref_sig8] (0xf8473fd3bfd1e564)`
t2, type unit referenced twice (save space by sharing the sig8): `DW_AT_type [DW_FORM_ref4] (cu + 0x00cc => {0x000000cc} "t2")`
```
0x000000cc: DW_TAG_structure_type [14] (0x0000000c)
DW_AT_signature [DW_FORM_ref_sig8] (0x3fea40f8df132361)
```
t3: referenced a declaration of a member function:
```
0x000000b3: DW_TAG_subprogram [13] (0x0000000c)
DW_AT_specification [DW_FORM_ref4] (cu + 0x0049 => {0x00000049} "_ZN2ns2t33memEv")
DW_AT_decl_line [DW_FORM_data1] (9)
DW_AT_decl_column [DW_FORM_data1] (6)
DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000 ".text")
DW_AT_high_pc [DW_FORM_data8] (0x0000000000000007)
DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_call_frame_cfa)
DW_AT_call_all_calls [DW_FORM_flag_present] (true)
```
```
0x0000002e: DW_TAG_namespace [10] * (0x0000000c)
DW_AT_name [DW_FORM_string] ("ns")
DW_AT_decl_file [DW_FORM_data1] ("/app/example.cpp")
DW_AT_decl_line [DW_FORM_data1] (1)
DW_AT_decl_column [DW_FORM_data1] (11)
DW_AT_sibling [DW_FORM_ref4] (cu + 0x0086 => {0x00000086})
0x00000039: DW_TAG_structure_type [11] * (0x0000002e)
DW_AT_name [DW_FORM_string] ("t3")
DW_AT_declaration [DW_FORM_flag_present] (true)
DW_AT_signature [DW_FORM_ref_sig8] (0x55d7e46295b56ec8)
DW_AT_sibling [DW_FORM_ref4] (cu + 0x0056 => {0x00000056})
0x00000049: DW_TAG_subprogram [5] (0x00000039)
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_name [DW_FORM_string] ("mem")
DW_AT_decl_file [DW_FORM_data1] ("/app/example.cpp")
DW_AT_decl_line [DW_FORM_data1] (4)
DW_AT_decl_column [DW_FORM_data1] (25)
DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000091] = "_ZN2ns2t33memEv")
DW_AT_declaration [DW_FORM_flag_present] (true)
```
In any case...
It seems to me that perhaps we could/should introduce a `getAttributeValueAsReferencedDieRecursively`? That recurses the referenced type, but doesn't recurse the attribute (since this is called on an already found attribute - with find or findRecursively)?
> getAttributeValueAsReferencedDie will only resolve the first reference, and not the second one. Unless we want to teach it to resolve references recursively (which sounds like a bad idea)
Hmm, you mentioned that this sounds like a bad idea, but then mention that we should do it a few lines later? Not sure which you're thinking of, or why it might be a bad idea? (I mean, it might be, not suggesting it isn't, but trying to understand better)
Or perhaps you were presenting these as alternatives...
https://github.com/llvm/llvm-project/pull/99495
More information about the llvm-commits
mailing list