1 # Test object to verify dwarfdump handles v4 and v5 CU/TU/line headers.
2 # We have a representative set of units: v4 CU, v5 CU, v4 TU, v5 split TU.
3 # We have v4 and v5 line-table headers.
5 # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
6 # RUN: llvm-dwarfdump -v %t.o | FileCheck %s
7 # RUN: llvm-dwarfdump -verify %t.o | FileCheck %s --check-prefix=VERIFY
9 .section .debug_str,"MS",@progbits,1
11 .asciz "Handmade DWARF producer"
13 .asciz "V4_compile_unit"
15 .asciz "V5_compile_unit"
23 .section .debug_str.dwo,"MSe",@progbits,1
25 .asciz "V5_split_type_unit"
27 .asciz "Handmade DWO producer"
29 .asciz "V5_dwo_compile_unit"
31 .asciz "DWODirectory5a"
33 .asciz "DWODirectory5b"
35 .section .debug_str_offsets.dwo,"e",@progbits
36 .long Lstr_offsets_end-Lstr_offsets_start # Length of String Offsets Set
40 .long dwo_TU_5-.debug_str.dwo
41 .long dwo_producer-.debug_str.dwo
42 .long dwo_CU_5-.debug_str.dwo
43 .long dwo_LT_5a-.debug_str.dwo
44 .long dwo_LT_5b-.debug_str.dwo
47 # All CUs/TUs use the same abbrev section for simplicity.
48 .section .debug_abbrev,"",@progbits
49 .byte 0x01 # Abbrev code
50 .byte 0x11 # DW_TAG_compile_unit
51 .byte 0x00 # DW_CHILDREN_no
52 .byte 0x25 # DW_AT_producer
53 .byte 0x0e # DW_FORM_strp
54 .byte 0x03 # DW_AT_name
55 .byte 0x0e # DW_FORM_strp
56 .byte 0x10 # DW_AT_stmt_list
57 .byte 0x17 # DW_FORM_sec_offset
60 .byte 0x02 # Abbrev code
61 .byte 0x41 # DW_TAG_type_unit
62 .byte 0x01 # DW_CHILDREN_yes
63 .byte 0x03 # DW_AT_name
64 .byte 0x0e # DW_FORM_strp
67 .byte 0x03 # Abbrev code
68 .byte 0x13 # DW_TAG_structure_type
69 .byte 0x00 # DW_CHILDREN_no (no members)
70 .byte 0x03 # DW_AT_name
71 .byte 0x0e # DW_FORM_strp
74 .byte 0x04 # Abbrev code
75 .byte 0x3c # DW_TAG_partial_unit
76 .byte 0x00 # DW_CHILDREN_no
77 .byte 0x03 # DW_AT_name
78 .byte 0x0e # DW_FORM_strp
83 # And a .dwo copy for the .dwo sections.
84 .section .debug_abbrev.dwo,"e",@progbits
85 .byte 0x01 # Abbrev code
86 .byte 0x11 # DW_TAG_compile_unit
87 .byte 0x00 # DW_CHILDREN_no
88 .byte 0x25 # DW_AT_producer
89 .byte 0x25 # DW_FORM_strx1
90 .byte 0x03 # DW_AT_name
91 .byte 0x25 # DW_FORM_strx1
92 .byte 0x10 # DW_AT_stmt_list
93 .byte 0x17 # DW_FORM_sec_offset
96 .byte 0x02 # Abbrev code
97 .byte 0x41 # DW_TAG_type_unit
98 .byte 0x01 # DW_CHILDREN_yes
99 .byte 0x03 # DW_AT_name
100 .byte 0x25 # DW_FORM_strx1
103 .byte 0x03 # Abbrev code
104 .byte 0x13 # DW_TAG_structure_type
105 .byte 0x00 # DW_CHILDREN_no (no members)
106 .byte 0x03 # DW_AT_name
107 .byte 0x25 # DW_FORM_strx1
112 .section .debug_info,"",@progbits
113 # CHECK-LABEL: .debug_info contents:
115 # DWARF v4 CU header. V4 CU headers all look the same so we do only one.
116 .long CU_4_end-CU_4_version # Length of Unit
118 .short 4 # DWARF version number
119 .long .debug_abbrev # Offset Into Abbrev. Section
120 .byte 8 # Address Size (in bytes)
121 # The compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
129 # CHECK: 0x00000000: Compile Unit: length = 0x00000015, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000019)
130 # CHECK: 0x0000000b: DW_TAG_compile_unit
132 # DWARF v5 normal CU header.
133 .long CU_5_end-CU_5_version # Length of Unit
135 .short 5 # DWARF version number
136 .byte 1 # DWARF Unit Type
137 .byte 8 # Address Size (in bytes)
138 .long .debug_abbrev # Offset Into Abbrev. Section
139 # The compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
147 # CHECK: 0x00000019: Compile Unit: length = 0x00000016, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000033)
148 # CHECK: 0x00000025: DW_TAG_compile_unit
150 # DWARF v5 CU header (Unit Type = DW_UT_partial).
151 .long CU_5_partial_end-CU_5_partial_version # Length of Unit
152 CU_5_partial_version
:
153 .short 5 # DWARF version number
154 .byte 3 # DWARF Unit Type
155 .byte 8 # Address Size (in bytes)
156 .long .debug_abbrev # Offset Into Abbrev. Section
157 # The partial-unit DIE, with DW_AT_name
163 # CHECK: 0x00000033: Compile Unit: length = 0x0000000e, format = DWARF32, version = 0x0005, unit_type = DW_UT_partial, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000045)
164 # CHECK: 0x0000003f: DW_TAG_partial_unit
166 .section .debug_info.dwo,"e",@progbits
167 # CHECK-LABEL: .debug_info.dwo
169 # DWARF v5 split CU header.
170 .long CU_split_5_end-CU_split_5_version # Length of Unit
172 .short 5 # DWARF version number
173 .byte 5 # DWARF Unit Type
174 .byte 8 # Address Size (in bytes)
175 .long 0 # Offset Into Abbrev. Section
177 # The split compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
185 # CHECK: 0x00000000: Compile Unit: length = 0x00000018, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_compile, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = 0x000000000000005a (next unit at 0x0000001c)
186 # CHECK: 0x00000014: DW_TAG_compile_unit
187 # CHECK-NEXT: DW_AT_producer {{.*}} "Handmade DWO producer"
188 # CHECK-NEXT: DW_AT_name {{.*}} "V5_dwo_compile_unit"
190 # Now a DWARF v5 type unit, which goes in a .debug_info.dwo comdat.
191 # Note there will not be another ".debug_info.dwo contents:" line, even though
192 # there is a separate ELF section header; it's dumped along with the previous
193 # unit as if they were in a single section.
195 .section .debug_info.dwo,"Ge",@progbits,5555,comdat
196 # CHECK-NOT: .debug_info.dwo
198 # DWARF v5 split type unit header.
200 .long TU_split_5_end-TU_split_5_version # Length of Unit
202 .short 5 # DWARF version number
203 .byte 6 # DWARF Unit Type
204 .byte 8 # Address Size (in bytes)
205 .long 0 # Offset Into Abbrev. Section
206 .quad 0x8899aabbccddeeff # Type Signature
207 .long TU_split_5_type-TU_split_5_start # Type offset
208 # The type-unit DIE, which has a name.
211 # The type DIE, which has a name.
219 # CHECK: 0x00000000: Type Unit: length = 0x0000001a, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_type, abbr_offset = 0x0000, addr_size = 0x08, name = 'V5_split_type_unit', type_signature = 0x8899aabbccddeeff, type_offset = 0x001a (next unit at 0x0000001e)
220 # CHECK: 0x00000018: DW_TAG_type_unit
222 .section .debug_types,"",@progbits
223 # CHECK-LABEL: .debug_types contents:
225 # DWARF v4 Type unit header. Normal/split are identical so we do only one.
227 .long TU_4_end-TU_4_version # Length of Unit
229 .short 4 # DWARF version number
230 .long .debug_abbrev # Offset Into Abbrev. Section
231 .byte 8 # Address Size (in bytes)
232 .quad 0x0011223344556677 # Type Signature
233 .long TU_4_type-TU_4_start # Type offset
234 # The type-unit DIE, which has a name.
237 # The type DIE, which has a name.
245 # CHECK: 0x00000000: Type Unit: length = 0x0000001f, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08, name = 'V4_type_unit', type_signature = 0x0011223344556677, type_offset = 0x001c (next unit at 0x00000023)
246 # CHECK: 0x00000017: DW_TAG_type_unit
248 .section .debug_line,"",@progbits
249 # CHECK-LABEL: .debug_line contents:
251 # DWARF v4 line-table header.
253 .long LH_4_end-LH_4_version # Length of Unit
255 .short 4 # DWARF version number
256 .long LH_4_header_end-LH_4_params # Length of Prologue
258 .byte 1 # Minimum Instruction Length
259 .byte 1 # Maximum Operations per Instruction
260 .byte 1 # Default is_stmt
262 .byte 14 # Line Range
263 .byte 13 # Opcode Base
264 .byte 0 # Standard Opcode Lengths
281 .asciz "File4a" # File name 1
282 .byte 1 # Directory index 1
283 .byte 0x41 # Timestamp 1
284 .byte 0x42 # File Size 1
285 .asciz "File4b" # File name 2
286 .byte 0 # Directory index 2
287 .byte 0x43 # Timestamp 2
288 .byte 0x44 # File Size 2
289 .byte 0 # End of list
291 # Line number program, which is empty.
294 # CHECK: Line table prologue:
296 # CHECK-NOT: address_size
297 # CHECK-NOT: seg_select_size
298 # CHECK: max_ops_per_inst: 1
299 # CHECK: include_directories[ 1] = "Directory4a"
300 # CHECK: include_directories[ 2] = "Directory4b"
301 # CHECK-NOT: include_directories
302 # CHECK: file_names[ 1]:
303 # CHECK-NEXT: name: "File4a"
304 # CHECK-NEXT: dir_index: 1
305 # CHECK-NEXT: mod_time: 0x00000041
306 # CHECK-NEXT: length: 0x00000042
307 # CHECK: file_names[ 2]:
308 # CHECK-NEXT: name: "File4b"
309 # CHECK-NEXT: dir_index: 0
310 # CHECK-NEXT: mod_time: 0x00000043
311 # CHECK-NEXT: length: 0x00000044
312 # CHECK-NOT: file_names
314 # DWARF v5 line-table header.
316 .long LH_5_end-LH_5_version # Length of Unit
318 .short 5 # DWARF version number
319 .byte 8 # Address Size
320 .byte 0 # Segment Selector Size
321 .long LH_5_header_end-LH_5_params # Length of Prologue
323 .byte 1 # Minimum Instruction Length
324 .byte 1 # Maximum Operations per Instruction
325 .byte 1 # Default is_stmt
327 .byte 14 # Line Range
328 .byte 13 # Opcode Base
329 .byte 0 # Standard Opcode Lengths
341 # Directory table format
342 .byte 1 # One element per directory entry
343 .byte 1 # DW_LNCT_path
344 .byte 0x0e # DW_FORM_strp (-> .debug_str)
345 # Directory table entries
346 .byte 2 # Two directories
350 .byte 3 # Three elements per file entry
351 .byte 1 # DW_LNCT_path
352 .byte 0x1f # DW_FORM_line_strp (-> .debug_line_str)
353 .byte 2 # DW_LNCT_directory_index
354 .byte 0x0b # DW_FORM_data1
355 .byte 5 # DW_LNCT_MD5
356 .byte 0x1e # DW_FORM_data16
361 .quad 0x7766554433221100
362 .quad 0xffeeddccbbaa9988
365 .quad 0x8899aabbccddeeff
366 .quad 0x0011223344556677
368 # Line number program, which is empty.
371 # CHECK: Line table prologue:
373 # CHECK: address_size: 8
374 # CHECK: seg_select_size: 0
375 # CHECK: max_ops_per_inst: 1
376 # Mixing .debug_str (here) with .debug_line_str (in file_names) is not
377 # something a producer would do, but both are legal and we want to test them.
378 # CHECK: include_directories[ 0] = .debug_str[0x00000045] = "Directory5a"
379 # CHECK: include_directories[ 1] = .debug_str[0x00000051] = "Directory5b"
380 # CHECK-NOT: include_directories
381 # CHECK: file_names[ 0]:
382 # CHECK-NEXT: name: .debug_line_str[0x00000000] = "File5a"
383 # CHECK-NEXT: dir_index: 0
384 # CHECK-NEXT: md5_checksum: 00112233445566778899aabbccddeeff
385 # CHECK: file_names[ 1]:
386 # CHECK-NEXT: name: .debug_line_str[0x00000007] = "File5b"
387 # CHECK-NEXT: dir_index: 1
388 # CHECK-NEXT: md5_checksum: ffeeddccbbaa99887766554433221100
389 # CHECK-NOT: file_names
391 .section .debug_line_str,"MS",@progbits,1
397 .section .debug_line.dwo,"e",@progbits
398 # CHECK-LABEL: .debug_line.dwo
400 # DWARF v5 DWO line-table header.
402 .long dwo_LH_5_end-dwo_LH_5_version # Length of Unit
404 .short 5 # DWARF version number
405 .byte 8 # Address Size
406 .byte 0 # Segment Selector Size
407 .long dwo_LH_5_header_end-dwo_LH_5_params # Length of Prologue
409 .byte 1 # Minimum Instruction Length
410 .byte 1 # Maximum Operations per Instruction
411 .byte 1 # Default is_stmt
413 .byte 14 # Line Range
414 .byte 13 # Opcode Base
415 .byte 0 # Standard Opcode Lengths
427 # Directory table format
428 .byte 1 # One element per directory entry
429 .byte 1 # DW_LNCT_path
430 .byte 0x25 # DW_FORM_strx1 (-> .debug_str.dwo)
431 # Directory table entries
432 .byte 2 # Two directories
436 .byte 4 # Four elements per file entry
437 .byte 1 # DW_LNCT_path
438 .byte 0x08 # DW_FORM_string
439 .byte 2 # DW_LNCT_directory_index
440 .byte 0x0b # DW_FORM_data1
441 .byte 3 # DW_LNCT_timestamp
442 .byte 0x0f # DW_FORM_udata
443 .byte 4 # DW_LNCT_size
444 .byte 0x0f # DW_FORM_udata
456 # Line number program, which is empty.
459 # CHECK: Line table prologue:
461 # CHECK: address_size: 8
462 # CHECK: seg_select_size: 0
463 # CHECK: max_ops_per_inst: 1
464 # CHECK: include_directories[ 0] = indexed (00000003) string = "DWODirectory5a"
465 # CHECK: include_directories[ 1] = indexed (00000004) string = "DWODirectory5b"
466 # CHECK-NOT: include_directories
467 # CHECK: file_names[ 0]:
468 # CHECK-NEXT: name: "DWOFile5a"
469 # CHECK-NEXT: dir_index: 0
470 # CHECK-NEXT: mod_time: 0x00000015
471 # CHECK-NEXT: length: 0x00000025
472 # CHECK: file_names[ 1]:
473 # CHECK-NEXT: name: "DWOFile5b"
474 # CHECK-NEXT: dir_index: 1
475 # CHECK-NEXT: mod_time: 0x00000035
476 # CHECK-NEXT: length: 0x00000045
477 # CHECK-NOT: file_names
479 # VERIFY: Verifying .debug_types