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