Some unit tests has incorrect DW_AT_type offset since they are manual crafted, fix them to the correct offset.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Some general questions:
Why are tests incorrect? Were they generated by a buggy clang version? How do we know they are correct now?
Thanks for you questions!
The clang version is clang version 15.0.0.
These tests are manual edit at beginning , when I pass them to my IR constructor, I found some reference offset in them are incorrect so IR construction process failed.
For example, debug information in the pre-bolt binary bolt/test/X86/high_pc_udata.s like following,
.debug_info contents: 0x00000000: Compile Unit: length = 0x00000044, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000048) 0x0000000b: DW_TAG_compile_unit [1] * DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000009] = "clang") DW_AT_language [DW_FORM_data2] (DW_LANG_C_plus_plus_14) DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000) DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000000f] = "test") DW_AT_low_pc [DW_FORM_addr] (0x00000000000012f0) DW_AT_high_pc [DW_FORM_udata] (15) DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000000] = "main.cpp") 0x00000027: DW_TAG_subprogram [2] DW_AT_low_pc [DW_FORM_addr] (0x00000000000012f0) DW_AT_high_pc [DW_FORM_data4] (0x0000000f) DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6 RBP) DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000014] = "main") DW_AT_decl_file [DW_FORM_data1] ("test/main.cpp") DW_AT_decl_line [DW_FORM_data1] (1) DW_AT_type [DW_FORM_ref4] (cu + 0x0043 => {0x00000043}) DW_AT_external [DW_FORM_flag_present] (true) 0x00000040: DW_TAG_base_type [3] DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000019] = "int") DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) DW_AT_byte_size [DW_FORM_data1] (0x04) 0x00000047: NULL
DW_AT_type [DW_FORM_ref4] (cu + 0x0043 => {0x00000043}) at Entry 0x00000027 does not refer to any entry. Ideally, it should point to 0x00000040 which is the entry for int
There are same situations happened for other patched tests.
After I patch it, it looks good as following,
.debug_info contents: 0x00000000: Compile Unit: length = 0x00000044, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000048) 0x0000000b: DW_TAG_compile_unit [1] * DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000009] = "clang") DW_AT_language [DW_FORM_data2] (DW_LANG_C_plus_plus_14) DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000) DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000000f] = "test") DW_AT_low_pc [DW_FORM_addr] (0x00000000000012f0) DW_AT_high_pc [DW_FORM_udata] (15) DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000000] = "main.cpp") 0x00000027: DW_TAG_subprogram [2] DW_AT_low_pc [DW_FORM_addr] (0x00000000000012f0) DW_AT_high_pc [DW_FORM_data4] (0x0000000f) DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6 RBP) DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000014] = "main") DW_AT_decl_file [DW_FORM_data1] ("test/main.cpp") DW_AT_decl_line [DW_FORM_data1] (1) DW_AT_type [DW_FORM_ref4] (cu + 0x0040 => {0x00000040} "int") DW_AT_external [DW_FORM_flag_present] (true) 0x00000040: DW_TAG_base_type [3] DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000019] = "int") DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) DW_AT_byte_size [DW_FORM_data1] (0x04) 0x00000047: NULL
The patched tests can pass both current test and my IR constructor (the IR constructor have check for reference destination, if invalid, it will failed), so I consider they are correct now.