1 ## Test that yaml2obj emits .debug_info section.
3 ## a) Generate the .debug_info section from the "DWARF" entry.
5 ## Generate and verify a DWARF32 little endian .debug_info (DWARFv5) section.
7 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o
8 # RUN: llvm-readobj --sections --section-data %t1.le.o | \
9 # RUN: FileCheck -DINDEX=2 -DNAME=15 -DOFFSET=0x9B -DSIZE=179 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE-CONTENT
11 # SHDR: Index: [[INDEX]]
12 # SHDR-NEXT: Name: .debug_info ([[NAME]])
13 # SHDR-NEXT: Type: SHT_PROGBITS (0x1)
14 # SHDR-NEXT: Flags [ (0x0)
16 # SHDR-NEXT: Address: 0x0
17 # SHDR-NEXT: Offset: [[OFFSET]]
18 # SHDR-NEXT: Size: [[SIZE]]
21 # SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]
22 # SHDR-NEXT: EntrySize: 0
23 # DWARF32-LE-CONTENT-NEXT: SectionData (
24 # DWARF32-LE-CONTENT-NEXT: 0000: 34120000 05000304 34120000 01785634
25 ## ^------- unit_length (4-byte)
26 ## ^--- version (2-byte)
27 ## ^- unit_type (1-byte) DW_UT_type
28 ## ^- address_size (1-byte)
29 ## ^------- debug_abbrev_offset (4-byte)
30 ## ^- abbreviation code (LEB128) 0x01
31 ## ^----- Form: DW_FORM_addr (4-byte)
32 # DWARF32-LE-CONTENT-NEXT: 0010: 12020012 34020000 00123434 12785634
34 ## ^--- Form: DW_FORM_block2 size (2-byte)
35 ## ^- ^- Form: DW_FORM_block2 body (2-byte)
36 ## ^-------- Form: DW_FORM_block4 size (4-byte)
37 ## ^-^- Form: DW_FORM_block4 body (2-byte)
38 ## ^---- Form: DW_FORM_data2 (2-byte)
39 ## ^----- Form: DW_FORM_data4 (4-byte)
40 # DWARF32-LE-CONTENT-NEXT: 0020: 12F0DEBC 9A785634 12616263 64000212
42 ## ^----------------- Form: DW_FORM_data8 (8-byte)
43 ## ^---------- Form: DW_FORM_string "abcd\0"
44 ## ^- Form: DW_FORM_block size (ULEB128)
45 ## ^- Form: DW_FORM_block body (2-byte)
46 # DWARF32-LE-CONTENT-NEXT: 0030: 34021234 1201B424 78563412 B4247856
47 ## ^- Form: DW_FORM_block body
48 ## ^- Form: DW_FORM_block1 size (1-byte)
49 ## ^-^- Form: DW_FORM_block1 body (2-byte)
50 ## ^- Form: DW_FORM_data1 (1-byte)
51 ## ^- Form: DW_FORM_flag (1-byte)
52 ## ^--- Form: DW_FORM_sdata (SLEB128) 0x1234
53 ## ^------- Form: DW_FORM_strp (4-byte)
54 ## ^--- Form: DW_FORM_udata (ULEB128) 0x1234
55 ## ^--- Form: DW_FORM_ref_addr (4-byte)
56 # DWARF32-LE-CONTENT-NEXT: 0040: 34121234 12785634 12F0DEBC 9A785634
58 ## ^- Form: DW_FORM_ref1 (1-byte)
59 ## ^---- Form: DW_FORM_ref2 (2-byte)
60 ## ^-------- Form: DW_FORM_ref4 (4-byte)
61 ## ^-------------- Form: DW_FORM_ref8 (8-byte)
62 # DWARF32-LE-CONTENT-NEXT: 0050: 12B42408 65666768 00341200 00021234
64 ## ^--- Form: DW_FORM_ref_udata (ULEB128) 0x1234
65 ## ^- Form: DW_FORM_indirect (ULEB128) DW_FORM_string
66 ## ^---------- "efgh\0"
67 ## ^-------- Form: DW_FORM_sec_offset (4-byte)
68 ## ^- Form: DW_FORM_exprloc size (ULEB128) 0x02
69 ## ^-^- Form: DW_FORM_exprloc body (2-byte)
70 # DWARF32-LE-CONTENT-NEXT: 0060: B424B424 78563412 78563412 78563412
71 ## ^--- Form: DW_FORM_strx (ULEB128)
72 ## ^--- Form: DW_FORM_addrx (ULEB128)
73 ## ^------- Form: DW_FORM_ref_sup4 (4-byte)
74 ## ^------- Form: DW_FORM_strp_sup (4-byte)
75 ## ^------- Form: DW_FORM_line_strp (4-byte)
76 # DWARF32-LE-CONTENT-NEXT: 0070: F0DEBC9A 78563412 B424B424 F0DEBC9A
77 ## ^---------------- Form: DW_FORM_ref_sig8 (8-byte)
78 ## ^--- Form: DW_FORM_loclistx (ULEB128)
79 ## ^--- Form: DW_FORM_rnglistx (ULEB128)
80 ## ^------- Form: DW_FORM_ref_sup8 (8-byte)
81 # DWARF32-LE-CONTENT-NEXT: 0080: 78563412 12341278 56341212 34127856
83 ## ^- Form: DW_FORM_strx1 (1-byte)
84 ## ^--- Form: DW_FORM_strx2 (2-byte)
85 ## ^-------- Form: DW_FORM_strx4 (4-byte)
86 ## ^- Form: DW_FORM_addrx1 (1-byte)
87 ## ^--- Form: DW_FORM_addrx2 (1-byte)
88 ## ^--- Form: DW_FORM_addrx4 (4-byte)
89 # DWARF32-LE-CONTENT-NEXT: 0090: 34123412 00000500 01043412 00000078
91 ## ^-------- unit_length (4-byte)
92 ## ^--- version (2-byte)
93 ## ^- unit_type (1-byte)
94 ## ^- address_size (1-byte)
95 ## ^-------- debug_abbrev_offset (4-byte)
96 ## ^- abbrev code (ULEB128) 0x00
97 ## ^- unit_length (4-byte)
98 # DWARF32-LE-CONTENT-NEXT: 00A0: 56000004 00785600 00040178 56341202
100 ## ^---- version (2-byte)
101 ## ^-------- debug_abbrev_offset (4-byte)
102 ## ^- address_size (1-byte)
103 ## ^- abbrev code (ULEB128) 0x01
104 ## ^-------- Form: DW_FORM_addr
105 ## ^- Form: DW_FORM_block2 size (2-byte)
106 # DWARF32-LE-CONTENT-NEXT: 00B0: 001234
108 ## ^-^- Form: DW_FORM_block2 body (2-byte)
109 # DWARF32-LE-CONTENT-NEXT: )
120 Tag: DW_TAG_compile_unit
121 Children: DW_CHILDREN_no
124 Form: DW_FORM_addr ## 0x01
126 Form: DW_FORM_block2 ## 0x03
128 Form: DW_FORM_block4 ## 0x04
130 Form: DW_FORM_data2 ## 0x05
132 Form: DW_FORM_data4 ## 0x06
134 Form: DW_FORM_data8 ## 0x07
136 Form: DW_FORM_string ## 0x08
138 Form: DW_FORM_block ## 0x09
140 Form: DW_FORM_block1 ## 0x0a
142 Form: DW_FORM_data1 ## 0x0b
144 Form: DW_FORM_flag ## 0x0c
146 Form: DW_FORM_sdata ## 0x0d
148 Form: DW_FORM_strp ## 0x0e
150 Form: DW_FORM_udata ## 0x0f
152 Form: DW_FORM_ref_addr ## 0x10
154 Form: DW_FORM_ref1 ## 0x11
156 Form: DW_FORM_ref2 ## 0x12
158 Form: DW_FORM_ref4 ## 0x13
160 Form: DW_FORM_ref8 ## 0x14
162 Form: DW_FORM_ref_udata ## 0x15
164 Form: DW_FORM_indirect ## 0x16
166 Form: DW_FORM_sec_offset ## 0x17
168 Form: DW_FORM_exprloc ## 0x18
170 Form: DW_FORM_strx ## 0x1a
172 Form: DW_FORM_addrx ## 0x1b
174 Form: DW_FORM_ref_sup4 ## 0x1c
176 Form: DW_FORM_strp_sup ## 0x1d
178 Form: DW_FORM_data16 ## 0x1e
180 Form: DW_FORM_line_strp ## 0x1f
182 Form: DW_FORM_ref_sig8 ## 0x20
184 Form: DW_FORM_implicit_const ## 0x21
187 Form: DW_FORM_loclistx ## 0x22
189 Form: DW_FORM_rnglistx ## 0x23
191 Form: DW_FORM_ref_sup8 ## 0x24
193 Form: DW_FORM_strx1 ## 0x25
195 Form: DW_FORM_strx2 ## 0x26
197 Form: DW_FORM_strx3 ## 0x27
199 Form: DW_FORM_strx4 ## 0x28
201 Form: DW_FORM_addrx1 ## 0x29
203 Form: DW_FORM_addrx2 ## 0x2a
205 Form: DW_FORM_addrx3 ## 0x2b
207 Form: DW_FORM_addrx4 ## 0x2c
211 UnitType: DW_UT_partial
217 - Value: 0x12345678 ## DW_FORM_addr
218 - BlockData: ## DW_FORM_block2
221 - BlockData: ## DW_FORM_block4
224 - Value: 0x1234 ## DW_FORM_data2
225 - Value: 0x12345678 ## DW_FORM_data4
226 - Value: 0x123456789abcdef0 ## DW_FORM_data8
227 - CStr: abcd ## DW_FORM_string
228 - BlockData: ## DW_FORM_block
231 - BlockData: ## DW_FORM_block1
234 - Value: 0x12 ## DW_FORM_data1
235 - Value: 0x01 ## DW_FORM_flag
236 - Value: 0x1234 ## DW_FORM_sdata
237 - Value: 0x12345678 ## DW_FORM_strp
238 - Value: 0x1234 ## DW_FORM_udata
239 - Value: 0x12345678 ## DW_FORM_ref_addr
240 - Value: 0x12 ## DW_FORM_ref1
241 - Value: 0x1234 ## DW_FORM_ref2
242 - Value: 0x12345678 ## DW_FORM_ref4
243 - Value: 0x123456789abcdef0 ## DW_FORM_ref8
244 - Value: 0x1234 ## DW_FORM_ref_udata
245 - Value: 0x08 ## DW_FORM_indirect. The following value's form is 0x08, which is DW_FORM_string.
247 - Value: 0x1234 ## DW_FORM_sec_offset
248 - BlockData: ## DW_FORM_exprloc
251 - Value: 0x1234 ## DW_FORM_strx
252 - Value: 0x1234 ## DW_FORM_addrx
253 - Value: 0x12345678 ## DW_FORM_ref_sup4
254 - Value: 0x12345678 ## DW_FORM_strp_sup
255 - Value: 0x1234 ## DW_FORM_data16 (unimplemented)
256 - Value: 0x12345678 ## DW_FORM_line_strp
257 - Value: 0x123456789abcdef0 ## DW_FORM_ref_sig8
258 - Value: 0x1234 ## DW_FORM_implicit_const (unimplemented)
259 - Value: 0x1234 ## DW_FORM_loclistx
260 - Value: 0x1234 ## DW_FORM_rnglistx
261 - Value: 0x123456789abcdef0 ## DW_FORM_ref_sup8
262 - Value: 0x12 ## DW_FORM_strx1
263 - Value: 0x1234 ## DW_FORM_strx2
264 - Value: 0x123456 ## DW_FORM_strx3 (unimplemented)
265 - Value: 0x12345678 ## DW_FORM_strx4
266 - Value: 0x12 ## DW_FORM_addrx1
267 - Value: 0x1234 ## DW_FORM_addrx2
268 - Value: 0x123456 ## DW_FORM_addrx3 (unimplemented)
269 - Value: 0x12345678 ## DW_FORM_addrx4
272 ## Test another unit type.
273 UnitType: DW_UT_compile
288 - Value: 0x12345678 ## DW_FORM_addr
289 - BlockData: ## DW_FORM_block2
293 ## Generate and verify a DWARF32 big endian .debug_info (DWARFv4) section.
295 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o
296 # RUN: llvm-readobj --sections --section-data %t1.be.o | \
297 # RUN: FileCheck -DINDEX=2 -DNAME=15 -DOFFSET=0x9B -DSIZE=179 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE-CONTENT
299 # DWARF32-BE-CONTENT-NEXT: SectionData (
300 # DWARF32-BE-CONTENT-NEXT: 0000: 00001234 00050304 00001234 01123456
301 ## ^------- unit_length (4-byte)
302 ## ^--- version (2-byte)
303 ## ^- unit_type (1-byte) DW_UT_type
304 ## ^- address_size (1-byte)
305 ## ^------- debug_abbrev_offset (4-byte)
306 ## ^- abbreviation code (LEB128) 0x01
307 ## ^----- Form: DW_FORM_addr (4-byte)
308 # DWARF32-BE-CONTENT-NEXT: 0010: 78000212 34000000 02123412 34123456
310 ## ^--- Form: DW_FORM_block2 size (2-byte)
311 ## ^- ^- Form: DW_FORM_block2 body (2-byte)
312 ## ^-------- Form: DW_FORM_block4 size (4-byte)
313 ## ^-^- Form: DW_FORM_block4 body (2-byte)
314 ## ^---- Form: DW_FORM_data2 (2-byte)
315 ## ^----- Form: DW_FORM_data4 (4-byte)
316 # DWARF32-BE-CONTENT-NEXT: 0020: 78123456 789ABCDE F0616263 64000212
318 ## ^----------------- Form: DW_FORM_data8 (8-byte)
319 ## ^---------- Form: DW_FORM_string "abcd\0"
320 ## ^- Form: DW_FORM_block size (ULEB128)
321 ## ^- Form: DW_FORM_block body (2-byte)
322 # DWARF32-BE-CONTENT-NEXT: 0030: 34021234 1201B424 12345678 B4241234
323 ## ^- Form: DW_FORM_block body
324 ## ^- Form: DW_FORM_block1 size (1-byte)
325 ## ^-^- Form: DW_FORM_block1 body (2-byte)
326 ## ^- Form: DW_FORM_data1 (1-byte)
327 ## ^- Form: DW_FORM_flag (1-byte)
328 ## ^--- Form: DW_FORM_sdata (SLEB128) 0x1234
329 ## ^------- Form: DW_FORM_strp (4-byte)
330 ## ^--- Form: DW_FORM_udata (ULEB128) 0x1234
331 ## ^--- Form: DW_FORM_ref_addr (4-byte)
332 # DWARF32-BE-CONTENT-NEXT: 0040: 56781212 34123456 78123456 789ABCDE
334 ## ^- Form: DW_FORM_ref1 (1-byte)
335 ## ^---- Form: DW_FORM_ref2 (2-byte)
336 ## ^-------- Form: DW_FORM_ref4 (4-byte)
337 ## ^-------------- Form: DW_FORM_ref8 (8-byte)
338 # DWARF32-BE-CONTENT-NEXT: 0050: F0B42408 65666768 00000012 34021234
340 ## ^--- Form: DW_FORM_ref_udata (ULEB128) 0x1234
341 ## ^- Form: DW_FORM_indirect (ULEB128) DW_FORM_string
342 ## ^---------- "efgh\0"
343 ## ^-------- Form: DW_FORM_sec_offset (4-byte)
344 ## ^- Form: DW_FORM_exprloc size (ULEB128) 0x02
345 ## ^-^- Form: DW_FORM_exprloc body (2-byte)
346 # DWARF32-BE-CONTENT-NEXT: 0060: B424B424 12345678 12345678 12345678
347 ## ^--- Form: DW_FORM_strx (ULEB128)
348 ## ^--- Form: DW_FORM_addrx (ULEB128)
349 ## ^------- Form: DW_FORM_ref_sup4 (4-byte)
350 ## ^------- Form: DW_FORM_strp_sup (4-byte)
351 ## ^------- Form: DW_FORM_line_strp (4-byte)
352 # DWARF32-BE-CONTENT-NEXT: 0070: 12345678 9ABCDEF0 B424B424 12345678
353 ## ^---------------- Form: DW_FORM_ref_sig8 (8-byte)
354 ## ^--- Form: DW_FORM_loclistx (ULEB128)
355 ## ^--- Form: DW_FORM_rnglistx (ULEB128)
356 ## ^------- Form: DW_FORM_ref_sup8 (8-byte)
357 # DWARF32-BE-CONTENT-NEXT: 0080: 9ABCDEF0 12123412 34567812 12341234
359 ## ^- Form: DW_FORM_strx1 (1-byte)
360 ## ^--- Form: DW_FORM_strx2 (2-byte)
361 ## ^-------- Form: DW_FORM_strx4 (4-byte)
362 ## ^- Form: DW_FORM_addrx1 (1-byte)
363 ## ^--- Form: DW_FORM_addrx2 (1-byte)
364 ## ^--- Form: DW_FORM_addrx4 (4-byte)
365 # DWARF32-BE-CONTENT-NEXT: 0090: 56780000 12340005 01040000 12340000
367 ## ^-------- unit_length (4-byte)
368 ## ^--- version (2-byte)
369 ## ^- unit_type (1-byte)
370 ## ^- address_size (1-byte)
371 ## ^-------- debug_abbrev_offset (4-byte)
372 ## ^- abbrev code (ULEB128) 0x00
373 ## ^- unit_length (4-byte)
374 # DWARF32-BE-CONTENT-NEXT: 00A0: 00567800 04000056 78040112 34567800
376 ## ^---- version (2-byte)
377 ## ^-------- debug_abbrev_offset (4-byte)
378 ## ^- address_size (1-byte)
379 ## ^- abbrev code (ULEB128) 0x01
380 ## ^-------- Form: DW_FORM_addr
381 ## ^- Form: DW_FORM_block2 size (2-byte)
382 # DWARF32-BE-CONTENT-NEXT: 00B0: 021234
384 ## ^-^- Form: DW_FORM_block2 body (2-byte)
385 # DWARF32-BE-CONTENT-NEXT: )
387 ## b) Generate the .debug_info section from raw section content.
389 # RUN: yaml2obj --docnum=2 %s -o %t2.o
390 # RUN: llvm-readobj --sections --section-data %t2.o | \
391 # RUN: FileCheck -DINDEX=1 -DNAME=1 -DOFFSET=0x40 -DSIZE=3 -DADDRALIGN=0 %s --check-prefixes=SHDR,ARBITRARY-CONTENT
393 # ARBITRARY-CONTENT-NEXT: SectionData (
394 # ARBITRARY-CONTENT-NEXT: 0000: 112233
395 # ARBITRARY-CONTENT-NEXT: )
407 ## c) Generate the .debug_info section when the "Size" is specified.
409 # RUN: yaml2obj --docnum=3 %s -o %t3.o
410 # RUN: llvm-readobj --sections --section-data %t3.o | \
411 # RUN: FileCheck -DINDEX=1 -DNAME=1 -DOFFSET=0x40 -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE
413 # SIZE-NEXT: SectionData (
414 # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000
427 ## d) Test that yaml2obj emits an error message when both the "Size" and the
428 ## "debug_info" entry are specified at the same time.
430 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT
432 # AMBIGUOUS-CONTENT: yaml2obj: error: cannot specify section '.debug_info' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
447 Tag: DW_TAG_compile_unit
448 Children: DW_CHILDREN_no
452 UnitType: DW_UT_compile
456 ## e) Test that yaml2obj emits an error message when both the "Content" and the
457 ## "debug_info" entry are specified at the same time.
459 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT
474 Tag: DW_TAG_compile_unit
475 Children: DW_CHILDREN_no
479 UnitType: DW_UT_compile
483 ## f) Test that all the properties can be overridden by the section header when
484 ## the "debug_info" entry doesn't exist.
486 # RUN: yaml2obj --docnum=6 %s -o %t6.o
487 # RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
489 # OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
490 # OVERRIDDEN: [ 1] .debug_info STRTAB 0000000000002020 000050 00000d 01 A 2 1 2
491 # OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 00005d 000000 00 0 0 0
500 Type: SHT_STRTAB ## SHT_PROGBITS by default.
501 Flags: [SHF_ALLOC] ## 0 by default.
502 Link: .sec ## 0 by default.
503 EntSize: 1 ## 0 by default.
504 Info: 1 ## 0 by default.
505 AddressAlign: 2 ## 0 by default.
506 Address: 0x2020 ## 0x00 by default.
507 Offset: 0x50 ## 0x40 for the first section.
508 Size: 0x0d ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
509 - Name: .sec ## Linked by .debug_info.
512 ## g) Test that all the properties can be overridden by the section header when
513 ## the "debug_info" entry exists.
515 # RUN: yaml2obj --docnum=7 %s -o %t7.o
516 # RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
525 Type: SHT_STRTAB ## SHT_PROGBITS by default.
526 Flags: [SHF_ALLOC] ## 0 by default.
527 Link: .sec ## 0 by default.
528 EntSize: 1 ## 0 by default.
529 Info: 1 ## 0 by default.
530 AddressAlign: 2 ## 0 by default.
531 Address: 0x2020 ## 0x00 by default.
532 Offset: 0x50 ## 0x40 for the first section.
533 - Name: .sec ## Linked by .debug_info.
539 Tag: DW_TAG_compile_unit
540 Children: DW_CHILDREN_no
544 UnitType: DW_UT_compile
550 ## h) Test that yaml2obj doesn't crash when the 'Entries' of a compilation unit is empty.
552 # RUN: yaml2obj --docnum=8 %s -o %t8.o
553 # RUN: llvm-readelf --hex-dump=.debug_info %t8.o | \
554 # RUN: FileCheck %s --check-prefix=EMPTY-ENTRIES --match-full-lines
556 # EMPTY-ENTRIES: Hex dump of section '.debug_info':
557 # EMPTY-ENTRIES-NEXT: 0x00000000 34120000 05000104 34120000 4.......4...
558 # EMPTY-ENTRIES-EMPTY:
559 ## ^- 'Entries' is empty
570 UnitType: DW_UT_compile
574 ## h) Test that yaml2obj emits values in the DIE according to the abbreviation whose
575 ## index is equal to the value in 'AbbrevCode'.
577 # RUN: yaml2obj --docnum=9 %s -o %t9.o
578 # RUN: llvm-readelf --hex-dump=.debug_info %t9.o | \
579 # RUN: FileCheck %s --check-prefix=FORM --match-full-lines
581 # FORM: Hex dump of section '.debug_info':
582 # FORM-NEXT: 0x00000000 34120000 05000104 34120000 02341221 4.......4....4.!
583 ## ^------- unit_length (4-byte)
584 ## ^- abbreviation code (ULEB128)
585 ## ^--- Form: DW_FORM_data2 (2-byte)
586 ## ^- Form: DW_FORM_data4 (4-byte)
587 # FORM-NEXT: 0x00000010 43658701 21436587 341200 Ce..!Ce.4..
589 ## ^- abbreviation code (ULEB128)
590 ## ^------- Form: DW_FORM_data4 (4-byte)
591 ## ^--- Form: DW_FORM_data2 (2-byte)
592 ## ^- abbreviation code (ULEB128)
603 - Tag: DW_TAG_compile_unit
604 Children: DW_CHILDREN_yes
606 - Attribute: DW_AT_low_pc
608 - Attribute: DW_AT_high_pc
610 - Tag: DW_TAG_subprogram
611 Children: DW_CHILDREN_no
613 - Attribute: DW_AT_low_pc
615 - Attribute: DW_AT_high_pc
620 UnitType: DW_UT_compile
623 ## Test that yaml2obj emits values when the abbrev code is specified.
628 ## Test that yaml2obj emits values when the abbrev code is specified to
629 ## be lower than the first abbrev.
634 ## Test that yaml2obj ignores the contents of entries with abbrev code 0.
639 ## i) Test that yaml2obj reports an error when 'debug_info' has values in its
640 ## entries but 'debug_abbrev' doesn't have enough attributes for them.
642 # RUN: not yaml2obj --docnum=10 %s -o %t10.o 2>&1 | \
643 # RUN: FileCheck %s --check-prefixes=ERROR
645 # ERROR: yaml2obj: error: abbrev code must be less than or equal to the number of entries in abbreviation table
658 UnitType: DW_UT_compile
665 ## j) Test that yaml2obj emits the correct DWARFv5 unit headers.
667 # RUN: yaml2obj --docnum=11 %s -o %t11.o
668 # RUN: llvm-readelf --hex-dump=.debug_info %t11.o | \
669 # RUN: FileCheck %s --check-prefix=DWARFV5-HEADER
671 # DWARFV5-HEADER: Hex dump of section '.debug_info':
672 # DWARFV5-HEADER-NEXT: 0x00000000 ffffffff 0d000000 00000000 05000108 ................
673 ## ^------------------------- unit_length (12-byte)
674 ## ^--- version (2-byte)
675 ## ^- unit_type (1-byte)
676 ## ^- address_size (1-byte)
677 # DWARFV5-HEADER-NEXT: 0x00000010 34120000 00000000 00150000 00050002 4...............
678 ## ^---------------- debug_abbrev_offset (8-byte)
679 ## ^- End of children (1-byte)
680 ## ^-------- unit_length (4-byte)
681 ## ^--- version (2-byte)
682 ## ^- unit_type (1-byte)
683 # DWARFV5-HEADER-NEXT: 0x00000020 08341200 000df0ad baefbead de180000 .4..............
684 ## ^- address_size (1-byte)
685 ## ^-------- debug_abbrev_offset (4-byte)
686 ## ^----------------- type_signature (8-byte)
687 ## \/ ^----- type_offset (4-byte)
688 # DWARFV5-HEADER-NEXT: 0x00000030 0000ffff ffff1d00 00000000 00000500 ................
689 ## ^- End of children (1-byte)
690 ## ^-------------------------- unit_length (12-byte)
691 ## ^--- version (2-byte)
692 # DWARFV5-HEADER-NEXT: 0x00000040 02083412 00000000 00000df0 adbaefbe ..4.............
693 ## ^- unit_type (1-byte)
694 ## ^- address_size (1-byte)
695 ## ^----------------- debug_abbrev_offset (8-byte)
696 ## \/-- ^------------ type_signature (8-byte)
697 # DWARFV5-HEADER-NEXT: 0x00000050 adde2800 00000000 00000011 00000005 ..(.............
698 ## ^----------------- type_offset (8-byte)
699 ## ^- End of children (1-byte)
700 ## ^-------- unit_length (4-byte)
701 ## \/ ^- version (2-byte)
702 # DWARFV5-HEADER-NEXT: 0x00000060 00040834 1200000d f0adbaef beadde00 ...4............
703 ## ^- unit_type (1-byte)
704 ## ^- address_size (1-byte)
705 ## ^-------- debug_abbrev_offset (4-byte)
706 ## ^----------------- type_signature (8-byte)
707 ## ^- End of children (1-byte)
720 UnitType: DW_UT_compile
727 TypeSignature: 0xdeadbeefbaadf00d
735 TypeSignature: 0xdeadbeefbaadf00d
740 UnitType: DW_UT_skeleton
742 DwoID: 0xdeadbeefbaadf00d
746 ## DWARFv4 unit header.
748 # RUN: yaml2obj --docnum=12 %s -o %t12.o
749 # RUN: llvm-readelf --hex-dump=.debug_info %t12.o | \
750 # RUN: FileCheck %s --check-prefix=DWARFV4-HEADER
752 # DWARFV4-HEADER: Hex dump of section '.debug_info':
753 # DWARFV4-HEADER-NEXT: 0x00000000 ffffffff 0c000000 00000000 04003412 ..............4.
754 ## ^------------------------- unit_length (12-byte)
755 ## ^--- version (2-byte)
756 ## ^--- debug_abbrev_offset (8-byte)
757 # DWARFV4-HEADER-NEXT: 0x00000010 00000000 000008 .......
759 ## ^- address_size (1-byte)
774 ## k) Test that yaml2obj is able to emit a correct length for compilation units.
776 # RUN: yaml2obj --docnum=13 %s -o %t13.o
777 # RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \
778 # RUN: FileCheck %s --check-prefix=INFER-LENGTH
780 # INFER-LENGTH: Hex dump of section '.debug_info':
781 # INFER-LENGTH-NEXT: 0x00000000 37000000 04000000 00000801 00000000 7...............
782 ## ^------- unit_length (0x37)
783 ## ^--- version (2-byte)
784 ## ^-------- debug_abbrev_offset (4-byte)
785 ## ^- address_size (1-byte)
786 ## ^- abbrev code (ULEB128) 0x01
787 ## ^------- Form: DW_FORM_strp (4-byte)
788 # INFER-LENGTH-NEXT: 0x00000010 0c001600 00000000 00001e00 00002011 .............. .
789 ## ^--- Form: DW_FORM_data2 (2-byte)
790 ## ^-------- Form: DW_FORM_strp (4-byte)
791 ## ^-------- Form: DW_FORM_sec_offset (4-byte)
792 ## ^-------- Form: DW_FORM_strp (4-byte)
793 ## ^--- Form: DW_FORM_addr (8-byte)
794 # INFER-LENGTH-NEXT: 0x00000020 00000000 00003300 00000220 11000000 ......3.... ....
796 ## ^-------- Form: DW_FORM_data4 (4-byte)
797 ## ^- abbrev code (ULEB128) 0x02
798 ## ^---------- Form: DW_FORM_addr (8-byte)
799 # INFER-LENGTH-NEXT: 0x00000030 00000006 00000038 000000 .......8...
801 ## ^-------- Form: DW_FORM_data4 (4-byte)
802 ## ^-------- Form: DW_FORM_strp (4-byte)
804 ## The handwritten DIEs should look like:
806 ## 0x0000000b: DW_TAG_compile_unit [1] *
807 ## DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "clang version 10.0.0 ")
808 ## DW_AT_language [DW_FORM_data2] (DW_LANG_C99)
809 ## DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000016] = "hello.c")
810 ## DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
811 ## DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000001e] = "/home/v/x/llvm/playground")
812 ## DW_AT_low_pc [DW_FORM_addr] (0x0000000000001120)
813 ## DW_AT_high_pc [DW_FORM_data4] (0x00000033)
815 ## 0x0000002a: DW_TAG_subprogram [2]
816 ## DW_AT_low_pc [DW_FORM_addr] (0x0000000000001120)
817 ## DW_AT_high_pc [DW_FORM_data4] (0x00000006)
818 ## DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000038] = "main")
827 - "clang version 10.0.0 "
829 - "/home/v/x/llvm/playground"
834 Tag: DW_TAG_compile_unit
835 Children: DW_CHILDREN_yes
837 - Attribute: DW_AT_producer
839 - Attribute: DW_AT_language
841 - Attribute: DW_AT_name
843 - Attribute: DW_AT_stmt_list
844 Form: DW_FORM_sec_offset
845 - Attribute: DW_AT_comp_dir
847 - Attribute: DW_AT_low_pc
849 - Attribute: DW_AT_high_pc
852 Tag: DW_TAG_subprogram
853 Children: DW_CHILDREN_no
855 - Attribute: DW_AT_low_pc
857 - Attribute: DW_AT_high_pc
859 - Attribute: DW_AT_name
867 - Value: 0x00 ## DW_AT_producer [DW_FORM_strp]
868 - Value: 0x0c ## DW_LANG_C99, DW_AT_language [DW_FORM_data2]
869 - Value: 0x16 ## DW_AT_name [DW_FORM_strp]
870 - Value: 0x00 ## DW_AT_stmt_list [DW_FORM_sec_offset]
871 - Value: 0x1e ## DW_AT_comp_dir [DW_FORM_strp]
872 - Value: 0x1120 ## DW_AT_low_pc [DW_FORM_addr]
873 - Value: 0x33 ## DW_AT_high_pc [DW_FORM_data4]
876 - Value: 0x1120 ## DW_AT_low_pc [DW_FORM_addr]
877 - Value: 0x06 ## DW_AT_high_pc [DW_FORM_data4]
878 - Value: 0x38 ## DW_AT_name [DW_FORM_strp]
880 ## l) Test that if we don't specify the 'Values' key for an entry, yaml2obj will only emit the abbrev_code.
882 # RUN: yaml2obj --docnum=14 %s -o %t14.o
883 # RUN: llvm-readelf --hex-dump=.debug_info %t14.o | \
884 # RUN: FileCheck %s --check-prefix=NO-VALUES
886 # NO-VALUES: Hex dump of section '.debug_info':
887 # NO-VALUES-NEXT: 0x00000000 0a000000 04000000 00000801 0002 ..............
888 ## ^------- unit_length (4-byte)
889 ## ^--- version (2-byte)
890 ## ^-------- debug_abbrev_offset (4-byte)
891 ## ^- address_size (1-byte)
892 ## ^- abbrev_code (ULEB128) 0x01
893 ## ^- abbrev_code (ULEB128) 0x00
894 ## ^- abbrev_code (ULEB128) 0x02
910 ## m) Test that yaml2obj is able to infer the address size from the object file.
912 # RUN: yaml2obj --docnum=15 -DBITS=64 %s -o %t15.64-bit.o
913 # RUN: llvm-readelf --hex-dump=.debug_info %t15.64-bit.o | \
914 # RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDRSIZE=08
916 # ADDRSIZE: Hex dump of section '.debug_info':
917 # ADDRSIZE-NEXT: 0x00000000 07000000 04000000 0000[[ADDRSIZE]] ...........
919 # RUN: yaml2obj --docnum=15 -DBITS=32 %s -o %t15.32-bit.o
920 # RUN: llvm-readelf --hex-dump=.debug_info %t15.32-bit.o | \
921 # RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDRSIZE=04
925 Class: ELFCLASS[[BITS]]
933 ## n) Test that yaml2obj emits an error message when a compilation unit has values but there is no associated abbrev table.
935 ## RUN: not yaml2obj --docnum=16 %s 2>&1 | FileCheck %s --check-prefix=NO-ABBREV
937 # NO-ABBREV: yaml2obj: error: cannot find abbrev table whose ID is 0 for compilation unit with index 0
954 ## o) Test that yaml2obj is able to generate compilation units according to the
955 ## associated abbrev table that is referenced by the 'AbbrevTableID' and infer
956 ## the value of the debug_abbrev_offset field.
958 # RUN: yaml2obj --docnum=17 %s -o %t17.o
959 # RUN: llvm-readelf --hex-dump=.debug_info %t17.o | FileCheck %s --check-prefix=MULTI-TABLES
961 # MULTI-TABLES: Hex dump of section '.debug_info':
962 # MULTI-TABLES-NEXT: 0x00000000 0c000000 04000800 00000801 34120000 ............4...
963 ## ^------- unit_length (4-byte)
964 ## ^--- version (2-byte)
965 ## ^-------- debug_abbrev_offset (4-byte)
966 ## ^- address_size (1-byte)
967 ## ^- abbrev_code (ULEB128) 0x01
968 ## ^------- Form: DW_FORM_data4 (4-byte) 0x1234
969 # MULTI-TABLES-NEXT: 0x00000010 0c000000 04000800 00000801 21430000 ............!C..
970 ## ^------- unit_length (4-byte)
971 ## ^--- version (2-byte)
972 ## ^-------- debug_abbrev_offset (4-byte)
973 ## ^- address_size (1-byte)
974 ## ^- abbrev_code (ULEB128) 0x01
975 ## ^------- Form: DW_FORM_data4 (4-byte) 0x4321
976 # MULTI-TABLES-NEXT: 0x00000020 10000000 04000000 00000801 78560000 ............xV..
977 ## ^------- unit_length (4-byte)
978 ## ^--- version (2-byte)
979 ## ^-------- debug_abbrev_offset (4-byte)
980 ## ^- address_size (1-byte)
981 ## ^- abbrev_code (ULEB128) 0x01
982 ## ^------- Form: DW_FORM_addr (8-byte) 0x5678
983 # MULTI-TABLES-NEXT: 0x00000030 00000000 0b000000 04001000 00000801 ................
985 ## ^------- unit_length (4-byte)
986 ## ^--- version (2-byte)
987 ## ^-------- debug_abbrev_offset (4-byte)
988 ## ^- address_size (1-byte)
989 ## ^- abbrev_code (ULEB128) 0x01
990 # MULTI-TABLES-NEXT: 0x00000040 e58e02 ...
991 ## ^----- Form: DW_FORM_udata (ULEB128) 0x8765
1002 Tag: DW_TAG_compile_unit
1003 Children: DW_CHILDREN_no
1005 - Attribute: DW_AT_low_pc
1010 Tag: DW_TAG_compile_unit
1011 Children: DW_CHILDREN_no
1013 - Attribute: DW_AT_low_pc
1018 Tag: DW_TAG_compile_unit
1019 Children: DW_CHILDREN_no
1021 - Attribute: DW_AT_low_pc
1049 ## p) Test that when the debug_abbrev_offset field isn't specified and there is no associated
1050 ## abbrev table, yaml2obj will assign 0 to the debug_abbrev_offset field.
1052 # RUN: yaml2obj --docnum=18 %s -o %t18.o
1053 # RUN: llvm-readelf --hex-dump=.debug_info %t18.o | FileCheck %s --check-prefix=ZERO-OFFSET
1055 # ZERO-OFFSET: Hex dump of section '.debug_info':
1056 # ZERO-OFFSET-NEXT: 0x00000000 07000000 04000000 000008 ...........
1057 ## ^------- unit_length (4-byte)
1058 ## ^--- version (2-byte)
1059 ## ^-------- debug_abbrev_offset (4-byte)
1060 ## ^- address_size (1-byte)
1070 AbbrevTableID: [[ABBREVID=<none>]]
1072 ## q) Test that when we assign an invalid 'AbbrevTableID' that doesn't point to an abbrev table,
1073 ## yaml2obj will assign 0 to the debug_abbrev_offset field.
1075 # RUN: yaml2obj --docnum=18 -DABBREVID=2 %s -o %t18.o
1076 # RUN: llvm-readelf --hex-dump=.debug_info %t18.o | FileCheck %s --check-prefix=ZERO-OFFSET