1 # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2 # RUN: llvm-dwarfdump -v %t.o 2> %t.err | FileCheck --check-prefixes=COMMON,SPLIT,OFFSETS %s
4 # FIXME: the verifier does not accept padding between debug-str-offset
5 # sections, which this test uses.
6 # RUN: llvm-dwarfdump -verify --debug-info %t.o | FileCheck --check-prefix=VERIFY %s
7 # RUN: llvm-dwarfdump -debug-str-offsets %t.o | FileCheck --check-prefix=OFFSETS %s
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.err
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.
16 .section .debug_str,"MS",@progbits,1
18 .asciz "Handmade DWARF producer"
20 .asciz "Compile_Unit_1"
22 .asciz "/home/test/CU1"
24 .asciz "Compile_Unit_2"
26 .asciz "/home/test/CU2"
40 # Every unit contributes to the string_offsets table.
41 .section .debug_str_offsets,"",@progbits
43 .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4
44 .short 5 # DWARF version
46 .debug_str_offsets_base0:
54 .debug_str_offsets_segment0_end:
57 # CU2's contribution in DWARF64 format
59 .quad .debug_str_offsets_segment1_end-.debug_str_offsets_base1+4
60 .short 5 # DWARF version
62 .debug_str_offsets_base1:
66 .debug_str_offsets_segment1_end:
67 # The TU's contribution
68 .long .debug_str_offsets_segment2_end-.debug_str_offsets_base2+4
69 .short 5 # DWARF version
71 .debug_str_offsets_base2:
74 .debug_str_offsets_segment2_end:
76 .section .debug_str.dwo,"MSe",@progbits,1
77 dwo_str_CU_5_producer
:
78 .asciz "Handmade split DWARF producer"
80 .asciz "V5_split_compile_unit"
81 dwo_str_CU_5_comp_dir
:
82 .asciz "/home/test/splitCU"
84 .asciz "V5_split_type_unit"
86 .asciz "V5_split_Mystruct"
88 .section .debug_str_offsets.dwo,"e",@progbits
89 # One contribution only in a .dwo file
90 .long .debug_dwo_str_offsets_segment0_end-.debug_dwo_str_offsets_base0+4
91 .short 5 # DWARF version
93 .debug_dwo_str_offsets_base0:
94 .long dwo_str_CU_5_producer-.debug_str.dwo
95 .long dwo_str_CU_5_name-.debug_str.dwo
96 .long dwo_str_CU_5_comp_dir-.debug_str.dwo
97 .long dwo_str_TU_5-.debug_str.dwo
98 .long dwo_str_TU_5_type-.debug_str.dwo
99 .debug_dwo_str_offsets_segment0_end:
101 # All CUs/TUs use the same abbrev section for simplicity.
102 .section .debug_abbrev,"",@progbits
103 .byte 0x01 # Abbrev code
104 .byte 0x11 # DW_TAG_compile_unit
105 .byte 0x01 # DW_CHILDREN_yes
106 .byte 0x25 # DW_AT_producer
107 .byte 0x1a # DW_FORM_strx
108 .byte 0x03 # DW_AT_name
109 .byte 0x1a # DW_FORM_strx
110 .byte 0x72 # DW_AT_str_offsets_base
111 .byte 0x17 # DW_FORM_sec_offset
112 .byte 0x1b # DW_AT_comp_dir
113 .byte 0x1a # DW_FORM_strx
116 .byte 0x02 # Abbrev code
117 .byte 0x41 # DW_TAG_type_unit
118 .byte 0x01 # DW_CHILDREN_yes
119 .byte 0x03 # DW_AT_name
120 .byte 0x1a # DW_FORM_strx
121 .byte 0x72 # DW_AT_str_offsets_base
122 .byte 0x17 # DW_FORM_sec_offset
125 .byte 0x03 # Abbrev code
126 .byte 0x13 # DW_TAG_structure_type
127 .byte 0x00 # DW_CHILDREN_no (no members)
128 .byte 0x03 # DW_AT_name
129 .byte 0x1a # DW_FORM_strx
132 .byte 0x04 # Abbrev code
133 .byte 0x2e # DW_TAG_subprogram
134 .byte 0x01 # DW_CHILDREN_yes
135 .byte 0x03 # DW_AT_name
136 .byte 0x25 # DW_FORM_strx1
139 .byte 0x05 # Abbrev code
140 .byte 0x34 # DW_TAG_variable
141 .byte 0x00 # DW_CHILDREN_no
142 .byte 0x03 # DW_AT_name
143 .byte 0x26 # DW_FORM_strx2
144 .byte 0x49 # DW_AT_type
145 .byte 0x13 # DW_FORM_ref4
148 .byte 0x06 # Abbrev code
149 .byte 0x34 # DW_TAG_variable
150 .byte 0x00 # DW_CHILDREN_no
151 .byte 0x03 # DW_AT_name
152 .byte 0x27 # DW_FORM_strx3
153 .byte 0x49 # DW_AT_type
154 .byte 0x13 # DW_FORM_ref4
157 .byte 0x07 # Abbrev code
158 .byte 0x34 # DW_TAG_variable
159 .byte 0x00 # DW_CHILDREN_no
160 .byte 0x03 # DW_AT_name
161 .byte 0x28 # DW_FORM_strx4
162 .byte 0x49 # DW_AT_type
163 .byte 0x13 # DW_FORM_ref4
166 .byte 0x08 # Abbrev code
167 .byte 0x24 # DW_TAG_base_type
168 .byte 0x00 # DW_CHILDREN_no
169 .byte 0x3e # DW_AT_encoding
170 .byte 0x0b # DW_FORM_data1
173 .byte 0x09 # Abbrev code
174 .byte 0x11 # DW_TAG_compile_unit
175 .byte 0x00 # DW_CHILDREN_no
180 # And a .dwo copy of a subset for the .dwo sections.
181 .section .debug_abbrev.dwo,"e",@progbits
182 .byte 0x01 # Abbrev code
183 .byte 0x11 # DW_TAG_compile_unit
184 .byte 0x00 # DW_CHILDREN_no
185 .byte 0x25 # DW_AT_producer
186 .byte 0x1a # DW_FORM_strx
187 .byte 0x03 # DW_AT_name
188 .byte 0x1a # DW_FORM_strx
189 .byte 0x1b # DW_AT_comp_dir
190 .byte 0x1a # DW_FORM_strx
193 .byte 0x02 # Abbrev code
194 .byte 0x41 # DW_TAG_type_unit
195 .byte 0x01 # DW_CHILDREN_yes
196 .byte 0x03 # DW_AT_name
197 .byte 0x1a # DW_FORM_strx
200 .byte 0x03 # Abbrev code
201 .byte 0x13 # DW_TAG_structure_type
202 .byte 0x00 # DW_CHILDREN_no (no members)
203 .byte 0x03 # DW_AT_name
204 .byte 0x1a # DW_FORM_strx
209 .section .debug_info,"",@progbits
211 # DWARF v5 CU header.
212 .long CU1_5_end-CU1_5_version # Length of Unit
214 .short 5 # DWARF version number
215 .byte 1 # DWARF Unit Type
216 .byte 8 # Address Size (in bytes)
217 .long .debug_abbrev # Offset Into Abbrev. Section
218 # 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 code
221 .byte 0 # The index of the producer string
222 .byte 1 # The index of the CU name string
223 .long .debug_str_offsets_base0
224 .byte 2 # The index of the comp dir string
225 # A subprogram DIE with DW_AT_name, using DW_FORM_strx1.
226 .byte 4 # Abbreviation code
227 .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 code
230 .short 0x0004 # Subprogram name string (DW_FORM_strx2)
231 .long TypeDie-.debug_info
232 # A variable DIE with DW_AT_name, using DW_FORM_strx3, and DW_AT_type.
233 .byte 6 # Abbreviation code
234 .byte 5 # Subprogram name string (DW_FORM_strx3)
235 .short 0 # Subprogram name string (DW_FORM_strx3)
236 .long TypeDie-.debug_info
237 # A variable DIE with DW_AT_name, using DW_FORM_strx4, and DW_AT_type.
238 .byte 7 # Abbreviation code
239 .long 6 # Subprogram name string (DW_FORM_strx4)
240 .long TypeDie-.debug_info
242 # A base type DIE with DW_AT_encoding.
244 .byte 8 # Abbreviation code
245 .byte 5 # DW_ATE_signed
252 .quad CU2_5_end-CU2_5_version # Length of Unit
254 .short 5 # DWARF version number
255 .byte 1 # DWARF Unit Type
256 .byte 8 # Address Size (in bytes)
257 .quad .debug_abbrev # Offset Into Abbrev. Section
258 # 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 code
261 .byte 0 # The index of the producer string
262 .byte 1 # The index of the CU name string
263 .quad .debug_str_offsets_base1
264 .byte 2 # The index of the comp dir string
267 # DWARF v5 CU without str_offsets_base - this shouldn't produce an error/nor
268 # prevent other str_offsets contributions from being dumped.
269 .long CU3_5_end-CU3_5_version # Length of Unit
271 .short 5 # DWARF version number
272 .byte 1 # DWARF Unit Type
273 .byte 8 # Address Size (in bytes)
274 .long .debug_abbrev # Offset Into Abbrev. Section
275 # The compile-unit DIE with no attributes.
276 .byte 9 # Abbreviation code
284 .section .debug_types,"",@progbits
285 # DWARF v5 Type unit header.
287 .long TU_5_end-TU_5_version # Length of Unit
289 .short 5 # DWARF version number
290 .byte 2 # DWARF Unit Type
291 .byte 8 # Address Size (in bytes)
292 .long .debug_abbrev # Offset Into Abbrev. Section
293 .quad 0x0011223344556677 # Type Signature
294 .long TU_5_type-TU_5_start # Type offset
295 # The type-unit DIE, which has a name.
296 .byte 2 # Abbreviation code
297 .byte 0 # Index of the unit type name string
298 .long .debug_str_offsets_base2 # offset into the str_offsets section
299 # The type DIE, which has a name.
301 .byte 3 # Abbreviation code
302 .byte 1 # Index of the type name string
307 .section .debug_info.dwo,"e",@progbits
309 # DWARF v5 split CU header.
310 .long CU_split_5_end-CU_split_5_version # Length of Unit
312 .short 5 # DWARF version number
313 .byte 1 # DWARF Unit Type
314 .byte 8 # Address Size (in bytes)
315 .long .debug_abbrev.dwo # Offset Into Abbrev Section
316 # 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 code
319 .byte 0 # The index of the producer string
320 .byte 1 # The index of the CU name string
321 .byte 2 # The index of the comp dir string
325 .section .debug_types.dwo,"e",@progbits
327 # DWARF v5 split type unit header.
329 .long TU_split_5_end-TU_split_5_version # Length of Unit
331 .short 5 # DWARF version number
332 .byte 6 # DWARF Unit Type
333 .byte 8 # Address Size (in bytes)
334 .long .debug_abbrev.dwo # Offset Into Abbrev Section
335 .quad 0x8899aabbccddeeff # Type Signature
336 .long TU_split_5_type-TU_split_5_start # Type offset
337 # The type-unit DIE, which has a name.
338 .byte 2 # Abbreviation code
339 .byte 3 # The index of the type unit name string
340 # The type DIE, which has a name.
342 .byte 3 # Abbreviation code
343 .byte 4 # The index of the type name string
348 # We are using a hand-constructed object file and are interest in the correct
349 # diplay of the DW_str_offsetsbase attribute, the correct display of strings
350 # and the dump of the .debug_str_offsets[.dwo] table.
352 # Abbreviation for DW_AT_str_offsets_base
353 # COMMON: .debug_abbrev contents:
354 # COMMON-NOT: contents:
355 # COMMON: DW_TAG_compile_unit
357 # COMMON: DW_AT_str_offsets_base DW_FORM_sec_offset
359 # Verify that strings are displayed correctly as indexed strings
360 # COMMON: .debug_info contents:
361 # COMMON-NOT: contents:
362 # COMMON: DW_TAG_compile_unit
363 # 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")
368 # COMMON: DW_TAG_subprogram
369 # COMMON-NEXT: DW_AT_name [DW_FORM_strx1] (indexed (00000003) string = "MyFunc")
371 # COMMON: DW_TAG_variable
372 # COMMON-NEXT: DW_AT_name [DW_FORM_strx2] (indexed (00000004) string = "MyVar1")
374 # COMMON: DW_TAG_variable
375 # COMMON-NEXT: DW_AT_name [DW_FORM_strx3] (indexed (00000005) string = "MyVar2")
377 # COMMON: DW_TAG_variable
378 # COMMON-NEXT: DW_AT_name [DW_FORM_strx4] (indexed (00000006) string = "MyVar3")
380 # Second compile unit (b.cpp)
381 # COMMON: DW_TAG_compile_unit
382 # 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")
388 # SPLIT: .debug_info.dwo contents:
389 # SPLIT-NOT: contents:
390 # SPLIT: DW_TAG_compile_unit
391 # 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")
396 # COMMON: .debug_types contents:
397 # COMMON: DW_TAG_type_unit
398 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000000) string = "Type_Unit")
399 # COMMON: DW_TAG_structure_type
400 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "MyStruct")
402 # The split type unit
403 # SPLIT: .debug_types.dwo contents:
404 # SPLIT: DW_TAG_type_unit
405 # SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000003) string = "V5_split_type_unit")
406 # SPLIT: DW_TAG_structure_type
407 # SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000004) string = "V5_split_Mystruct")
409 # The .debug_str_offsets section
410 # OFFSETS: .debug_str_offsets contents:
411 # OFFSETS-NEXT: 0x00000000: Contribution size = 32, Format = DWARF32, Version = 5
412 # 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 = 4
420 # OFFSETS-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
421 # 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 = 5
425 # OFFSETS-NEXT: 0x00000058: 00000054 "Type_Unit"
426 # OFFSETS-NEXT: 0x0000005c: 0000005e "MyStruct"
428 # OFFSETS: .debug_str_offsets.dwo contents:
429 # OFFSETS-NEXT: 0x00000000: Contribution size = 24, Format = DWARF32, Version = 5
430 # 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"
438 # ERR-NOT: parsing a range list table: