1 ## This file contains test cases for generating a DAWRFv4 .debug_info
2 ## section in object files from the DWARF entry of Mach-O YAML inputs.
4 ## a) Test that yaml2obj emits a DWARF32 .debug_info sections and obj2yaml
7 # RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s --check-prefix=DWARF32
13 cpusubtype: 0x00000003
45 addr: 0x0000000100000F50
57 addr: 0x0000000100000F84
67 - sectname: __stub_helper
69 addr: 0x0000000100000F8C
81 addr: 0x0000000100000FA6
91 - sectname: __unwind_info
93 addr: 0x0000000100000FB4
100 reserved1: 0x00000000
101 reserved2: 0x00000000
102 reserved3: 0x00000000
115 - sectname: __nl_symbol_ptr
117 addr: 0x0000000100001000
124 reserved1: 0x00000001
125 reserved2: 0x00000000
126 reserved3: 0x00000000
127 - sectname: __la_symbol_ptr
129 addr: 0x0000000100001010
136 reserved1: 0x00000003
137 reserved2: 0x00000000
138 reserved3: 0x00000000
162 - sectname: __debug_line
164 addr: 0x0000000100003000
171 reserved1: 0x00000000
172 reserved2: 0x00000000
173 reserved3: 0x00000000
174 - sectname: __debug_pubnames
176 addr: 0x0000000100003045
183 reserved1: 0x00000000
184 reserved2: 0x00000000
185 reserved3: 0x00000000
186 - sectname: __debug_pubtypes
188 addr: 0x0000000100003060
195 reserved1: 0x00000000
196 reserved2: 0x00000000
197 reserved3: 0x00000000
198 - sectname: __debug_aranges
200 addr: 0x0000000100003083
207 reserved1: 0x00000000
208 reserved2: 0x00000000
209 reserved3: 0x00000000
210 - sectname: __debug_info
212 addr: 0x00000001000030B3
219 reserved1: 0x00000000
220 reserved2: 0x00000000
221 reserved3: 0x00000000
222 - sectname: __debug_abbrev
224 addr: 0x000000010000312C
231 reserved1: 0x00000000
232 reserved2: 0x00000000
233 reserved3: 0x00000000
234 - sectname: __debug_str
236 addr: 0x0000000100003178
243 reserved1: 0x00000000
244 reserved2: 0x00000000
245 reserved3: 0x00000000
246 - sectname: __apple_names
248 addr: 0x0000000100003206
255 reserved1: 0x00000000
256 reserved2: 0x00000000
257 reserved3: 0x00000000
258 - sectname: __apple_namespac
260 addr: 0x0000000100003242
267 reserved1: 0x00000000
268 reserved2: 0x00000000
269 reserved3: 0x00000000
270 - sectname: __apple_types
272 addr: 0x0000000100003266
279 reserved1: 0x00000000
280 reserved2: 0x00000000
281 reserved3: 0x00000000
282 - sectname: __apple_objc
284 addr: 0x00000001000032D8
291 reserved1: 0x00000000
292 reserved2: 0x00000000
293 reserved3: 0x00000000
309 - __mh_execute_header
315 Tag: DW_TAG_compile_unit
316 Children: DW_CHILDREN_yes
318 - Attribute: DW_AT_producer
320 - Attribute: DW_AT_language
322 - Attribute: DW_AT_name
324 - Attribute: DW_AT_stmt_list
325 Form: DW_FORM_sec_offset
326 - Attribute: DW_AT_comp_dir
328 - Attribute: DW_AT_low_pc
330 - Attribute: DW_AT_high_pc
333 Tag: DW_TAG_subprogram
334 Children: DW_CHILDREN_yes
336 - Attribute: DW_AT_low_pc
338 - Attribute: DW_AT_high_pc
340 - Attribute: DW_AT_frame_base
341 Form: DW_FORM_exprloc
342 - Attribute: DW_AT_name
344 - Attribute: DW_AT_decl_file
346 - Attribute: DW_AT_decl_line
348 - Attribute: DW_AT_prototyped
349 Form: DW_FORM_flag_present
350 - Attribute: DW_AT_type
352 - Attribute: DW_AT_external
353 Form: DW_FORM_flag_present
355 Tag: DW_TAG_formal_parameter
356 Children: DW_CHILDREN_no
358 - Attribute: DW_AT_location
359 Form: DW_FORM_exprloc
360 - Attribute: DW_AT_name
362 - Attribute: DW_AT_decl_file
364 - Attribute: DW_AT_decl_line
366 - Attribute: DW_AT_type
369 Tag: DW_TAG_base_type
370 Children: DW_CHILDREN_no
372 - Attribute: DW_AT_name
374 - Attribute: DW_AT_encoding
376 - Attribute: DW_AT_byte_size
379 Tag: DW_TAG_pointer_type
380 Children: DW_CHILDREN_no
382 - Attribute: DW_AT_type
389 SegmentSelectorSize: 0
391 - Address: 0x0000000100000F50
399 - AbbrCode: 0x00000001
401 - Value: 0x0000000000000001
402 - Value: 0x000000000000000C
403 - Value: 0x0000000000000038
404 - Value: 0x0000000000000000
405 - Value: 0x0000000000000046
406 - Value: 0x0000000100000F50
407 - Value: 0x0000000000000034
408 - AbbrCode: 0x00000002
410 - Value: 0x0000000100000F50
411 - Value: 0x0000000000000034
412 - Value: 0x0000000000000001
415 - Value: 0x0000000000000076
416 - Value: 0x0000000000000001
417 - Value: 0x0000000000000003
418 - Value: 0x0000000000000001
419 - Value: 0x0000000000000060
420 - Value: 0x0000000000000001
421 - AbbrCode: 0x00000003
423 - Value: 0x0000000000000002
427 - Value: 0x000000000000007B
428 - Value: 0x0000000000000001
429 - Value: 0x0000000000000003
430 - Value: 0x0000000000000060
431 - AbbrCode: 0x00000003
433 - Value: 0x0000000000000002
437 - Value: 0x0000000000000080
438 - Value: 0x0000000000000001
439 - Value: 0x0000000000000003
440 - Value: 0x0000000000000067
441 - AbbrCode: 0x00000000
442 - AbbrCode: 0x00000004
444 - Value: 0x0000000000000085
445 - Value: 0x0000000000000005
446 - Value: 0x0000000000000004
447 - AbbrCode: 0x00000005
449 - Value: 0x000000000000006C
450 - AbbrCode: 0x00000005
452 - Value: 0x0000000000000071
453 - AbbrCode: 0x00000004
455 - Value: 0x0000000000000089
456 - Value: 0x0000000000000006
457 - Value: 0x0000000000000001
458 - AbbrCode: 0x00000000
468 StandardOpcodeLengths:
482 - Name: hello_world.c
487 - Opcode: DW_LNS_extended_op
489 SubOpcode: DW_LNE_set_address
493 - Opcode: DW_LNS_set_column
495 - Opcode: DW_LNS_set_prologue_end
497 - Opcode: DW_LNS_const_add_pc
503 - Opcode: DW_LNS_advance_pc
505 - Opcode: DW_LNS_extended_op
507 SubOpcode: DW_LNE_end_sequence
513 # DWARF32: debug_info:
514 # DWARF32-NEXT: - Length: 0x75
515 # DWARF32-NEXT: Version: 4
516 # DWARF32-NEXT: AbbrevTableID: 0
517 # DWARF32-NEXT: AbbrOffset: 0
518 # DWARF32-NEXT: AddrSize: 8
519 # DWARF32-NEXT: Entries:
520 # DWARF32-NEXT: - AbbrCode: 0x1
521 # DWARF32-NEXT: Values:
522 # DWARF32-NEXT: - Value: 0x1
523 # DWARF32-NEXT: - Value: 0xC
524 # DWARF32-NEXT: - Value: 0x38
525 # DWARF32-NEXT: - Value: 0x0
526 # DWARF32-NEXT: - Value: 0x46
527 # DWARF32-NEXT: - Value: 0x100000F50
528 # DWARF32-NEXT: - Value: 0x34
529 # DWARF32-NEXT: - AbbrCode: 0x2
530 # DWARF32-NEXT: Values:
531 # DWARF32-NEXT: - Value: 0x100000F50
532 # DWARF32-NEXT: - Value: 0x34
533 # DWARF32-NEXT: - Value: 0x1
534 # DWARF32-NEXT: BlockData: [ 0x56 ]
535 # DWARF32-NEXT: - Value: 0x76
536 # DWARF32-NEXT: - Value: 0x1
537 # DWARF32-NEXT: - Value: 0x3
538 # DWARF32-NEXT: - Value: 0x1
539 # DWARF32-NEXT: - Value: 0x60
540 # DWARF32-NEXT: - Value: 0x1
541 # DWARF32-NEXT: - AbbrCode: 0x3
542 # DWARF32-NEXT: Values:
543 # DWARF32-NEXT: - Value: 0x2
544 # DWARF32-NEXT: BlockData: [ 0x91, 0x78 ]
545 # DWARF32-NEXT: - Value: 0x7B
546 # DWARF32-NEXT: - Value: 0x1
547 # DWARF32-NEXT: - Value: 0x3
548 # DWARF32-NEXT: - Value: 0x60
549 # DWARF32-NEXT: - AbbrCode: 0x3
550 # DWARF32-NEXT: Values:
551 # DWARF32-NEXT: - Value: 0x2
552 # DWARF32-NEXT: BlockData: [ 0x91, 0x70 ]
553 # DWARF32-NEXT: - Value: 0x80
554 # DWARF32-NEXT: - Value: 0x1
555 # DWARF32-NEXT: - Value: 0x3
556 # DWARF32-NEXT: - Value: 0x67
557 # DWARF32-NEXT: - AbbrCode: 0x0
558 # DWARF32-NEXT: - AbbrCode: 0x4
559 # DWARF32-NEXT: Values:
560 # DWARF32-NEXT: - Value: 0x85
561 # DWARF32-NEXT: - Value: 0x5
562 # DWARF32-NEXT: - Value: 0x4
563 # DWARF32-NEXT: - AbbrCode: 0x5
564 # DWARF32-NEXT: Values:
565 # DWARF32-NEXT: - Value: 0x6C
566 # DWARF32-NEXT: - AbbrCode: 0x5
567 # DWARF32-NEXT: Values:
568 # DWARF32-NEXT: - Value: 0x71
569 # DWARF32-NEXT: - AbbrCode: 0x4
570 # DWARF32-NEXT: Values:
571 # DWARF32-NEXT: - Value: 0x89
572 # DWARF32-NEXT: - Value: 0x6
573 # DWARF32-NEXT: - Value: 0x1
574 # DWARF32-NEXT: - AbbrCode: 0x0
576 ## b) Test that yaml2obj emits a correct unit header and obj2yaml is able to convert it back.
578 ## Test DWARF32 unit header.
580 # RUN: yaml2obj --docnum=2 -DFORMAT=DWARF32 %s | \
581 # RUN: obj2yaml | FileCheck %s --check-prefix=DWARF32-YAML
583 # DWARF32-YAML: debug_info:
584 # DWARF32-YAML-NEXT: - Length: 0xC
585 # DWARF32-YAML-NEXT: Version: 4
586 # DWARF32-YAML-NEXT: AbbrevTableID: 0
587 # DWARF32-YAML-NEXT: AbbrOffset: 0
588 # DWARF32-YAML-NEXT: AddrSize: 8
589 # DWARF32-YAML-NEXT: Entries:
590 # DWARF32-YAML-NEXT: - AbbrCode: 0x1
591 # DWARF32-YAML-NEXT: Values:
592 # DWARF32-YAML-NEXT: - Value: 0x1234
598 cpusubtype: 0x00000003
617 - sectname: __debug_abbrev
626 reserved1: 0x00000000
627 reserved2: 0x00000000
628 reserved3: 0x00000000
629 - sectname: __debug_info
638 reserved1: 0x00000000
639 reserved2: 0x00000000
640 reserved3: 0x00000000
645 Tag: DW_TAG_compile_unit
646 Children: DW_CHILDREN_no
648 - Attribute: DW_AT_low_pc
661 ## Test DWARF64 unit header.
663 # RUN: yaml2obj --docnum=2 -DFORMAT=DWARF64 %s | \
664 # RUN: obj2yaml | FileCheck %s --check-prefix=DWARF64-YAML
666 # DWARF64-YAML: debug_info:
667 # DWARF64-YAML-NEXT: - Format: DWARF64
668 # DWARF64-YAML-NEXT: Length: 0xC
669 # DWARF64-YAML-NEXT: Version: 4
670 # DWARF64-YAML-NEXT: AbbrevTableID: 0
671 # DWARF64-YAML-NEXT: AbbrOffset: 0
672 # DWARF64-YAML-NEXT: AddrSize: 8
673 # DWARF64-YAML-NEXT: Entries:
674 # DWARF64-YAML-NEXT: - AbbrCode: 0x1
675 # DWARF64-YAML-NEXT: Values:
676 # DWARF64-YAML-NEXT: - Value: 0x1234
678 ## c) Test that yaml2obj is able to generate compilation units according to the
679 ## associated abbrev table that is referenced by the 'AbbrevTableID' and obj2yaml
680 ## is able to convert it back.
682 # RUN: yaml2obj --docnum=3 %s | obj2yaml | FileCheck %s --check-prefix=MULTI-TABLES
684 # MULTI-TABLES: DWARF:
685 # MULTI-TABLES-NEXT: debug_abbrev:
686 # MULTI-TABLES-NEXT: - ID: 0
687 # MULTI-TABLES-NEXT: Table:
688 # MULTI-TABLES-NEXT: - Code: 0x1
689 # MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit
690 # MULTI-TABLES-NEXT: Children: DW_CHILDREN_no
691 # MULTI-TABLES-NEXT: Attributes:
692 # MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc
693 # MULTI-TABLES-NEXT: Form: DW_FORM_addr
694 # MULTI-TABLES-NEXT: - ID: 1
695 # MULTI-TABLES-NEXT: Table:
696 # MULTI-TABLES-NEXT: - Code: 0x1
697 # MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit
698 # MULTI-TABLES-NEXT: Children: DW_CHILDREN_no
699 # MULTI-TABLES-NEXT: Attributes:
700 # MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc
701 # MULTI-TABLES-NEXT: Form: DW_FORM_data4
702 # MULTI-TABLES-NEXT: - Code: 0x2
703 # MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit
704 # MULTI-TABLES-NEXT: Children: DW_CHILDREN_no
705 # MULTI-TABLES-NEXT: Attributes:
706 # MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc
707 # MULTI-TABLES-NEXT: Form: DW_FORM_data4
708 # MULTI-TABLES-NEXT: - ID: 2
709 # MULTI-TABLES-NEXT: Table:
710 # MULTI-TABLES-NEXT: - Code: 0x1
711 # MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit
712 # MULTI-TABLES-NEXT: Children: DW_CHILDREN_no
713 # MULTI-TABLES-NEXT: Attributes:
714 # MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc
715 # MULTI-TABLES-NEXT: Form: DW_FORM_udata
716 # MULTI-TABLES-NEXT: - ID: 3
717 # MULTI-TABLES-NEXT: debug_info:
718 # MULTI-TABLES-NEXT: - Length: 0xC
719 # MULTI-TABLES-NEXT: Version: 4
720 # MULTI-TABLES-NEXT: AbbrevTableID: 1
721 # MULTI-TABLES-NEXT: AbbrOffset: 0x8
722 # MULTI-TABLES-NEXT: AddrSize: 8
723 # MULTI-TABLES-NEXT: Entries:
724 # MULTI-TABLES-NEXT: - AbbrCode: 0x1
725 # MULTI-TABLES-NEXT: Values:
726 # MULTI-TABLES-NEXT: - Value: 0x1234
727 # MULTI-TABLES-NEXT: - Length: 0xC
728 # MULTI-TABLES-NEXT: Version: 4
729 # MULTI-TABLES-NEXT: AbbrevTableID: 1
730 # MULTI-TABLES-NEXT: AbbrOffset: 0x8
731 # MULTI-TABLES-NEXT: AddrSize: 8
732 # MULTI-TABLES-NEXT: Entries:
733 # MULTI-TABLES-NEXT: - AbbrCode: 0x1
734 # MULTI-TABLES-NEXT: Values:
735 # MULTI-TABLES-NEXT: - Value: 0x4321
736 # MULTI-TABLES-NEXT: - Length: 0x10
737 # MULTI-TABLES-NEXT: Version: 4
738 # MULTI-TABLES-NEXT: AbbrevTableID: 0
739 # MULTI-TABLES-NEXT: AbbrOffset: 0x0
740 # MULTI-TABLES-NEXT: AddrSize: 8
741 # MULTI-TABLES-NEXT: Entries:
742 # MULTI-TABLES-NEXT: - AbbrCode: 0x1
743 # MULTI-TABLES-NEXT: Values:
744 # MULTI-TABLES-NEXT: - Value: 0x5678
745 # MULTI-TABLES-NEXT: - Length: 0xB
746 # MULTI-TABLES-NEXT: Version: 4
747 # MULTI-TABLES-NEXT: AbbrevTableID: 2
748 # MULTI-TABLES-NEXT: AbbrOffset: 0x17
749 # MULTI-TABLES-NEXT: AddrSize: 8
750 # MULTI-TABLES-NEXT: Entries:
751 # MULTI-TABLES-NEXT: - AbbrCode: 0x1
752 # MULTI-TABLES-NEXT: Values:
753 # MULTI-TABLES-NEXT: - Value: 0x8765
754 # MULTI-TABLES-NEXT: ...
760 cpusubtype: 0x00000003
779 - sectname: __debug_abbrev
788 reserved1: 0x00000000
789 reserved2: 0x00000000
790 reserved3: 0x00000000
791 - sectname: __debug_info
800 reserved1: 0x00000000
801 reserved2: 0x00000000
802 reserved3: 0x00000000
807 Tag: DW_TAG_compile_unit
808 Children: DW_CHILDREN_no
810 - Attribute: DW_AT_low_pc
815 Tag: DW_TAG_compile_unit
816 Children: DW_CHILDREN_no
818 - Attribute: DW_AT_low_pc
821 Tag: DW_TAG_compile_unit
822 Children: DW_CHILDREN_no
824 - Attribute: DW_AT_low_pc
829 Tag: DW_TAG_compile_unit
830 Children: DW_CHILDREN_no
832 - Attribute: DW_AT_low_pc
861 ## d) Test that yaml2obj emits an error message when a compilation unit doesn't have
862 ## an associated abbrev table.
864 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=MISSING-ABBREV
866 # MISSING-ABBREV: yaml2obj: error: cannot find abbrev table whose ID is 0 for compilation unit with index 0
872 cpusubtype: 0x00000003
891 - sectname: __debug_info
900 reserved1: 0x00000000
901 reserved2: 0x00000000
902 reserved3: 0x00000000