llvm.org GIT mirror llvm / 9ddf28d
llvm-dwarfdump support for gnu_pubtypes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191329 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 6 years ago
4 changed file(s) with 49 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
109109 DIDT_Ranges,
110110 DIDT_Pubnames,
111111 DIDT_GnuPubnames,
112 DIDT_GnuPubtypes,
112113 DIDT_Str,
113114 DIDT_StrDwo,
114115 DIDT_StrOffsetsDwo
2525 DWARFContext::~DWARFContext() {
2626 DeleteContainerPointers(CUs);
2727 DeleteContainerPointers(DWOCUs);
28 }
29
30 static void dumpPubSection(raw_ostream &OS, StringRef Name, StringRef Data,
31 bool LittleEndian) {
32 OS << "\n." << Name << " contents:\n";
33 DataExtractor pubNames(Data, LittleEndian, 0);
34 uint32_t offset = 0;
35 OS << "Length: " << pubNames.getU32(&offset) << "\n";
36 OS << "Version: " << pubNames.getU16(&offset) << "\n";
37 OS << "Offset in .debug_info: " << pubNames.getU32(&offset) << "\n";
38 OS << "Size: " << pubNames.getU32(&offset) << "\n";
39 OS << "Offset Linkage Kind Name\n";
40 while (offset < Data.size()) {
41 uint32_t dieRef = pubNames.getU32(&offset);
42 if (dieRef == 0)
43 break;
44 PubIndexEntryDescriptor desc(pubNames.getU8(&offset));
45 OS << format("0x%8.8x ", dieRef)
46 << format("%-8s", dwarf::GDBIndexEntryLinkageString(desc.Linkage)) << ' '
47 << dwarf::GDBIndexEntryKindString(desc.Kind) << " \""
48 << pubNames.getCStr(&offset) << "\"\n";
49 }
2850 }
2951
3052 void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) {
125147 }
126148 }
127149
128 if (DumpType == DIDT_All || DumpType == DIDT_GnuPubnames) {
129 OS << "\n.debug_gnu_pubnames contents:\n";
130 DataExtractor pubNames(getGnuPubNamesSection(), isLittleEndian(), 0);
131 offset = 0;
132 OS << "Length: " << pubNames.getU32(&offset) << "\n";
133 OS << "Version: " << pubNames.getU16(&offset) << "\n";
134 OS << "Offset in .debug_info: " << pubNames.getU32(&offset) << "\n";
135 OS << "Size: " << pubNames.getU32(&offset) << "\n";
136 OS << "Offset Linkage Kind Name\n";
137 while (offset < getGnuPubNamesSection().size()) {
138 uint32_t dieRef = pubNames.getU32(&offset);
139 if (dieRef == 0)
140 break;
141 PubIndexEntryDescriptor desc(pubNames.getU8(&offset));
142 OS << format("0x%8.8x ", dieRef)
143 << format("%-8s", dwarf::GDBIndexEntryLinkageString(desc.Linkage))
144 << ' ' << format("%-8s", dwarf::GDBIndexEntryKindString(desc.Kind))
145 << " \"" << pubNames.getCStr(&offset) << "\"\n";
146 }
147 }
150 if (DumpType == DIDT_All || DumpType == DIDT_GnuPubnames)
151 dumpPubSection(OS, "debug_gnu_pubnames", getGnuPubNamesSection(),
152 isLittleEndian());
153
154 if (DumpType == DIDT_All || DumpType == DIDT_GnuPubtypes)
155 dumpPubSection(OS, "debug_gnu_pubtypes", getGnuPubTypesSection(),
156 isLittleEndian());
148157
149158 if (DumpType == DIDT_All || DumpType == DIDT_AbbrevDwo) {
150159 const DWARFDebugAbbrev *D = getDebugAbbrevDWO();
611620 .Case("debug_ranges", &RangeSection)
612621 .Case("debug_pubnames", &PubNamesSection)
613622 .Case("debug_gnu_pubnames", &GnuPubNamesSection)
623 .Case("debug_gnu_pubtypes", &GnuPubTypesSection)
614624 .Case("debug_info.dwo", &InfoDWOSection.Data)
615625 .Case("debug_abbrev.dwo", &AbbrevDWOSection)
616626 .Case("debug_str.dwo", &StringDWOSection)
147147 virtual StringRef getRangeSection() = 0;
148148 virtual StringRef getPubNamesSection() = 0;
149149 virtual StringRef getGnuPubNamesSection() = 0;
150 virtual StringRef getGnuPubTypesSection() = 0;
150151
151152 // Sections for DWARF5 split dwarf proposal.
152153 virtual const Section &getInfoDWOSection() = 0;
186187 StringRef RangeSection;
187188 StringRef PubNamesSection;
188189 StringRef GnuPubNamesSection;
190 StringRef GnuPubTypesSection;
189191
190192 // Sections for DWARF5 split dwarf proposal.
191193 Section InfoDWOSection;
215217 virtual StringRef getRangeSection() { return RangeSection; }
216218 virtual StringRef getPubNamesSection() { return PubNamesSection; }
217219 virtual StringRef getGnuPubNamesSection() { return GnuPubNamesSection; }
220 virtual StringRef getGnuPubTypesSection() { return GnuPubTypesSection; }
218221
219222 // Sections for DWARF5 split dwarf proposal.
220223 virtual const Section &getInfoDWOSection() { return InfoDWOSection; }
3434
3535 ; ASM: .section .debug_gnu_pubnames
3636 ; ASM: .byte 32 # Kind: VARIABLE, EXTERNAL
37 ; ASM-NEXT: .asciz "global_namespace_variable" # External Name
3738
3839 ; ASM: .section .debug_gnu_pubtypes
3940 ; ASM: .byte 16 # Kind: TYPE, EXTERNAL
40 ; ASM: .asciz "C" # External Name
41 ; ASM: .byte 144 # Kind: TYPE, STATIC
42 ; ASM: .asciz "int" # External Name
41 ; ASM-NEXT: .asciz "C" # External Name
4342
4443 ; CHECK: .debug_info contents:
44 ; CHECK: 0x00000026: DW_TAG_base_type
45 ; CHECK-NEXT: DW_AT_name {{.*}} "int"
46 ; CHECK: 0x00000032: DW_TAG_structure_type
47 ; CHECK-NEXT: DW_AT_name {{.*}} "C"
4548 ; CHECK: 0x00000046: DW_TAG_subprogram
4649 ; CHECK-NEXT: DW_AT_MIPS_linkage_name
4750 ; CHECK-NEXT: DW_AT_name {{.*}} "member_function"
7679 ; CHECK-DAG: 0x0000007c EXTERNAL VARIABLE "global_variable"
7780 ; CHECK-DAG: 0x00000101 EXTERNAL FUNCTION "global_function"
7881 ; CHECK-DAG: 0x000000c2 STATIC FUNCTION "member_function"
82
83 ; CHECK-LABEL: debug_gnu_pubtypes contents:
84 ; CHECK-NEXT: Length:
85 ; CHECK-NEXT: Version:
86 ; CHECK-NEXT: Offset in .debug_info:
87 ; CHECK-NEXT: Size:
88 ; CHECK-NEXT: Offset Linkage Kind Name
89 ; CHECK-DAG: 0x00000032 EXTERNAL TYPE "C"
90 ; CHECK-DAG: 0x00000026 STATIC TYPE "int"
7991
8092 %struct.C = type { i8 }
8193