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
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
14 .asciz "Handmade DWARF producer"
16 .asciz "Compile_Unit_1"
18 .asciz "/home/test/CU1"
20 .asciz "Compile_Unit_2"
22 .asciz "/home/test/CU2"
36 # Every unit contributes to the string_offsets table.
37 .section .debug_str_offsets,"",@progbits
39 .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4
40 .short 5 # DWARF version
42 .debug_str_offsets_base0:
50 .debug_str_offsets_segment0_end:
53 # CU2's contribution in DWARF64 format
55 .quad .debug_str_offsets_segment1_end-.debug_str_offsets_base1+4
56 .short 5 # DWARF version
58 .debug_str_offsets_base1:
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
67 .debug_str_offsets_base2:
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"
76 .asciz "V5_split_compile_unit"
77 dwo_str_CU_5_comp_dir
:
78 .asciz "/home/test/splitCU"
80 .asciz "V5_split_type_unit"
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
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
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
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
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
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
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
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
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
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
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
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
200 .section .debug_info,"",@progbits
202 # DWARF v5 CU header.
203 .long CU1_5_end-CU1_5_version # Length of Unit
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
233 # A base type DIE with DW_AT_encoding.
235 .byte 8 # Abbreviation code
236 .byte 5 # DW_ATE_signed
242 .long CU2_5_end-CU2_5_version # Length of Unit
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
258 .section .debug_types,"",@progbits
259 # DWARF v5 Type unit header.
261 .long TU_5_end-TU_5_version # Length of Unit
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.
275 .byte 3 # Abbreviation code
276 .byte 1 # Index of the type name string
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
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
299 .section .debug_types.dwo,"",@progbits
301 # DWARF v5 split type unit header.
303 .long TU_split_5_end-TU_split_5_version # Length of Unit
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.
316 .byte 3 # Abbreviation code
317 .byte 4 # The index of the type name string
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
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")
342 # COMMON: DW_TAG_subprogram
343 # COMMON-NEXT: DW_AT_name [DW_FORM_strx1] (indexed (00000003) string = "MyFunc")
345 # COMMON: DW_TAG_variable
346 # COMMON-NEXT: DW_AT_name [DW_FORM_strx2] (indexed (00000004) string = "MyVar1")
348 # COMMON: DW_TAG_variable
349 # COMMON-NEXT: DW_AT_name [DW_FORM_strx3] (indexed (00000005) string = "MyVar2")
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")
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")
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"
412 # ERR-NOT: parsing a range list table: