[llvm] [DebugInfo] Support to get TU for hash from .debug_types.dwo section in DWARF4. (PR #161067)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 1 17:13:24 PDT 2025
dwblaikie wrote:
Can you add a test case?
My rudimentary testing seems to show this working correctly already - but perhaps by accident or something?
```
struct t1 { };
void f1(t1) {
}
```
```
clang++-tot -fdebug-types-section -c test.cpp -gdwarf-4 -gsplit-dwarf && llvm-dwarfdump-tot test.dwo -debug-info -debug-types
```
```
test.dwo: file format elf64-x86-64
.debug_info.dwo contents:
0x00000000: Compile Unit: length = 0x00000036, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000003a)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("clang version 21.1.1 (git at github.com:llvm/llvm-project.git f4907049285ca0875cc91770e3ceb3f162ec7c48)")
DW_AT_language (DW_LANG_C_plus_plus_14)
DW_AT_name ("test.cpp")
DW_AT_GNU_dwo_name ("test.dwo")
DW_AT_GNU_dwo_id (0x9a627b6109b8affc)
0x00000019: DW_TAG_subprogram
DW_AT_low_pc (indexed (00000000) address = <unresolved>)
DW_AT_high_pc (0x00000006)
DW_AT_frame_base (DW_OP_reg6 RBP)
DW_AT_linkage_name ("_Z2f12t1")
DW_AT_name ("f1")
DW_AT_decl_file (0x01)
DW_AT_decl_line (2)
DW_AT_external (true)
0x00000025: DW_TAG_formal_parameter
DW_AT_location (DW_OP_fbreg -1)
DW_AT_decl_file (0x01)
DW_AT_decl_line (2)
DW_AT_type (0x00000030 "t1")
0x0000002f: NULL
0x00000030: DW_TAG_structure_type
DW_AT_declaration (true)
DW_AT_signature (0xc6694e51369161f2)
0x00000039: NULL
.debug_types.dwo contents:
0x00000000: Type Unit: length = 0x00000021, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08, name = 't1', type_signature = 0xc6694e51369161f2, type_offset = 0x001e (next unit at 0x00000025)
0x00000017: DW_TAG_type_unit
DW_AT_language (DW_LANG_C_plus_plus_14)
DW_AT_stmt_list (0x00000000)
0x0000001e: DW_TAG_structure_type
DW_AT_calling_convention (DW_CC_pass_by_value)
DW_AT_name ("t1")
DW_AT_byte_size (0x01)
DW_AT_decl_file ("test.cpp")
DW_AT_decl_line (1)
0x00000024: NULL
```
Specifically, when dumping the CU it shows the name of the type at offset 0x30, which indicates that it's successfully looking through the `DW_TAG_structure_type` and using the `DW_AT_signature` to find the DWARFv4 type unit in `.debug_types.dwo` to retrieve the name...
https://github.com/llvm/llvm-project/pull/161067
More information about the llvm-commits
mailing list