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,"MS",@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 # All CUs/TUs use the same abbrev section for simplicity.
36 .section .debug_abbrev,"",@progbits
37 .byte 0x01 # Abbrev code
38 .byte 0x11 # DW_TAG_compile_unit
39 .byte 0x00 # DW_CHILDREN_no
40 .byte 0x25 # DW_AT_producer
41 .byte 0x0e # DW_FORM_strp
42 .byte 0x03 # DW_AT_name
43 .byte 0x0e # DW_FORM_strp
44 .byte 0x10 # DW_AT_stmt_list
45 .byte 0x17 # DW_FORM_sec_offset
48 .byte 0x02 # Abbrev code
49 .byte 0x41 # DW_TAG_type_unit
50 .byte 0x01 # DW_CHILDREN_yes
51 .byte 0x03 # DW_AT_name
52 .byte 0x0e # DW_FORM_strp
55 .byte 0x03 # Abbrev code
56 .byte 0x13 # DW_TAG_structure_type
57 .byte 0x00 # DW_CHILDREN_no (no members)
58 .byte 0x03 # DW_AT_name
59 .byte 0x0e # DW_FORM_strp
64 # And a .dwo copy for the .dwo sections.
65 .section .debug_abbrev.dwo,"",@progbits
66 .byte 0x01 # Abbrev code
67 .byte 0x11 # DW_TAG_compile_unit
68 .byte 0x00 # DW_CHILDREN_no
69 .byte 0x25 # DW_AT_producer
70 .byte 0x0e # DW_FORM_strp
71 .byte 0x03 # DW_AT_name
72 .byte 0x0e # DW_FORM_strp
73 .byte 0x10 # DW_AT_stmt_list
74 .byte 0x17 # DW_FORM_sec_offset
77 .byte 0x02 # Abbrev code
78 .byte 0x41 # DW_TAG_type_unit
79 .byte 0x01 # DW_CHILDREN_yes
80 .byte 0x03 # DW_AT_name
81 .byte 0x0e # DW_FORM_strp
84 .byte 0x03 # Abbrev code
85 .byte 0x13 # DW_TAG_structure_type
86 .byte 0x00 # DW_CHILDREN_no (no members)
87 .byte 0x03 # DW_AT_name
88 .byte 0x0e # DW_FORM_strp
93 .section .debug_info,"",@progbits
94 # CHECK-LABEL: .debug_info contents:
96 # DWARF v4 CU header. V4 CU headers all look the same so we do only one.
97 .long CU_4_end-CU_4_version # Length of Unit
99 .short 4 # DWARF version number
100 .long .debug_abbrev # Offset Into Abbrev. Section
101 .byte 8 # Address Size (in bytes)
102 # The compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
110 # CHECK: 0x00000000: Compile Unit: length = 0x00000015 version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000019)
111 # CHECK: 0x0000000b: DW_TAG_compile_unit
113 # DWARF v5 normal CU header.
114 .long CU_5_end-CU_5_version # Length of Unit
116 .short 5 # DWARF version number
117 .byte 1 # DWARF Unit Type
118 .byte 8 # Address Size (in bytes)
119 .long .debug_abbrev # Offset Into Abbrev. Section
120 # The compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
128 # CHECK: 0x00000019: Compile Unit: length = 0x00000016 version = 0x0005 unit_type = DW_UT_compile abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000033)
129 # CHECK: 0x00000025: DW_TAG_compile_unit
131 .section .debug_info.dwo,"",@progbits
132 # CHECK-LABEL: .debug_info.dwo
134 # DWARF v5 split CU header.
135 .long CU_split_5_end-CU_split_5_version # Length of Unit
137 .short 5 # DWARF version number
138 .byte 5 # DWARF Unit Type
139 .byte 8 # Address Size (in bytes)
140 .long .debug_abbrev.dwo # Offset Into Abbrev. Section
142 # The split compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
150 # CHECK: 0x00000000: Compile Unit: length = 0x0000001e version = 0x0005 unit_type = DW_UT_split_compile abbr_offset = 0x0000 addr_size = 0x08 DWO_id = 0x000000000000005a (next unit at 0x00000022)
151 # CHECK: 0x00000014: DW_TAG_compile_unit
152 # CHECK-NEXT: DW_AT_producer {{.*}} "Handmade DWO producer"
153 # CHECK-NEXT: DW_AT_name {{.*}} "V5_dwo_compile_unit"
155 # Now a DWARF v5 type unit, which goes in a .debug_info.dwo comdat.
156 # Note there will not be another ".debug_info.dwo contents:" line, even though
157 # there is a separate ELF section header; it's dumped along with the previous
158 # unit as if they were in a single section.
160 .section .debug_info.dwo,"G",@progbits,5555,comdat
161 # CHECK-NOT: .debug_info.dwo
163 # DWARF v5 split type unit header.
165 .long TU_split_5_end-TU_split_5_version # Length of Unit
167 .short 5 # DWARF version number
168 .byte 6 # DWARF Unit Type
169 .byte 8 # Address Size (in bytes)
170 .long .debug_abbrev.dwo # Offset Into Abbrev. Section
171 .quad 0x8899aabbccddeeff # Type Signature
172 .long TU_split_5_type-TU_split_5_start # Type offset
173 # The type-unit DIE, which has a name.
176 # The type DIE, which has a name.
184 # CHECK: 0x00000000: Type Unit: length = 0x00000020 version = 0x0005 unit_type = DW_UT_split_type abbr_offset = 0x0000 addr_size = 0x08 name = 'V5_split_type_unit' type_signature = 0x8899aabbccddeeff type_offset = 0x001d (next unit at 0x00000024)
185 # CHECK: 0x00000018: DW_TAG_type_unit
187 .section .debug_types,"",@progbits
188 # CHECK-LABEL: .debug_types contents:
190 # DWARF v4 Type unit header. Normal/split are identical so we do only one.
192 .long TU_4_end-TU_4_version # Length of Unit
194 .short 4 # DWARF version number
195 .long .debug_abbrev # Offset Into Abbrev. Section
196 .byte 8 # Address Size (in bytes)
197 .quad 0x0011223344556677 # Type Signature
198 .long TU_4_type-TU_4_start # Type offset
199 # The type-unit DIE, which has a name.
202 # The type DIE, which has a name.
210 # CHECK: 0x00000000: Type Unit: length = 0x0000001f version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 name = 'V4_type_unit' type_signature = 0x0011223344556677 type_offset = 0x001c (next unit at 0x00000023)
211 # CHECK: 0x00000017: DW_TAG_type_unit
213 .section .debug_line,"",@progbits
214 # CHECK-LABEL: .debug_line contents:
216 # DWARF v4 line-table header.
218 .long LH_4_end-LH_4_version # Length of Unit
220 .short 4 # DWARF version number
221 .long LH_4_header_end-LH_4_params # Length of Prologue
223 .byte 1 # Minimum Instruction Length
224 .byte 1 # Maximum Operations per Instruction
225 .byte 1 # Default is_stmt
227 .byte 14 # Line Range
228 .byte 13 # Opcode Base
229 .byte 0 # Standard Opcode Lengths
246 .asciz "File4a" # File name 1
247 .byte 1 # Directory index 1
248 .byte 0x41 # Timestamp 1
249 .byte 0x42 # File Size 1
250 .asciz "File4b" # File name 2
251 .byte 0 # Directory index 2
252 .byte 0x43 # Timestamp 2
253 .byte 0x44 # File Size 2
254 .byte 0 # End of list
256 # Line number program, which is empty.
259 # CHECK: Line table prologue:
261 # CHECK-NOT: address_size
262 # CHECK-NOT: seg_select_size
263 # CHECK: max_ops_per_inst: 1
264 # CHECK: include_directories[ 1] = "Directory4a"
265 # CHECK: include_directories[ 2] = "Directory4b"
266 # CHECK-NOT: include_directories
267 # CHECK: file_names[ 1]:
268 # CHECK-NEXT: name: "File4a"
269 # CHECK-NEXT: dir_index: 1
270 # CHECK-NEXT: mod_time: 0x00000041
271 # CHECK-NEXT: length: 0x00000042
272 # CHECK: file_names[ 2]:
273 # CHECK-NEXT: name: "File4b"
274 # CHECK-NEXT: dir_index: 0
275 # CHECK-NEXT: mod_time: 0x00000043
276 # CHECK-NEXT: length: 0x00000044
277 # CHECK-NOT: file_names
279 # DWARF v5 line-table header.
281 .long LH_5_end-LH_5_version # Length of Unit
283 .short 5 # DWARF version number
284 .byte 8 # Address Size
285 .byte 0 # Segment Selector Size
286 .long LH_5_header_end-LH_5_params # Length of Prologue
288 .byte 1 # Minimum Instruction Length
289 .byte 1 # Maximum Operations per Instruction
290 .byte 1 # Default is_stmt
292 .byte 14 # Line Range
293 .byte 13 # Opcode Base
294 .byte 0 # Standard Opcode Lengths
306 # Directory table format
307 .byte 1 # One element per directory entry
308 .byte 1 # DW_LNCT_path
309 .byte 0x0e # DW_FORM_strp (-> .debug_str)
310 # Directory table entries
311 .byte 2 # Two directories
315 .byte 3 # Three elements per file entry
316 .byte 1 # DW_LNCT_path
317 .byte 0x1f # DW_FORM_line_strp (-> .debug_line_str)
318 .byte 2 # DW_LNCT_directory_index
319 .byte 0x0b # DW_FORM_data1
320 .byte 5 # DW_LNCT_MD5
321 .byte 0x1e # DW_FORM_data16
326 .quad 0x7766554433221100
327 .quad 0xffeeddccbbaa9988
330 .quad 0x8899aabbccddeeff
331 .quad 0x0011223344556677
333 # Line number program, which is empty.
336 # CHECK: Line table prologue:
338 # CHECK: address_size: 8
339 # CHECK: seg_select_size: 0
340 # CHECK: max_ops_per_inst: 1
341 # Mixing .debug_str (here) with .debug_line_str (in file_names) is not
342 # something a producer would do, but both are legal and we want to test them.
343 # CHECK: include_directories[ 0] = .debug_str[0x00000045] = "Directory5a"
344 # CHECK: include_directories[ 1] = .debug_str[0x00000051] = "Directory5b"
345 # CHECK-NOT: include_directories
346 # CHECK: file_names[ 0]:
347 # CHECK-NEXT: name: .debug_line_str[0x00000000] = "File5a"
348 # CHECK-NEXT: dir_index: 0
349 # CHECK-NEXT: md5_checksum: 00112233445566778899aabbccddeeff
350 # CHECK: file_names[ 1]:
351 # CHECK-NEXT: name: .debug_line_str[0x00000007] = "File5b"
352 # CHECK-NEXT: dir_index: 1
353 # CHECK-NEXT: md5_checksum: ffeeddccbbaa99887766554433221100
354 # CHECK-NOT: file_names
356 .section .debug_line_str,"MS",@progbits,1
362 .section .debug_line.dwo,"",@progbits
363 # CHECK-LABEL: .debug_line.dwo
365 # DWARF v5 DWO line-table header.
367 .long dwo_LH_5_end-dwo_LH_5_version # Length of Unit
369 .short 5 # DWARF version number
370 .byte 8 # Address Size
371 .byte 0 # Segment Selector Size
372 .long dwo_LH_5_header_end-dwo_LH_5_params # Length of Prologue
374 .byte 1 # Minimum Instruction Length
375 .byte 1 # Maximum Operations per Instruction
376 .byte 1 # Default is_stmt
378 .byte 14 # Line Range
379 .byte 13 # Opcode Base
380 .byte 0 # Standard Opcode Lengths
392 # Directory table format
393 .byte 1 # One element per directory entry
394 .byte 1 # DW_LNCT_path
395 .byte 0x0e # DW_FORM_strp (-> .debug_str.dwo)
396 # Directory table entries
397 .byte 2 # Two directories
401 .byte 4 # Four elements per file entry
402 .byte 1 # DW_LNCT_path
403 .byte 0x08 # DW_FORM_string
404 .byte 2 # DW_LNCT_directory_index
405 .byte 0x0b # DW_FORM_data1
406 .byte 3 # DW_LNCT_timestamp
407 .byte 0x0f # DW_FORM_udata
408 .byte 4 # DW_LNCT_size
409 .byte 0x0f # DW_FORM_udata
421 # Line number program, which is empty.
424 # CHECK: Line table prologue:
426 # CHECK: address_size: 8
427 # CHECK: seg_select_size: 0
428 # CHECK: max_ops_per_inst: 1
429 # CHECK: include_directories[ 0] = .debug_str[0x0000003d] = "DWODirectory5a"
430 # CHECK: include_directories[ 1] = .debug_str[0x0000004c] = "DWODirectory5b"
431 # CHECK-NOT: include_directories
432 # CHECK: file_names[ 0]:
433 # CHECK-NEXT: name: "DWOFile5a"
434 # CHECK-NEXT: dir_index: 0
435 # CHECK-NEXT: mod_time: 0x00000015
436 # CHECK-NEXT: length: 0x00000025
437 # CHECK: file_names[ 1]:
438 # CHECK-NEXT: name: "DWOFile5b"
439 # CHECK-NEXT: dir_index: 1
440 # CHECK-NEXT: mod_time: 0x00000035
441 # CHECK-NEXT: length: 0x00000045
442 # CHECK-NOT: file_names
444 # VERIFY: Verifying .debug_types