497 lines · plain
1# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o2# RUN: %clang %cflags -gdwarf-5 %tmain.o -o %tmain.exe3# RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections4# RUN: llvm-dwarfdump --debug-names %tmain.exe.bolt > %tlog.txt5# RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s6 7## This test checks that bolt correctly generates entry for DW_TAG_union_type for .debug_name section.8 9# BOLT: Abbreviations [10# BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] {11# BOLT-NEXT: Tag: DW_TAG_subprogram12# BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref413# BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present14# BOLT-NEXT: }15# BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] {16# BOLT-NEXT: Tag: DW_TAG_base_type17# BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref418# BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present19# BOLT-NEXT: }20# BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] {21# BOLT-NEXT: Tag: DW_TAG_union_type22# BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref423# BOLT-NEXT: DW_IDX_parent: DW_FORM_ref424# BOLT-NEXT: }25# BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] {26# BOLT-NEXT: Tag: DW_TAG_structure_type27# BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref428# BOLT-NEXT: DW_IDX_parent: DW_FORM_ref429# BOLT-NEXT: }30# BOLT-NEXT: ]31# BOLT-NEXT: Bucket 0 [32# BOLT-NEXT: EMPTY33# BOLT-NEXT: ]34# BOLT-NEXT: Bucket 1 [35# BOLT-NEXT: Name 1 {36# BOLT-NEXT: Hash: 0x7C9A7F6A37# BOLT-NEXT: String: {{.+}} "main"38# BOLT-NEXT: Entry @ [[ENTRY:0x[0-9a-f]*]] {39# BOLT-NEXT: Abbrev: [[ABBREV1]]40# BOLT-NEXT: Tag: DW_TAG_subprogram41# BOLT-NEXT: DW_IDX_die_offset: 0x0000002442# BOLT-NEXT: DW_IDX_parent: <parent not indexed>43# BOLT-NEXT: }44# BOLT-NEXT: }45# BOLT-NEXT: ]46# BOLT-NEXT: Bucket 2 [47# BOLT-NEXT: EMPTY48# BOLT-NEXT: ]49# BOLT-NEXT: Bucket 3 [50# BOLT-NEXT: Name 2 {51# BOLT-NEXT: Hash: 0xB88803052# BOLT-NEXT: String: {{.+}} "int"53# BOLT-NEXT: Entry @ {{.+}} {54# BOLT-NEXT: Abbrev: [[ABBREV2]]55# BOLT-NEXT: Tag: DW_TAG_base_type56# BOLT-NEXT: DW_IDX_die_offset: 0x0000008357# BOLT-NEXT: DW_IDX_parent: <parent not indexed>58# BOLT-NEXT: }59# BOLT-NEXT: }60# BOLT-NEXT: Name 3 {61# BOLT-NEXT: Hash: 0xED0F01B462# BOLT-NEXT: String: {{.+}} "MyUnion"63# BOLT-NEXT: Entry @ {{.+}} {64# BOLT-NEXT: Abbrev: [[ABBREV3]]65# BOLT-NEXT: Tag: DW_TAG_union_type66# BOLT-NEXT: DW_IDX_die_offset: 0x0000004967# BOLT-NEXT: DW_IDX_parent: Entry @ [[ENTRY]]68# BOLT-NEXT: }69# BOLT-NEXT: }70# BOLT-NEXT: ]71# BOLT-NEXT: Bucket 4 [72# BOLT-NEXT: Name 4 {73# BOLT-NEXT: Hash: 0x8AB681F074# BOLT-NEXT: String: {{.+}} "MyStruct"75# BOLT-NEXT: Entry @ [[ENTRY2:0x[0-9a-f]*]] {76# BOLT-NEXT: Abbrev: [[ABBREV4]]77# BOLT-NEXT: Tag: DW_TAG_structure_type78# BOLT-NEXT: DW_IDX_die_offset: 0x0000006279# BOLT-NEXT: DW_IDX_parent: Entry @ [[ENTRY]]80# BOLT-NEXT: }81# BOLT-NEXT: }82# BOLT-NEXT: Name 5 {83# BOLT-NEXT: Hash: 0x8EEF386684# BOLT-NEXT: String: {{.+}} "MyUnion2"85# BOLT-NEXT: Entry @ {{.+}} {86# BOLT-NEXT: Abbrev: [[ABBREV3]]87# BOLT-NEXT: Tag: DW_TAG_union_type88# BOLT-NEXT: DW_IDX_die_offset: 0x0000007189# BOLT-NEXT: DW_IDX_parent: Entry @ [[ENTRY2]]90 91 92## int main() {93## union MyUnion {94## int a;95## int b;96## };97## struct MyStruct {98## union MyUnion2 {99## int a;100## };101## MyUnion2 myUnion2;102## };103## MyUnion myEnum;104## myEnum.a = 5;105## MyStruct myStruct;106## return myEnum.a + myStruct.myUnion2.a;107## }108 109 .text110 .file "main.cpp"111 .globl main # -- Begin function main112 .p2align 4, 0x90113 .type main,@function114main: # @main115.Lfunc_begin0:116 .file 0 "union" "main.cpp" md5 0xb75b2512f2daa57bbcfe0c29f56d95f4117 .loc 0 1 0 # main.cpp:1:0118 retq119.Lfunc_end0:120 .size main, .-main121 # -- End function122 .section .debug_abbrev,"",@progbits123 .byte 1 # Abbreviation Code124 .byte 17 # DW_TAG_compile_unit125 .byte 1 # DW_CHILDREN_yes126 .byte 37 # DW_AT_producer127 .byte 37 # DW_FORM_strx1128 .byte 19 # DW_AT_language129 .byte 5 # DW_FORM_data2130 .byte 3 # DW_AT_name131 .byte 37 # DW_FORM_strx1132 .byte 114 # DW_AT_str_offsets_base133 .byte 23 # DW_FORM_sec_offset134 .byte 16 # DW_AT_stmt_list135 .byte 23 # DW_FORM_sec_offset136 .byte 27 # DW_AT_comp_dir137 .byte 37 # DW_FORM_strx1138 .byte 17 # DW_AT_low_pc139 .byte 27 # DW_FORM_addrx140 .byte 18 # DW_AT_high_pc141 .byte 6 # DW_FORM_data4142 .byte 115 # DW_AT_addr_base143 .byte 23 # DW_FORM_sec_offset144 .byte 0 # EOM(1)145 .byte 0 # EOM(2)146 .byte 2 # Abbreviation Code147 .byte 46 # DW_TAG_subprogram148 .byte 1 # DW_CHILDREN_yes149 .byte 17 # DW_AT_low_pc150 .byte 27 # DW_FORM_addrx151 .byte 18 # DW_AT_high_pc152 .byte 6 # DW_FORM_data4153 .byte 64 # DW_AT_frame_base154 .byte 24 # DW_FORM_exprloc155 .byte 3 # DW_AT_name156 .byte 37 # DW_FORM_strx1157 .byte 58 # DW_AT_decl_file158 .byte 11 # DW_FORM_data1159 .byte 59 # DW_AT_decl_line160 .byte 11 # DW_FORM_data1161 .byte 73 # DW_AT_type162 .byte 19 # DW_FORM_ref4163 .byte 63 # DW_AT_external164 .byte 25 # DW_FORM_flag_present165 .byte 0 # EOM(1)166 .byte 0 # EOM(2)167 .byte 3 # Abbreviation Code168 .byte 52 # DW_TAG_variable169 .byte 0 # DW_CHILDREN_no170 .byte 2 # DW_AT_location171 .byte 24 # DW_FORM_exprloc172 .byte 3 # DW_AT_name173 .byte 37 # DW_FORM_strx1174 .byte 58 # DW_AT_decl_file175 .byte 11 # DW_FORM_data1176 .byte 59 # DW_AT_decl_line177 .byte 11 # DW_FORM_data1178 .byte 73 # DW_AT_type179 .byte 19 # DW_FORM_ref4180 .byte 0 # EOM(1)181 .byte 0 # EOM(2)182 .byte 4 # Abbreviation Code183 .byte 23 # DW_TAG_union_type184 .byte 1 # DW_CHILDREN_yes185 .byte 54 # DW_AT_calling_convention186 .byte 11 # DW_FORM_data1187 .byte 3 # DW_AT_name188 .byte 37 # DW_FORM_strx1189 .byte 11 # DW_AT_byte_size190 .byte 11 # DW_FORM_data1191 .byte 58 # DW_AT_decl_file192 .byte 11 # DW_FORM_data1193 .byte 59 # DW_AT_decl_line194 .byte 11 # DW_FORM_data1195 .byte 0 # EOM(1)196 .byte 0 # EOM(2)197 .byte 5 # Abbreviation Code198 .byte 13 # DW_TAG_member199 .byte 0 # DW_CHILDREN_no200 .byte 3 # DW_AT_name201 .byte 37 # DW_FORM_strx1202 .byte 73 # DW_AT_type203 .byte 19 # DW_FORM_ref4204 .byte 58 # DW_AT_decl_file205 .byte 11 # DW_FORM_data1206 .byte 59 # DW_AT_decl_line207 .byte 11 # DW_FORM_data1208 .byte 56 # DW_AT_data_member_location209 .byte 11 # DW_FORM_data1210 .byte 0 # EOM(1)211 .byte 0 # EOM(2)212 .byte 6 # Abbreviation Code213 .byte 19 # DW_TAG_structure_type214 .byte 1 # DW_CHILDREN_yes215 .byte 54 # DW_AT_calling_convention216 .byte 11 # DW_FORM_data1217 .byte 3 # DW_AT_name218 .byte 37 # DW_FORM_strx1219 .byte 11 # DW_AT_byte_size220 .byte 11 # DW_FORM_data1221 .byte 58 # DW_AT_decl_file222 .byte 11 # DW_FORM_data1223 .byte 59 # DW_AT_decl_line224 .byte 11 # DW_FORM_data1225 .byte 0 # EOM(1)226 .byte 0 # EOM(2)227 .byte 7 # Abbreviation Code228 .byte 36 # DW_TAG_base_type229 .byte 0 # DW_CHILDREN_no230 .byte 3 # DW_AT_name231 .byte 37 # DW_FORM_strx1232 .byte 62 # DW_AT_encoding233 .byte 11 # DW_FORM_data1234 .byte 11 # DW_AT_byte_size235 .byte 11 # DW_FORM_data1236 .byte 0 # EOM(1)237 .byte 0 # EOM(2)238 .byte 0 # EOM(3)239 .section .debug_info,"",@progbits240.Lcu_begin0:241 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit242.Ldebug_info_start0:243 .short 5 # DWARF version number244 .byte 1 # DWARF Unit Type245 .byte 8 # Address Size (in bytes)246 .long .debug_abbrev # Offset Into Abbrev. Section247 .byte 1 # Abbrev [1] 0xc:0x7b DW_TAG_compile_unit248 .byte 0 # DW_AT_producer249 .short 33 # DW_AT_language250 .byte 1 # DW_AT_name251 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base252 .long .Lline_table_start0 # DW_AT_stmt_list253 .byte 2 # DW_AT_comp_dir254 .byte 0 # DW_AT_low_pc255 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc256 .long .Laddr_table_base0 # DW_AT_addr_base257 .byte 2 # Abbrev [2] 0x23:0x5f DW_TAG_subprogram258 .byte 0 # DW_AT_low_pc259 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc260 .byte 1 # DW_AT_frame_base261 .byte 86262 .byte 3 # DW_AT_name263 .byte 0 # DW_AT_decl_file264 .byte 1 # DW_AT_decl_line265 .long 130 # DW_AT_type266 # DW_AT_external267 .byte 3 # Abbrev [3] 0x32:0xb DW_TAG_variable268 .byte 2 # DW_AT_location269 .byte 145270 .byte 120271 .byte 5 # DW_AT_name272 .byte 0 # DW_AT_decl_file273 .byte 12 # DW_AT_decl_line274 .long 72 # DW_AT_type275 .byte 3 # Abbrev [3] 0x3d:0xb DW_TAG_variable276 .byte 2 # DW_AT_location277 .byte 145278 .byte 116279 .byte 9 # DW_AT_name280 .byte 0 # DW_AT_decl_file281 .byte 14 # DW_AT_decl_line282 .long 97 # DW_AT_type283 .byte 4 # Abbrev [4] 0x48:0x19 DW_TAG_union_type284 .byte 5 # DW_AT_calling_convention285 .byte 8 # DW_AT_name286 .byte 4 # DW_AT_byte_size287 .byte 0 # DW_AT_decl_file288 .byte 2 # DW_AT_decl_line289 .byte 5 # Abbrev [5] 0x4e:0x9 DW_TAG_member290 .byte 6 # DW_AT_name291 .long 130 # DW_AT_type292 .byte 0 # DW_AT_decl_file293 .byte 3 # DW_AT_decl_line294 .byte 0 # DW_AT_data_member_location295 .byte 5 # Abbrev [5] 0x57:0x9 DW_TAG_member296 .byte 7 # DW_AT_name297 .long 130 # DW_AT_type298 .byte 0 # DW_AT_decl_file299 .byte 4 # DW_AT_decl_line300 .byte 0 # DW_AT_data_member_location301 .byte 0 # End Of Children Mark302 .byte 6 # Abbrev [6] 0x61:0x20 DW_TAG_structure_type303 .byte 5 # DW_AT_calling_convention304 .byte 12 # DW_AT_name305 .byte 4 # DW_AT_byte_size306 .byte 0 # DW_AT_decl_file307 .byte 6 # DW_AT_decl_line308 .byte 5 # Abbrev [5] 0x67:0x9 DW_TAG_member309 .byte 10 # DW_AT_name310 .long 112 # DW_AT_type311 .byte 0 # DW_AT_decl_file312 .byte 10 # DW_AT_decl_line313 .byte 0 # DW_AT_data_member_location314 .byte 4 # Abbrev [4] 0x70:0x10 DW_TAG_union_type315 .byte 5 # DW_AT_calling_convention316 .byte 11 # DW_AT_name317 .byte 4 # DW_AT_byte_size318 .byte 0 # DW_AT_decl_file319 .byte 7 # DW_AT_decl_line320 .byte 5 # Abbrev [5] 0x76:0x9 DW_TAG_member321 .byte 6 # DW_AT_name322 .long 130 # DW_AT_type323 .byte 0 # DW_AT_decl_file324 .byte 8 # DW_AT_decl_line325 .byte 0 # DW_AT_data_member_location326 .byte 0 # End Of Children Mark327 .byte 0 # End Of Children Mark328 .byte 0 # End Of Children Mark329 .byte 7 # Abbrev [7] 0x82:0x4 DW_TAG_base_type330 .byte 4 # DW_AT_name331 .byte 5 # DW_AT_encoding332 .byte 4 # DW_AT_byte_size333 .byte 0 # End Of Children Mark334.Ldebug_info_end0:335 .section .debug_str_offsets,"",@progbits336 .long 56 # Length of String Offsets Set337 .short 5338 .short 0339.Lstr_offsets_base0:340 .section .debug_str,"MS",@progbits,1341.Linfo_string0:342 .asciz "clang version 20.0.0git" # string offset=0343.Linfo_string1:344 .asciz "main.cpp" # string offset=24345.Linfo_string2:346 .asciz "union" # string offset=33347.Linfo_string3:348 .asciz "main" # string offset=77349.Linfo_string4:350 .asciz "int" # string offset=82351.Linfo_string5:352 .asciz "myEnum" # string offset=86353.Linfo_string6:354 .asciz "MyUnion" # string offset=93355.Linfo_string7:356 .asciz "a" # string offset=101357.Linfo_string8:358 .asciz "b" # string offset=103359.Linfo_string9:360 .asciz "myStruct" # string offset=105361.Linfo_string10:362 .asciz "MyStruct" # string offset=114363.Linfo_string11:364 .asciz "myUnion2" # string offset=123365.Linfo_string12:366 .asciz "MyUnion2" # string offset=132367 .section .debug_str_offsets,"",@progbits368 .long .Linfo_string0369 .long .Linfo_string1370 .long .Linfo_string2371 .long .Linfo_string3372 .long .Linfo_string4373 .long .Linfo_string5374 .long .Linfo_string7375 .long .Linfo_string8376 .long .Linfo_string6377 .long .Linfo_string9378 .long .Linfo_string11379 .long .Linfo_string12380 .long .Linfo_string10381 .section .debug_addr,"",@progbits382 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution383.Ldebug_addr_start0:384 .short 5 # DWARF version number385 .byte 8 # Address size386 .byte 0 # Segment selector size387.Laddr_table_base0:388 .quad .Lfunc_begin0389.Ldebug_addr_end0:390 .section .debug_names,"",@progbits391 .long .Lnames_end0-.Lnames_start0 # Header: unit length392.Lnames_start0:393 .short 5 # Header: version394 .short 0 # Header: padding395 .long 1 # Header: compilation unit count396 .long 0 # Header: local type unit count397 .long 0 # Header: foreign type unit count398 .long 5 # Header: bucket count399 .long 5 # Header: name count400 .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size401 .long 8 # Header: augmentation string size402 .ascii "LLVM0700" # Header: augmentation string403 .long .Lcu_begin0 # Compilation unit 0404 .long 0 # Bucket 0405 .long 1 # Bucket 1406 .long 0 # Bucket 2407 .long 2 # Bucket 3408 .long 4 # Bucket 4409 .long 2090499946 # Hash in Bucket 1410 .long 193495088 # Hash in Bucket 3411 .long -317783628 # Hash in Bucket 3412 .long -1967750672 # Hash in Bucket 4413 .long -1896925082 # Hash in Bucket 4414 .long .Linfo_string3 # String in Bucket 1: main415 .long .Linfo_string4 # String in Bucket 3: int416 .long .Linfo_string6 # String in Bucket 3: MyUnion417 .long .Linfo_string10 # String in Bucket 4: MyStruct418 .long .Linfo_string12 # String in Bucket 4: MyUnion2419 .long .Lnames0-.Lnames_entries0 # Offset in Bucket 1420 .long .Lnames1-.Lnames_entries0 # Offset in Bucket 3421 .long .Lnames2-.Lnames_entries0 # Offset in Bucket 3422 .long .Lnames3-.Lnames_entries0 # Offset in Bucket 4423 .long .Lnames4-.Lnames_entries0 # Offset in Bucket 4424.Lnames_abbrev_start0:425 .byte 1 # Abbrev code426 .byte 46 # DW_TAG_subprogram427 .byte 3 # DW_IDX_die_offset428 .byte 19 # DW_FORM_ref4429 .byte 4 # DW_IDX_parent430 .byte 25 # DW_FORM_flag_present431 .byte 0 # End of abbrev432 .byte 0 # End of abbrev433 .byte 2 # Abbrev code434 .byte 36 # DW_TAG_base_type435 .byte 3 # DW_IDX_die_offset436 .byte 19 # DW_FORM_ref4437 .byte 4 # DW_IDX_parent438 .byte 25 # DW_FORM_flag_present439 .byte 0 # End of abbrev440 .byte 0 # End of abbrev441 .byte 3 # Abbrev code442 .byte 23 # DW_TAG_union_type443 .byte 3 # DW_IDX_die_offset444 .byte 19 # DW_FORM_ref4445 .byte 4 # DW_IDX_parent446 .byte 19 # DW_FORM_ref4447 .byte 0 # End of abbrev448 .byte 0 # End of abbrev449 .byte 4 # Abbrev code450 .byte 19 # DW_TAG_structure_type451 .byte 3 # DW_IDX_die_offset452 .byte 19 # DW_FORM_ref4453 .byte 4 # DW_IDX_parent454 .byte 19 # DW_FORM_ref4455 .byte 0 # End of abbrev456 .byte 0 # End of abbrev457 .byte 0 # End of abbrev list458.Lnames_abbrev_end0:459.Lnames_entries0:460.Lnames0:461.L3:462 .byte 1 # Abbreviation code463 .long 35 # DW_IDX_die_offset464 .byte 0 # DW_IDX_parent465 # End of list: main466.Lnames1:467.L1:468 .byte 2 # Abbreviation code469 .long 130 # DW_IDX_die_offset470 .byte 0 # DW_IDX_parent471 # End of list: int472.Lnames2:473.L4:474 .byte 3 # Abbreviation code475 .long 72 # DW_IDX_die_offset476 .long .L3-.Lnames_entries0 # DW_IDX_parent477 .byte 0 # End of list: MyUnion478.Lnames3:479.L2:480 .byte 4 # Abbreviation code481 .long 97 # DW_IDX_die_offset482 .long .L3-.Lnames_entries0 # DW_IDX_parent483 .byte 0 # End of list: MyStruct484.Lnames4:485.L0:486 .byte 3 # Abbreviation code487 .long 112 # DW_IDX_die_offset488 .long .L2-.Lnames_entries0 # DW_IDX_parent489 .byte 0 # End of list: MyUnion2490 .p2align 2, 0x0491.Lnames_end0:492 .ident "clang version 20.0.0git"493 .section ".note.GNU-stack","",@progbits494 .addrsig495 .section .debug_line,"",@progbits496.Lline_table_start0:497