diff --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml --- a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml +++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml @@ -7,7 +7,7 @@ # RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s --check-prefix=DWARF32 --- !mach-o -FileHeader: +FileHeader: magic: 0xFEEDFACF cputype: 0x01000007 cpusubtype: 0x00000003 @@ -16,7 +16,7 @@ sizeofcmds: 1800 flags: 0x00000000 reserved: 0x00000000 -LoadCommands: +LoadCommands: - cmd: LC_SEGMENT_64 cmdsize: 72 segname: __PAGEZERO @@ -39,7 +39,7 @@ initprot: 5 nsects: 5 flags: 0 - Sections: + Sections: - sectname: __text segname: __TEXT addr: 0x0000000100000F50 @@ -111,7 +111,7 @@ initprot: 3 nsects: 2 flags: 0 - Sections: + Sections: - sectname: __nl_symbol_ptr segname: __DATA addr: 0x0000000100001000 @@ -158,7 +158,7 @@ initprot: 3 nsects: 11 flags: 0 - Sections: + Sections: - sectname: __debug_line segname: __DWARF addr: 0x0000000100003000 @@ -291,8 +291,8 @@ reserved1: 0x00000000 reserved2: 0x00000000 reserved3: 0x00000000 -LinkEditData: - NameList: +LinkEditData: + NameList: - n_strx: 2 n_type: 0x0F n_sect: 1 @@ -303,13 +303,13 @@ n_sect: 1 n_desc: 0 n_value: 4294971216 - StringTable: + StringTable: - '' - '' - __mh_execute_header - _main -DWARF: - debug_abbrev: +DWARF: + debug_abbrev: - Table: - Code: 0x00000001 Tag: DW_TAG_compile_unit @@ -381,23 +381,23 @@ Attributes: - Attribute: DW_AT_type Form: DW_FORM_ref4 - debug_aranges: + debug_aranges: - Length: 44 Version: 2 CuOffset: 0 AddressSize: 8 SegmentSelectorSize: 0 - Descriptors: + Descriptors: - Address: 0x0000000100000F50 Length: 52 - debug_info: + debug_info: - Length: 117 Version: 4 AbbrOffset: 0 AddrSize: 8 - Entries: + Entries: - AbbrCode: 0x00000001 - Values: + Values: - Value: 0x0000000000000001 - Value: 0x000000000000000C - Value: 0x0000000000000038 @@ -406,11 +406,11 @@ - Value: 0x0000000100000F50 - Value: 0x0000000000000034 - AbbrCode: 0x00000002 - Values: + Values: - Value: 0x0000000100000F50 - Value: 0x0000000000000034 - Value: 0x0000000000000001 - BlockData: + BlockData: - 0x56 - Value: 0x0000000000000076 - Value: 0x0000000000000001 @@ -419,9 +419,9 @@ - Value: 0x0000000000000060 - Value: 0x0000000000000001 - AbbrCode: 0x00000003 - Values: + Values: - Value: 0x0000000000000002 - BlockData: + BlockData: - 0x91 - 0x78 - Value: 0x000000000000007B @@ -429,9 +429,9 @@ - Value: 0x0000000000000003 - Value: 0x0000000000000060 - AbbrCode: 0x00000003 - Values: + Values: - Value: 0x0000000000000002 - BlockData: + BlockData: - 0x91 - 0x70 - Value: 0x0000000000000080 @@ -440,23 +440,23 @@ - Value: 0x0000000000000067 - AbbrCode: 0x00000000 - AbbrCode: 0x00000004 - Values: + Values: - Value: 0x0000000000000085 - Value: 0x0000000000000005 - Value: 0x0000000000000004 - AbbrCode: 0x00000005 - Values: + Values: - Value: 0x000000000000006C - AbbrCode: 0x00000005 - Values: + Values: - Value: 0x0000000000000071 - AbbrCode: 0x00000004 - Values: + Values: - Value: 0x0000000000000089 - Value: 0x0000000000000006 - Value: 0x0000000000000001 - AbbrCode: 0x00000000 - debug_line: + debug_line: - Length: 65 Version: 2 PrologueLength: 36 @@ -465,7 +465,7 @@ LineBase: 251 LineRange: 14 OpcodeBase: 13 - StandardOpcodeLengths: + StandardOpcodeLengths: - 0 - 1 - 1 @@ -478,13 +478,13 @@ - 0 - 0 - 1 - IncludeDirs: - Files: + IncludeDirs: + Files: - Name: hello_world.c DirIdx: 0 ModTime: 0 Length: 0 - Opcodes: + Opcodes: - Opcode: DW_LNS_extended_op ExtLen: 9 SubOpcode: DW_LNE_set_address @@ -700,6 +700,12 @@ # MULTI-TABLES-NEXT: Attributes: # MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc # MULTI-TABLES-NEXT: Form: DW_FORM_data4 +# MULTI-TABLES-NEXT: - Code: 0x0000000000000002 +# MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit +# MULTI-TABLES-NEXT: Children: DW_CHILDREN_no +# MULTI-TABLES-NEXT: Attributes: +# MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc +# MULTI-TABLES-NEXT: Form: DW_FORM_data4 # MULTI-TABLES-NEXT: - ID: 2 # MULTI-TABLES-NEXT: Table: # MULTI-TABLES-NEXT: - Code: 0x0000000000000001 @@ -708,6 +714,7 @@ # MULTI-TABLES-NEXT: Attributes: # MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc # MULTI-TABLES-NEXT: Form: DW_FORM_udata +# MULTI-TABLES-NEXT: - ID: 3 # MULTI-TABLES-NEXT: debug_info: # MULTI-TABLES-NEXT: - Length: 0x000000000000000C # MULTI-TABLES-NEXT: Version: 4 @@ -739,7 +746,7 @@ # MULTI-TABLES-NEXT: - Length: 0x000000000000000B # MULTI-TABLES-NEXT: Version: 4 # MULTI-TABLES-NEXT: AbbrevTableID: 2 -# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000010 +# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000017 # MULTI-TABLES-NEXT: AddrSize: 8 # MULTI-TABLES-NEXT: Entries: # MULTI-TABLES-NEXT: - AbbrCode: 0x00000001 @@ -773,7 +780,7 @@ - sectname: __debug_abbrev segname: __DWARF addr: 0x00 - size: 24 + size: 32 offset: 528 align: 0 reloff: 0x00000000 @@ -811,6 +818,12 @@ Attributes: - Attribute: DW_AT_low_pc Form: DW_FORM_data4 + - Code: 2 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_data4 - ID: 1 Table: - Code: 1 @@ -843,7 +856,7 @@ - Value: 0x5678 - Version: 4 AbbrevTableID: 1 - AbbrOffset: 16 + AbbrOffset: 23 Entries: - AbbrCode: 1 Values: diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -25,6 +25,7 @@ uint64_t AbbrevTableID = 0; for (auto AbbrvDeclSet : *AbbrevSetPtr) { Y.DebugAbbrev.emplace_back(); + Y.DebugAbbrev.back().ID = AbbrevTableID++; for (auto AbbrvDecl : AbbrvDeclSet.second) { DWARFYAML::Abbrev Abbrv; Abbrv.Code = AbbrvDecl.getCode(); @@ -39,7 +40,6 @@ AttAbrv.Value = Attribute.getImplicitConstValue(); Abbrv.Attributes.push_back(AttAbrv); } - Y.DebugAbbrev.back().ID = AbbrevTableID++; Y.DebugAbbrev.back().Table.push_back(Abbrv); } }