Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / DebugInfo / X86 / dwarfdump-str-offsets.s
blob1725813aac7707174796b45a4c76973d78815f02
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
3 # RUN: llvm-dwarfdump -verify %t.o | FileCheck --check-prefix=VERIFY %s
4 # RUN: llvm-dwarfdump -debug-str-offsets %t.o | FileCheck --check-prefix=OFFSETS %s
5 #
6 # Check that we don't report an error on a non-existent range list table.
7 # RUN: FileCheck -allow-empty --check-prefix ERR %s < %t.err
9 # Test object to verify dwarfdump handles v5 string offset tables.
10 # We have 2 v5 CUs, a v5 TU, and a split v5 CU and TU.
13 .section .debug_str,"MS",@progbits,1
14 str_producer:
15 .asciz "Handmade DWARF producer"
16 str_CU1:
17 .asciz "Compile_Unit_1"
18 str_CU1_dir:
19 .asciz "/home/test/CU1"
20 str_CU2:
21 .asciz "Compile_Unit_2"
22 str_CU2_dir:
23 .asciz "/home/test/CU2"
24 str_TU:
25 .asciz "Type_Unit"
26 str_TU_type:
27 .asciz "MyStruct"
28 str_Subprogram:
29 .asciz "MyFunc"
30 str_Variable1:
31 .asciz "MyVar1"
32 str_Variable2:
33 .asciz "MyVar2"
34 str_Variable3:
35 .asciz "MyVar3"
37 # Every unit contributes to the string_offsets table.
38 .section .debug_str_offsets,"",@progbits
39 # CU1's contribution
40 .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4
41 .short 5 # DWARF version
42 .short 0 # Padding
43 .debug_str_offsets_base0:
44 .long str_producer
45 .long str_CU1
46 .long str_CU1_dir
47 .long str_Subprogram
48 .long str_Variable1
49 .long str_Variable2
50 .long str_Variable3
51 .debug_str_offsets_segment0_end:
52 # A 4-byte gap.
53 .long 0
54 # CU2's contribution in DWARF64 format
55 .long 0xffffffff
56 .quad .debug_str_offsets_segment1_end-.debug_str_offsets_base1+4
57 .short 5 # DWARF version
58 .short 0 # Padding
59 .debug_str_offsets_base1:
60 .quad str_producer
61 .quad str_CU2
62 .quad str_CU2_dir
63 .debug_str_offsets_segment1_end:
64 # The TU's contribution
65 .long .debug_str_offsets_segment2_end-.debug_str_offsets_base2+4
66 .short 5 # DWARF version
67 .short 0 # Padding
68 .debug_str_offsets_base2:
69 .long str_TU
70 .long str_TU_type
71 .debug_str_offsets_segment2_end:
73 .section .debug_str.dwo,"MSe",@progbits,1
74 dwo_str_CU_5_producer:
75 .asciz "Handmade split DWARF producer"
76 dwo_str_CU_5_name:
77 .asciz "V5_split_compile_unit"
78 dwo_str_CU_5_comp_dir:
79 .asciz "/home/test/splitCU"
80 dwo_str_TU_5:
81 .asciz "V5_split_type_unit"
82 dwo_str_TU_5_type:
83 .asciz "V5_split_Mystruct"
85 .section .debug_str_offsets.dwo,"e",@progbits
86 # One contribution only in a .dwo file
87 .long .debug_dwo_str_offsets_segment0_end-.debug_dwo_str_offsets_base0+4
88 .short 5 # DWARF version
89 .short 0 # Padding
90 .debug_dwo_str_offsets_base0:
91 .long dwo_str_CU_5_producer-.debug_str.dwo
92 .long dwo_str_CU_5_name-.debug_str.dwo
93 .long dwo_str_CU_5_comp_dir-.debug_str.dwo
94 .long dwo_str_TU_5-.debug_str.dwo
95 .long dwo_str_TU_5_type-.debug_str.dwo
96 .debug_dwo_str_offsets_segment0_end:
98 # All CUs/TUs use the same abbrev section for simplicity.
99 .section .debug_abbrev,"",@progbits
100 .byte 0x01 # Abbrev code
101 .byte 0x11 # DW_TAG_compile_unit
102 .byte 0x01 # DW_CHILDREN_yes
103 .byte 0x25 # DW_AT_producer
104 .byte 0x1a # DW_FORM_strx
105 .byte 0x03 # DW_AT_name
106 .byte 0x1a # DW_FORM_strx
107 .byte 0x72 # DW_AT_str_offsets_base
108 .byte 0x17 # DW_FORM_sec_offset
109 .byte 0x1b # DW_AT_comp_dir
110 .byte 0x1a # DW_FORM_strx
111 .byte 0x00 # EOM(1)
112 .byte 0x00 # EOM(2)
113 .byte 0x02 # Abbrev code
114 .byte 0x41 # DW_TAG_type_unit
115 .byte 0x01 # DW_CHILDREN_yes
116 .byte 0x03 # DW_AT_name
117 .byte 0x1a # DW_FORM_strx
118 .byte 0x72 # DW_AT_str_offsets_base
119 .byte 0x17 # DW_FORM_sec_offset
120 .byte 0x00 # EOM(1)
121 .byte 0x00 # EOM(2)
122 .byte 0x03 # Abbrev code
123 .byte 0x13 # DW_TAG_structure_type
124 .byte 0x00 # DW_CHILDREN_no (no members)
125 .byte 0x03 # DW_AT_name
126 .byte 0x1a # DW_FORM_strx
127 .byte 0x00 # EOM(1)
128 .byte 0x00 # EOM(2)
129 .byte 0x04 # Abbrev code
130 .byte 0x2e # DW_TAG_subprogram
131 .byte 0x01 # DW_CHILDREN_yes
132 .byte 0x03 # DW_AT_name
133 .byte 0x25 # DW_FORM_strx1
134 .byte 0x00 # EOM(1)
135 .byte 0x00 # EOM(2)
136 .byte 0x05 # Abbrev code
137 .byte 0x34 # DW_TAG_variable
138 .byte 0x00 # DW_CHILDREN_no
139 .byte 0x03 # DW_AT_name
140 .byte 0x26 # DW_FORM_strx2
141 .byte 0x49 # DW_AT_type
142 .byte 0x13 # DW_FORM_ref4
143 .byte 0x00 # EOM(1)
144 .byte 0x00 # EOM(2)
145 .byte 0x06 # Abbrev code
146 .byte 0x34 # DW_TAG_variable
147 .byte 0x00 # DW_CHILDREN_no
148 .byte 0x03 # DW_AT_name
149 .byte 0x27 # DW_FORM_strx3
150 .byte 0x49 # DW_AT_type
151 .byte 0x13 # DW_FORM_ref4
152 .byte 0x00 # EOM(1)
153 .byte 0x00 # EOM(2)
154 .byte 0x07 # Abbrev code
155 .byte 0x34 # DW_TAG_variable
156 .byte 0x00 # DW_CHILDREN_no
157 .byte 0x03 # DW_AT_name
158 .byte 0x28 # DW_FORM_strx4
159 .byte 0x49 # DW_AT_type
160 .byte 0x13 # DW_FORM_ref4
161 .byte 0x00 # EOM(1)
162 .byte 0x00 # EOM(2)
163 .byte 0x08 # Abbrev code
164 .byte 0x24 # DW_TAG_base_type
165 .byte 0x00 # DW_CHILDREN_no
166 .byte 0x3e # DW_AT_encoding
167 .byte 0x0b # DW_FORM_data1
168 .byte 0x00 # EOM(1)
169 .byte 0x00 # EOM(2)
170 .byte 0x09 # Abbrev code
171 .byte 0x11 # DW_TAG_compile_unit
172 .byte 0x00 # DW_CHILDREN_no
173 .byte 0x00 # EOM(1)
174 .byte 0x00 # EOM(2)
175 .byte 0x00 # EOM(3)
177 # And a .dwo copy of a subset for the .dwo sections.
178 .section .debug_abbrev.dwo,"e",@progbits
179 .byte 0x01 # Abbrev code
180 .byte 0x11 # DW_TAG_compile_unit
181 .byte 0x00 # DW_CHILDREN_no
182 .byte 0x25 # DW_AT_producer
183 .byte 0x1a # DW_FORM_strx
184 .byte 0x03 # DW_AT_name
185 .byte 0x1a # DW_FORM_strx
186 .byte 0x1b # DW_AT_comp_dir
187 .byte 0x1a # DW_FORM_strx
188 .byte 0x00 # EOM(1)
189 .byte 0x00 # EOM(2)
190 .byte 0x02 # Abbrev code
191 .byte 0x41 # DW_TAG_type_unit
192 .byte 0x01 # DW_CHILDREN_yes
193 .byte 0x03 # DW_AT_name
194 .byte 0x1a # DW_FORM_strx
195 .byte 0x00 # EOM(1)
196 .byte 0x00 # EOM(2)
197 .byte 0x03 # Abbrev code
198 .byte 0x13 # DW_TAG_structure_type
199 .byte 0x00 # DW_CHILDREN_no (no members)
200 .byte 0x03 # DW_AT_name
201 .byte 0x1a # DW_FORM_strx
202 .byte 0x00 # EOM(1)
203 .byte 0x00 # EOM(2)
204 .byte 0x00 # EOM(3)
206 .section .debug_info,"",@progbits
208 # DWARF v5 CU header.
209 .long CU1_5_end-CU1_5_version # Length of Unit
210 CU1_5_version:
211 .short 5 # DWARF version number
212 .byte 1 # DWARF Unit Type
213 .byte 8 # Address Size (in bytes)
214 .long .debug_abbrev # Offset Into Abbrev. Section
215 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
216 # DW_AT_str_offsets and DW_AT_compdir.
217 .byte 1 # Abbreviation code
218 .byte 0 # The index of the producer string
219 .byte 1 # The index of the CU name string
220 .long .debug_str_offsets_base0
221 .byte 2 # The index of the comp dir string
222 # A subprogram DIE with DW_AT_name, using DW_FORM_strx1.
223 .byte 4 # Abbreviation code
224 .byte 3 # Subprogram name string (DW_FORM_strx1)
225 # A variable DIE with DW_AT_name, using DW_FORM_strx2, and DW_AT_type.
226 .byte 5 # Abbreviation code
227 .short 0x0004 # Subprogram name string (DW_FORM_strx2)
228 .long TypeDie-.debug_info
229 # A variable DIE with DW_AT_name, using DW_FORM_strx3, and DW_AT_type.
230 .byte 6 # Abbreviation code
231 .byte 5 # Subprogram name string (DW_FORM_strx3)
232 .short 0 # Subprogram name string (DW_FORM_strx3)
233 .long TypeDie-.debug_info
234 # A variable DIE with DW_AT_name, using DW_FORM_strx4, and DW_AT_type.
235 .byte 7 # Abbreviation code
236 .long 6 # Subprogram name string (DW_FORM_strx4)
237 .long TypeDie-.debug_info
238 .byte 0 # NULL
239 # A base type DIE with DW_AT_encoding.
240 TypeDie:
241 .byte 8 # Abbreviation code
242 .byte 5 # DW_ATE_signed
243 .byte 0 # NULL
244 .byte 0 # NULL
245 CU1_5_end:
247 # DWARF v5 CU header
248 .long 0xffffffff
249 .quad CU2_5_end-CU2_5_version # Length of Unit
250 CU2_5_version:
251 .short 5 # DWARF version number
252 .byte 1 # DWARF Unit Type
253 .byte 8 # Address Size (in bytes)
254 .quad .debug_abbrev # Offset Into Abbrev. Section
255 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
256 # DW_AT_str_offsets and DW_AT_compdir.
257 .byte 1 # Abbreviation code
258 .byte 0 # The index of the producer string
259 .byte 1 # The index of the CU name string
260 .quad .debug_str_offsets_base1
261 .byte 2 # The index of the comp dir string
262 .byte 0 # NULL
263 CU2_5_end:
264 # DWARF v5 CU without str_offsets_base - this shouldn't produce an error/nor
265 # prevent other str_offsets contributions from being dumped.
266 .long CU3_5_end-CU3_5_version # Length of Unit
267 CU3_5_version:
268 .short 5 # DWARF version number
269 .byte 1 # DWARF Unit Type
270 .byte 8 # Address Size (in bytes)
271 .long .debug_abbrev # Offset Into Abbrev. Section
272 # The compile-unit DIE with no attributes.
273 .byte 9 # Abbreviation code
274 CU3_5_end:
281 .section .debug_types,"",@progbits
282 # DWARF v5 Type unit header.
283 TU_5_start:
284 .long TU_5_end-TU_5_version # Length of Unit
285 TU_5_version:
286 .short 5 # DWARF version number
287 .byte 2 # DWARF Unit Type
288 .byte 8 # Address Size (in bytes)
289 .long .debug_abbrev # Offset Into Abbrev. Section
290 .quad 0x0011223344556677 # Type Signature
291 .long TU_5_type-TU_5_start # Type offset
292 # The type-unit DIE, which has a name.
293 .byte 2 # Abbreviation code
294 .byte 0 # Index of the unit type name string
295 .long .debug_str_offsets_base2 # offset into the str_offsets section
296 # The type DIE, which has a name.
297 TU_5_type:
298 .byte 3 # Abbreviation code
299 .byte 1 # Index of the type name string
300 .byte 0 # NULL
301 .byte 0 # NULL
302 TU_5_end:
304 .section .debug_info.dwo,"e",@progbits
306 # DWARF v5 split CU header.
307 .long CU_split_5_end-CU_split_5_version # Length of Unit
308 CU_split_5_version:
309 .short 5 # DWARF version number
310 .byte 1 # DWARF Unit Type
311 .byte 8 # Address Size (in bytes)
312 .long .debug_abbrev.dwo # Offset Into Abbrev Section
313 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
314 # DW_AT_str_offsets and DW_AT_compdir.
315 .byte 1 # Abbreviation code
316 .byte 0 # The index of the producer string
317 .byte 1 # The index of the CU name string
318 .byte 2 # The index of the comp dir string
319 .byte 0 # NULL
320 CU_split_5_end:
322 .section .debug_types.dwo,"e",@progbits
324 # DWARF v5 split type unit header.
325 TU_split_5_start:
326 .long TU_split_5_end-TU_split_5_version # Length of Unit
327 TU_split_5_version:
328 .short 5 # DWARF version number
329 .byte 6 # DWARF Unit Type
330 .byte 8 # Address Size (in bytes)
331 .long .debug_abbrev.dwo # Offset Into Abbrev Section
332 .quad 0x8899aabbccddeeff # Type Signature
333 .long TU_split_5_type-TU_split_5_start # Type offset
334 # The type-unit DIE, which has a name.
335 .byte 2 # Abbreviation code
336 .byte 3 # The index of the type unit name string
337 # The type DIE, which has a name.
338 TU_split_5_type:
339 .byte 3 # Abbreviation code
340 .byte 4 # The index of the type name string
341 .byte 0 # NULL
342 .byte 0 # NULL
343 TU_split_5_end:
345 # We are using a hand-constructed object file and are interest in the correct
346 # diplay of the DW_str_offsetsbase attribute, the correct display of strings
347 # and the dump of the .debug_str_offsets[.dwo] table.
349 # Abbreviation for DW_AT_str_offsets_base
350 # COMMON: .debug_abbrev contents:
351 # COMMON-NOT: contents:
352 # COMMON: DW_TAG_compile_unit
353 # COMMON-NOT: DW_TAG
354 # COMMON: DW_AT_str_offsets_base DW_FORM_sec_offset
356 # Verify that strings are displayed correctly as indexed strings
357 # COMMON: .debug_info contents:
358 # COMMON-NOT: contents:
359 # COMMON: DW_TAG_compile_unit
360 # COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
361 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_1")
362 # COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
363 # COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU1")
364 # COMMON-NOT: NULL
365 # COMMON: DW_TAG_subprogram
366 # COMMON-NEXT: DW_AT_name [DW_FORM_strx1] (indexed (00000003) string = "MyFunc")
367 # COMMON-NOT: NULL
368 # COMMON: DW_TAG_variable
369 # COMMON-NEXT: DW_AT_name [DW_FORM_strx2] (indexed (00000004) string = "MyVar1")
370 # COMMON-NOT: NULL
371 # COMMON: DW_TAG_variable
372 # COMMON-NEXT: DW_AT_name [DW_FORM_strx3] (indexed (00000005) string = "MyVar2")
373 # COMMON-NOT: NULL
374 # COMMON: DW_TAG_variable
375 # COMMON-NEXT: DW_AT_name [DW_FORM_strx4] (indexed (00000006) string = "MyVar3")
377 # Second compile unit (b.cpp)
378 # COMMON: DW_TAG_compile_unit
379 # COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
380 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_2")
381 # COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x0000000000000038)
382 # COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU2")
384 # The split CU
385 # SPLIT: .debug_info.dwo contents:
386 # SPLIT-NOT: contents:
387 # SPLIT: DW_TAG_compile_unit
388 # SPLIT-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade split DWARF producer")
389 # SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "V5_split_compile_unit")
390 # SPLIT-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/splitCU")
392 # The type unit
393 # COMMON: .debug_types contents:
394 # COMMON: DW_TAG_type_unit
395 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000000) string = "Type_Unit")
396 # COMMON: DW_TAG_structure_type
397 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "MyStruct")
399 # The split type unit
400 # SPLIT: .debug_types.dwo contents:
401 # SPLIT: DW_TAG_type_unit
402 # SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000003) string = "V5_split_type_unit")
403 # SPLIT: DW_TAG_structure_type
404 # SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000004) string = "V5_split_Mystruct")
406 # The .debug_str_offsets section
407 # OFFSETS: .debug_str_offsets contents:
408 # OFFSETS-NEXT: 0x00000000: Contribution size = 32, Format = DWARF32, Version = 5
409 # OFFSETS-NEXT: 0x00000008: 00000000 "Handmade DWARF producer"
410 # OFFSETS-NEXT: 0x0000000c: 00000018 "Compile_Unit_1"
411 # OFFSETS-NEXT: 0x00000010: 00000027 "/home/test/CU1"
412 # OFFSETS-NEXT: 0x00000014: 00000067 "MyFunc"
413 # OFFSETS-NEXT: 0x00000018: 0000006e "MyVar1"
414 # OFFSETS-NEXT: 0x0000001c: 00000075 "MyVar2"
415 # OFFSETS-NEXT: 0x00000020: 0000007c "MyVar3"
416 # OFFSETS-NEXT: Gap, length = 4
417 # OFFSETS-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
418 # OFFSETS-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"
419 # OFFSETS-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"
420 # OFFSETS-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"
421 # OFFSETS-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
422 # OFFSETS-NEXT: 0x00000058: 00000054 "Type_Unit"
423 # OFFSETS-NEXT: 0x0000005c: 0000005e "MyStruct"
425 # OFFSETS: .debug_str_offsets.dwo contents:
426 # OFFSETS-NEXT: 0x00000000: Contribution size = 24, Format = DWARF32, Version = 5
427 # OFFSETS-NEXT: 0x00000008: 00000000 "Handmade split DWARF producer"
428 # OFFSETS-NEXT: 0x0000000c: 0000001e "V5_split_compile_unit"
429 # OFFSETS-NEXT: 0x00000010: 00000034 "/home/test/splitCU"
430 # OFFSETS-NEXT: 0x00000014: 00000047 "V5_split_type_unit"
431 # OFFSETS-NEXT: 0x00000018: 0000005a "V5_split_Mystruct"
433 # VERIFY: No errors.
435 # ERR-NOT: parsing a range list table: