439 lines · plain
1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o2# RUN: llvm-dwarfdump -v %t.o 2> %t.err | FileCheck --check-prefixes=COMMON,SPLIT,OFFSETS %s3 4# FIXME: the verifier does not accept padding between debug-str-offset5# sections, which this test uses.6# RUN: llvm-dwarfdump -verify --debug-info %t.o | FileCheck --check-prefix=VERIFY %s7# RUN: llvm-dwarfdump -debug-str-offsets %t.o | FileCheck --check-prefix=OFFSETS %s8# 9# Check that we don't report an error on a non-existent range list table.10# RUN: FileCheck -allow-empty --check-prefix ERR %s < %t.err11 12# Test object to verify dwarfdump handles v5 string offset tables.13# We have 2 v5 CUs, a v5 TU, and a split v5 CU and TU.14#15 16 .section .debug_str,"MS",@progbits,117str_producer:18 .asciz "Handmade DWARF producer"19str_CU1:20 .asciz "Compile_Unit_1"21str_CU1_dir:22 .asciz "/home/test/CU1"23str_CU2:24 .asciz "Compile_Unit_2"25str_CU2_dir:26 .asciz "/home/test/CU2"27str_TU:28 .asciz "Type_Unit"29str_TU_type:30 .asciz "MyStruct"31str_Subprogram:32 .asciz "MyFunc"33str_Variable1:34 .asciz "MyVar1"35str_Variable2:36 .asciz "MyVar2"37str_Variable3:38 .asciz "MyVar3"39 40# Every unit contributes to the string_offsets table.41 .section .debug_str_offsets,"",@progbits42# CU1's contribution43 .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+444 .short 5 # DWARF version45 .short 0 # Padding46.debug_str_offsets_base0:47 .long str_producer48 .long str_CU149 .long str_CU1_dir50 .long str_Subprogram51 .long str_Variable152 .long str_Variable253 .long str_Variable354.debug_str_offsets_segment0_end:55# A 4-byte gap.56 .long 057# CU2's contribution in DWARF64 format58 .long 0xffffffff59 .quad .debug_str_offsets_segment1_end-.debug_str_offsets_base1+460 .short 5 # DWARF version61 .short 0 # Padding62.debug_str_offsets_base1:63 .quad str_producer64 .quad str_CU265 .quad str_CU2_dir66.debug_str_offsets_segment1_end:67# The TU's contribution68 .long .debug_str_offsets_segment2_end-.debug_str_offsets_base2+469 .short 5 # DWARF version70 .short 0 # Padding71.debug_str_offsets_base2:72 .long str_TU73 .long str_TU_type74.debug_str_offsets_segment2_end:75 76 .section .debug_str.dwo,"MSe",@progbits,177dwo_str_CU_5_producer:78 .asciz "Handmade split DWARF producer"79dwo_str_CU_5_name:80 .asciz "V5_split_compile_unit"81dwo_str_CU_5_comp_dir:82 .asciz "/home/test/splitCU"83dwo_str_TU_5:84 .asciz "V5_split_type_unit"85dwo_str_TU_5_type:86 .asciz "V5_split_Mystruct"87 88 .section .debug_str_offsets.dwo,"e",@progbits89# One contribution only in a .dwo file90 .long .debug_dwo_str_offsets_segment0_end-.debug_dwo_str_offsets_base0+491 .short 5 # DWARF version92 .short 0 # Padding93.debug_dwo_str_offsets_base0:94 .long dwo_str_CU_5_producer-.debug_str.dwo95 .long dwo_str_CU_5_name-.debug_str.dwo96 .long dwo_str_CU_5_comp_dir-.debug_str.dwo97 .long dwo_str_TU_5-.debug_str.dwo98 .long dwo_str_TU_5_type-.debug_str.dwo99.debug_dwo_str_offsets_segment0_end:100 101# All CUs/TUs use the same abbrev section for simplicity.102 .section .debug_abbrev,"",@progbits103 .byte 0x01 # Abbrev code104 .byte 0x11 # DW_TAG_compile_unit105 .byte 0x01 # DW_CHILDREN_yes106 .byte 0x25 # DW_AT_producer107 .byte 0x1a # DW_FORM_strx108 .byte 0x03 # DW_AT_name109 .byte 0x1a # DW_FORM_strx110 .byte 0x72 # DW_AT_str_offsets_base111 .byte 0x17 # DW_FORM_sec_offset112 .byte 0x1b # DW_AT_comp_dir113 .byte 0x1a # DW_FORM_strx114 .byte 0x00 # EOM(1)115 .byte 0x00 # EOM(2)116 .byte 0x02 # Abbrev code117 .byte 0x41 # DW_TAG_type_unit118 .byte 0x01 # DW_CHILDREN_yes119 .byte 0x03 # DW_AT_name120 .byte 0x1a # DW_FORM_strx121 .byte 0x72 # DW_AT_str_offsets_base122 .byte 0x17 # DW_FORM_sec_offset123 .byte 0x00 # EOM(1)124 .byte 0x00 # EOM(2)125 .byte 0x03 # Abbrev code126 .byte 0x13 # DW_TAG_structure_type127 .byte 0x00 # DW_CHILDREN_no (no members)128 .byte 0x03 # DW_AT_name129 .byte 0x1a # DW_FORM_strx130 .byte 0x00 # EOM(1)131 .byte 0x00 # EOM(2)132 .byte 0x04 # Abbrev code133 .byte 0x2e # DW_TAG_subprogram134 .byte 0x01 # DW_CHILDREN_yes135 .byte 0x03 # DW_AT_name136 .byte 0x25 # DW_FORM_strx1137 .byte 0x00 # EOM(1)138 .byte 0x00 # EOM(2)139 .byte 0x05 # Abbrev code140 .byte 0x34 # DW_TAG_variable141 .byte 0x00 # DW_CHILDREN_no142 .byte 0x03 # DW_AT_name143 .byte 0x26 # DW_FORM_strx2144 .byte 0x49 # DW_AT_type145 .byte 0x13 # DW_FORM_ref4146 .byte 0x00 # EOM(1)147 .byte 0x00 # EOM(2)148 .byte 0x06 # Abbrev code149 .byte 0x34 # DW_TAG_variable150 .byte 0x00 # DW_CHILDREN_no151 .byte 0x03 # DW_AT_name152 .byte 0x27 # DW_FORM_strx3153 .byte 0x49 # DW_AT_type154 .byte 0x13 # DW_FORM_ref4155 .byte 0x00 # EOM(1)156 .byte 0x00 # EOM(2)157 .byte 0x07 # Abbrev code158 .byte 0x34 # DW_TAG_variable159 .byte 0x00 # DW_CHILDREN_no160 .byte 0x03 # DW_AT_name161 .byte 0x28 # DW_FORM_strx4162 .byte 0x49 # DW_AT_type163 .byte 0x13 # DW_FORM_ref4164 .byte 0x00 # EOM(1)165 .byte 0x00 # EOM(2)166 .byte 0x08 # Abbrev code167 .byte 0x24 # DW_TAG_base_type168 .byte 0x00 # DW_CHILDREN_no169 .byte 0x3e # DW_AT_encoding170 .byte 0x0b # DW_FORM_data1171 .byte 0x00 # EOM(1)172 .byte 0x00 # EOM(2)173 .byte 0x09 # Abbrev code174 .byte 0x11 # DW_TAG_compile_unit175 .byte 0x00 # DW_CHILDREN_no176 .byte 0x00 # EOM(1)177 .byte 0x00 # EOM(2)178 .byte 0x00 # EOM(3)179 180# And a .dwo copy of a subset for the .dwo sections.181 .section .debug_abbrev.dwo,"e",@progbits182 .byte 0x01 # Abbrev code183 .byte 0x11 # DW_TAG_compile_unit184 .byte 0x00 # DW_CHILDREN_no185 .byte 0x25 # DW_AT_producer186 .byte 0x1a # DW_FORM_strx187 .byte 0x03 # DW_AT_name188 .byte 0x1a # DW_FORM_strx189 .byte 0x1b # DW_AT_comp_dir190 .byte 0x1a # DW_FORM_strx191 .byte 0x00 # EOM(1)192 .byte 0x00 # EOM(2)193 .byte 0x02 # Abbrev code194 .byte 0x41 # DW_TAG_type_unit195 .byte 0x01 # DW_CHILDREN_yes196 .byte 0x03 # DW_AT_name197 .byte 0x1a # DW_FORM_strx198 .byte 0x00 # EOM(1)199 .byte 0x00 # EOM(2)200 .byte 0x03 # Abbrev code201 .byte 0x13 # DW_TAG_structure_type202 .byte 0x00 # DW_CHILDREN_no (no members)203 .byte 0x03 # DW_AT_name204 .byte 0x1a # DW_FORM_strx205 .byte 0x00 # EOM(1)206 .byte 0x00 # EOM(2)207 .byte 0x00 # EOM(3)208 209 .section .debug_info,"",@progbits210 211# DWARF v5 CU header.212 .long CU1_5_end-CU1_5_version # Length of Unit213CU1_5_version:214 .short 5 # DWARF version number215 .byte 1 # DWARF Unit Type216 .byte 8 # Address Size (in bytes)217 .long .debug_abbrev # Offset Into Abbrev. Section218# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name, 219# DW_AT_str_offsets and DW_AT_compdir.220 .byte 1 # Abbreviation code221 .byte 0 # The index of the producer string222 .byte 1 # The index of the CU name string223 .long .debug_str_offsets_base0224 .byte 2 # The index of the comp dir string225# A subprogram DIE with DW_AT_name, using DW_FORM_strx1.226 .byte 4 # Abbreviation code227 .byte 3 # Subprogram name string (DW_FORM_strx1)228# A variable DIE with DW_AT_name, using DW_FORM_strx2, and DW_AT_type.229 .byte 5 # Abbreviation code230 .short 0x0004 # Subprogram name string (DW_FORM_strx2)231 .long TypeDie-.debug_info232# A variable DIE with DW_AT_name, using DW_FORM_strx3, and DW_AT_type.233 .byte 6 # Abbreviation code234 .byte 5 # Subprogram name string (DW_FORM_strx3)235 .short 0 # Subprogram name string (DW_FORM_strx3)236 .long TypeDie-.debug_info237# A variable DIE with DW_AT_name, using DW_FORM_strx4, and DW_AT_type.238 .byte 7 # Abbreviation code239 .long 6 # Subprogram name string (DW_FORM_strx4)240 .long TypeDie-.debug_info241 .byte 0 # NULL242# A base type DIE with DW_AT_encoding.243TypeDie:244 .byte 8 # Abbreviation code245 .byte 5 # DW_ATE_signed246 .byte 0 # NULL247 .byte 0 # NULL248CU1_5_end:249 250# DWARF v5 CU header251 .long 0xffffffff252 .quad CU2_5_end-CU2_5_version # Length of Unit253CU2_5_version:254 .short 5 # DWARF version number255 .byte 1 # DWARF Unit Type256 .byte 8 # Address Size (in bytes)257 .quad .debug_abbrev # Offset Into Abbrev. Section258# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name, 259# DW_AT_str_offsets and DW_AT_compdir.260 .byte 1 # Abbreviation code261 .byte 0 # The index of the producer string262 .byte 1 # The index of the CU name string263 .quad .debug_str_offsets_base1264 .byte 2 # The index of the comp dir string265 .byte 0 # NULL266CU2_5_end:267# DWARF v5 CU without str_offsets_base - this shouldn't produce an error/nor268# prevent other str_offsets contributions from being dumped.269 .long CU3_5_end-CU3_5_version # Length of Unit270CU3_5_version:271 .short 5 # DWARF version number272 .byte 1 # DWARF Unit Type273 .byte 8 # Address Size (in bytes)274 .long .debug_abbrev # Offset Into Abbrev. Section275# The compile-unit DIE with no attributes.276 .byte 9 # Abbreviation code277CU3_5_end:278 279 280 281 282 283 284 .section .debug_types,"",@progbits285# DWARF v5 Type unit header.286TU_5_start:287 .long TU_5_end-TU_5_version # Length of Unit288TU_5_version:289 .short 5 # DWARF version number290 .byte 2 # DWARF Unit Type291 .byte 8 # Address Size (in bytes)292 .long .debug_abbrev # Offset Into Abbrev. Section293 .quad 0x0011223344556677 # Type Signature294 .long TU_5_type-TU_5_start # Type offset295# The type-unit DIE, which has a name.296 .byte 2 # Abbreviation code297 .byte 0 # Index of the unit type name string298 .long .debug_str_offsets_base2 # offset into the str_offsets section299# The type DIE, which has a name.300TU_5_type:301 .byte 3 # Abbreviation code302 .byte 1 # Index of the type name string303 .byte 0 # NULL304 .byte 0 # NULL305TU_5_end:306 307 .section .debug_info.dwo,"e",@progbits308 309# DWARF v5 split CU header.310 .long CU_split_5_end-CU_split_5_version # Length of Unit311CU_split_5_version:312 .short 5 # DWARF version number313 .byte 1 # DWARF Unit Type314 .byte 8 # Address Size (in bytes)315 .long .debug_abbrev.dwo # Offset Into Abbrev Section316# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name, 317# DW_AT_str_offsets and DW_AT_compdir.318 .byte 1 # Abbreviation code319 .byte 0 # The index of the producer string320 .byte 1 # The index of the CU name string321 .byte 2 # The index of the comp dir string322 .byte 0 # NULL323CU_split_5_end:324 325 .section .debug_types.dwo,"e",@progbits326 327# DWARF v5 split type unit header.328TU_split_5_start:329 .long TU_split_5_end-TU_split_5_version # Length of Unit330TU_split_5_version:331 .short 5 # DWARF version number332 .byte 6 # DWARF Unit Type333 .byte 8 # Address Size (in bytes)334 .long .debug_abbrev.dwo # Offset Into Abbrev Section335 .quad 0x8899aabbccddeeff # Type Signature336 .long TU_split_5_type-TU_split_5_start # Type offset337# The type-unit DIE, which has a name.338 .byte 2 # Abbreviation code339 .byte 3 # The index of the type unit name string340# The type DIE, which has a name.341TU_split_5_type:342 .byte 3 # Abbreviation code343 .byte 4 # The index of the type name string344 .byte 0 # NULL345 .byte 0 # NULL346TU_split_5_end:347 348# We are using a hand-constructed object file and are interest in the correct349# diplay of the DW_str_offsetsbase attribute, the correct display of strings350# and the dump of the .debug_str_offsets[.dwo] table.351 352# Abbreviation for DW_AT_str_offsets_base353# COMMON: .debug_abbrev contents:354# COMMON-NOT: contents:355# COMMON: DW_TAG_compile_unit356# COMMON-NOT: DW_TAG357# COMMON: DW_AT_str_offsets_base DW_FORM_sec_offset358# 359# Verify that strings are displayed correctly as indexed strings360# COMMON: .debug_info contents:361# COMMON-NOT: contents: 362# COMMON: DW_TAG_compile_unit363# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")364# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_1")365# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)366# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU1")367# COMMON-NOT: NULL368# COMMON: DW_TAG_subprogram369# COMMON-NEXT: DW_AT_name [DW_FORM_strx1] (indexed (00000003) string = "MyFunc")370# COMMON-NOT: NULL371# COMMON: DW_TAG_variable372# COMMON-NEXT: DW_AT_name [DW_FORM_strx2] (indexed (00000004) string = "MyVar1")373# COMMON-NOT: NULL374# COMMON: DW_TAG_variable375# COMMON-NEXT: DW_AT_name [DW_FORM_strx3] (indexed (00000005) string = "MyVar2")376# COMMON-NOT: NULL377# COMMON: DW_TAG_variable378# COMMON-NEXT: DW_AT_name [DW_FORM_strx4] (indexed (00000006) string = "MyVar3")379# 380# Second compile unit (b.cpp)381# COMMON: DW_TAG_compile_unit382# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")383# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_2")384# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x0000000000000038)385# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU2")386# 387# The split CU388# SPLIT: .debug_info.dwo contents:389# SPLIT-NOT: contents:390# SPLIT: DW_TAG_compile_unit391# SPLIT-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade split DWARF producer")392# SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "V5_split_compile_unit")393# SPLIT-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/splitCU")394# 395# The type unit396# COMMON: .debug_types contents:397# COMMON: DW_TAG_type_unit398# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000000) string = "Type_Unit")399# COMMON: DW_TAG_structure_type400# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "MyStruct")401# 402# The split type unit403# SPLIT: .debug_types.dwo contents:404# SPLIT: DW_TAG_type_unit405# SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000003) string = "V5_split_type_unit")406# SPLIT: DW_TAG_structure_type407# SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000004) string = "V5_split_Mystruct")408# 409# The .debug_str_offsets section410# OFFSETS: .debug_str_offsets contents:411# OFFSETS-NEXT: 0x00000000: Contribution size = 32, Format = DWARF32, Version = 5412# OFFSETS-NEXT: 0x00000008: 00000000 "Handmade DWARF producer"413# OFFSETS-NEXT: 0x0000000c: 00000018 "Compile_Unit_1"414# OFFSETS-NEXT: 0x00000010: 00000027 "/home/test/CU1"415# OFFSETS-NEXT: 0x00000014: 00000067 "MyFunc"416# OFFSETS-NEXT: 0x00000018: 0000006e "MyVar1"417# OFFSETS-NEXT: 0x0000001c: 00000075 "MyVar2"418# OFFSETS-NEXT: 0x00000020: 0000007c "MyVar3"419# OFFSETS-NEXT: Gap, length = 4420# OFFSETS-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5421# OFFSETS-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"422# OFFSETS-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"423# OFFSETS-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"424# OFFSETS-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5425# OFFSETS-NEXT: 0x00000058: 00000054 "Type_Unit"426# OFFSETS-NEXT: 0x0000005c: 0000005e "MyStruct"427# 428# OFFSETS: .debug_str_offsets.dwo contents:429# OFFSETS-NEXT: 0x00000000: Contribution size = 24, Format = DWARF32, Version = 5430# OFFSETS-NEXT: 0x00000008: 00000000 "Handmade split DWARF producer"431# OFFSETS-NEXT: 0x0000000c: 0000001e "V5_split_compile_unit"432# OFFSETS-NEXT: 0x00000010: 00000034 "/home/test/splitCU"433# OFFSETS-NEXT: 0x00000014: 00000047 "V5_split_type_unit"434# OFFSETS-NEXT: 0x00000018: 0000005a "V5_split_Mystruct"435 436# VERIFY: No errors.437 438# ERR-NOT: parsing a range list table:439