llvm.org GIT mirror llvm / 8839439
Revert "[dwarfdump] Add support for dumping accelerator tables." This reverts commit r221836. The tests are asserting on some buildbots. This also reverts the test part of r221837 as it relies on dwarfdump dumping the accelerator tables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221842 91177308-0d34-0410-b5e6-96231b3b80d8 Frederic Riss 5 years ago
10 changed file(s) with 1 addition(s) and 372 deletion(s). Raw diff Collapse all Expand all
106106 DIDT_GnuPubtypes,
107107 DIDT_Str,
108108 DIDT_StrDwo,
109 DIDT_StrOffsetsDwo,
110 DIDT_AppleNames,
111 DIDT_AppleTypes,
112 DIDT_AppleNamespaces,
113 DIDT_AppleObjC
109 DIDT_StrOffsetsDwo
114110 };
115111
116112 // In place of applying the relocations to the data we've read from disk we use
0 add_llvm_library(LLVMDebugInfo
11 DIContext.cpp
22 DWARFAbbreviationDeclaration.cpp
3 DWARFAcceleratorTable.cpp
43 DWARFCompileUnit.cpp
54 DWARFContext.cpp
65 DWARFDebugAbbrev.cpp
+0
-110
lib/DebugInfo/DWARFAcceleratorTable.cpp less more
None #include "DWARFAcceleratorTable.h"
1
2 #include "llvm/Support/Dwarf.h"
3 #include "llvm/Support/Format.h"
4 #include "llvm/Support/raw_ostream.h"
5
6 namespace llvm {
7
8 bool DWARFAcceleratorTable::extract() {
9 uint32_t Offset = 0;
10
11 // Check that we can at least read the header.
12 if (!AccelSection.isValidOffset(offsetof(Header, HeaderDataLength)+4))
13 return false;
14
15 Hdr.Magic = AccelSection.getU32(&Offset);
16 Hdr.Version = AccelSection.getU16(&Offset);
17 Hdr.HashFunction = AccelSection.getU16(&Offset);
18 Hdr.NumBuckets = AccelSection.getU32(&Offset);
19 Hdr.NumHashes = AccelSection.getU32(&Offset);
20 Hdr.HeaderDataLength = AccelSection.getU32(&Offset);
21
22 // Check that we can read all the hashes and offsets from the
23 // section (see SourceLevelDebugging.rst for the structure of the index).
24 if (!AccelSection.isValidOffset(sizeof(Hdr) + Hdr.HeaderDataLength +
25 Hdr.NumBuckets*4 + Hdr.NumHashes*8))
26 return false;
27
28 HdrData.DIEOffsetBase = AccelSection.getU32(&Offset);
29 uint32_t NumAtoms = AccelSection.getU32(&Offset);
30
31 for (unsigned i = 0; i < NumAtoms; ++i) {
32 auto Atom = std::make_pair(AccelSection.getU16(&Offset),
33 DWARFFormValue(AccelSection.getU16(&Offset)));
34 HdrData.Atoms.push_back(Atom);
35 }
36
37 return true;
38 }
39
40 void DWARFAcceleratorTable::dump(raw_ostream &OS) {
41 // Dump the header.
42 OS << "Magic = " << format("0x%08x", Hdr.Magic) << '\n';
43 OS << "Version = " << format("0x%04x", Hdr.Version) << '\n';
44 OS << "Hash function = " << format("0x%08x", Hdr.HashFunction) << '\n';
45 OS << "Bucket count = " << Hdr.NumBuckets << '\n';
46 OS << "Hashes count = " << Hdr.NumHashes << '\n';
47 OS << "HeaderData length = " << Hdr.HeaderDataLength << '\n';
48 OS << "DIE offset base = " << HdrData.DIEOffsetBase << '\n';
49 OS << "Number of atoms = " << HdrData.Atoms.size() << '\n';
50
51 unsigned i = 0;
52 for (const auto &Atom: HdrData.Atoms) {
53 OS << format("Atom[%d] ", i++);
54 OS << " Type: " << dwarf::AtomTypeString(Atom.first);
55 OS << " Form: " << dwarf::FormEncodingString(Atom.second.getForm());
56 OS << "\n";
57 }
58
59 // Now go through the actual tables and dump them.
60 uint32_t Offset = sizeof(Hdr) + Hdr.HeaderDataLength;
61 unsigned HashesBase = Offset + Hdr.NumBuckets * 4;
62 unsigned OffsetsBase = HashesBase + Hdr.NumHashes * 4;
63
64 for (unsigned Bucket = 0; Bucket < Hdr.NumBuckets; ++Bucket) {
65 unsigned Index;
66 Index = AccelSection.getU32(&Offset);
67
68 OS << format("Bucket[%d]\n", Bucket);
69 if (Index == UINT32_MAX) {
70 OS << " EMPTY\n";
71 continue;
72 }
73
74 for (unsigned HashIdx = Index; HashIdx < Hdr.NumHashes; ++HashIdx) {
75 unsigned HashOffset = HashesBase + HashIdx*4;
76 unsigned OffsetsOffset = OffsetsBase + HashIdx*4;
77 uint32_t Hash = AccelSection.getU32(&HashOffset);
78
79 if (Hash % Hdr.NumBuckets != Bucket)
80 break;
81
82 unsigned DataOffset = AccelSection.getU32(&OffsetsOffset);
83 OS << format(" Hash = 0x%08x Offset = 0x%08x\n", Hash, DataOffset);
84 if (!AccelSection.isValidOffset(DataOffset)) {
85 OS << " Invalid section offset\n";
86 continue;
87 }
88 while (unsigned StringOffset = AccelSection.getU32(&DataOffset)) {
89 OS << format(" Name: %08x \"%s\"\n", StringOffset,
90 StringSection.getCStr(&StringOffset));
91 unsigned NumData = AccelSection.getU32(&DataOffset);
92 for (unsigned Data = 0; Data < NumData; ++Data) {
93 OS << format(" Data[%d] => ", Data);
94 unsigned i = 0;
95 for (auto &Atom : HdrData.Atoms) {
96 OS << format("{Atom[%d]: ", i++);
97 if (Atom.second.extractValue(AccelSection, &DataOffset, nullptr))
98 Atom.second.dump(OS, nullptr);
99 else
100 OS << "Error extracting the value";
101 OS << "} ";
102 }
103 OS << '\n';
104 }
105 }
106 }
107 }
108 }
109 }
+0
-38
lib/DebugInfo/DWARFAcceleratorTable.h less more
None
1 #include "llvm/ADT/SmallVector.h"
2 #include "llvm/DebugInfo/DWARFFormValue.h"
3
4 #include
5
6 namespace llvm {
7
8 class DWARFAcceleratorTable {
9
10 struct Header {
11 uint32_t Magic;
12 uint16_t Version;
13 uint16_t HashFunction;
14 uint32_t NumBuckets;
15 uint32_t NumHashes;
16 uint32_t HeaderDataLength;
17 };
18
19 struct HeaderData {
20 typedef uint16_t AtomType;
21 uint32_t DIEOffsetBase;
22 SmallVector, 1> Atoms;
23 };
24
25 struct Header Hdr;
26 struct HeaderData HdrData;
27 DataExtractor AccelSection;
28 DataExtractor StringSection;
29 public:
30 DWARFAcceleratorTable(DataExtractor AccelSection, DataExtractor StringSection)
31 : AccelSection(AccelSection), StringSection(StringSection) {}
32
33 bool extract();
34 void dump(raw_ostream &OS);
35 };
36
37 }
88
99 #include "DWARFContext.h"
1010 #include "DWARFDebugArangeSet.h"
11 #include "DWARFAcceleratorTable.h"
1211
1312 #include "llvm/ADT/SmallString.h"
1413 #include "llvm/ADT/StringSwitch.h"
5756 OS << '\"' << pubNames.getCStr(&offset) << "\"\n";
5857 }
5958 }
60 }
61
62 static void dumpAccelSection(raw_ostream &OS, StringRef Name, StringRef Data,
63 StringRef StringSection, bool LittleEndian) {
64 DataExtractor AccelSection(Data, LittleEndian, 0);
65 DataExtractor StrData(StringSection, LittleEndian, 0);
66 OS << "\n." << Name << " contents:\n";
67 DWARFAcceleratorTable Accel(AccelSection, StrData);
68 if (!Accel.extract())
69 return;
70 Accel.dump(OS);
7159 }
7260
7361 void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) {
229217 OS << format("%8.8x\n", strOffsetExt.getU32(&offset));
230218 }
231219 }
232
233 if (DumpType == DIDT_All || DumpType == DIDT_AppleNames)
234 dumpAccelSection(OS, "apple_names", getAppleNamesSection(),
235 getStringSection(), isLittleEndian());
236
237 if (DumpType == DIDT_All || DumpType == DIDT_AppleTypes)
238 dumpAccelSection(OS, "apple_types", getAppleTypesSection(),
239 getStringSection(), isLittleEndian());
240
241 if (DumpType == DIDT_All || DumpType == DIDT_AppleNamespaces)
242 dumpAccelSection(OS, "apple_namespaces", getAppleNamespacesSection(),
243 getStringSection(), isLittleEndian());
244
245 if (DumpType == DIDT_All || DumpType == DIDT_AppleObjC)
246 dumpAccelSection(OS, "apple_objc", getAppleObjCSection(),
247 getStringSection(), isLittleEndian());
248220 }
249221
250222 const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
592564 .Case("debug_str.dwo", &StringDWOSection)
593565 .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
594566 .Case("debug_addr", &AddrSection)
595 .Case("apple_names", &AppleNamesSection)
596 .Case("apple_types", &AppleTypesSection)
597 .Case("apple_namespaces", &AppleNamespacesSection)
598 .Case("apple_namespac", &AppleNamespacesSection)
599 .Case("apple_objc", &AppleObjCSection)
600567 // Any more debug info sections go here.
601568 .Default(nullptr);
602569 if (SectionData) {
191191 virtual StringRef getStringOffsetDWOSection() = 0;
192192 virtual StringRef getRangeDWOSection() = 0;
193193 virtual StringRef getAddrSection() = 0;
194 virtual StringRef getAppleNamesSection() = 0;
195 virtual StringRef getAppleTypesSection() = 0;
196 virtual StringRef getAppleNamespacesSection() = 0;
197 virtual StringRef getAppleObjCSection() = 0;
198194
199195 static bool isSupportedVersion(unsigned version) {
200196 return version == 2 || version == 3 || version == 4;
239235 StringRef StringOffsetDWOSection;
240236 StringRef RangeDWOSection;
241237 StringRef AddrSection;
242 StringRef AppleNamesSection;
243 StringRef AppleTypesSection;
244 StringRef AppleNamespacesSection;
245 StringRef AppleObjCSection;
246238
247239 SmallVector, 4> UncompressedSections;
248240
263255 StringRef getPubTypesSection() override { return PubTypesSection; }
264256 StringRef getGnuPubNamesSection() override { return GnuPubNamesSection; }
265257 StringRef getGnuPubTypesSection() override { return GnuPubTypesSection; }
266 StringRef getAppleNamesSection() override { return AppleNamesSection; }
267 StringRef getAppleTypesSection() override { return AppleTypesSection; }
268 StringRef getAppleNamespacesSection() override { return AppleNamespacesSection; }
269 StringRef getAppleObjCSection() override { return AppleObjCSection; }
270258
271259 // Sections for DWARF5 split dwarf proposal.
272260 const DWARFSection &getInfoDWOSection() override { return InfoDWOSection; }
9494 ; CHECK: .debug_pubtypes contents:
9595 ; CHECK-NOT: Offset
9696
97 ; CHECK: .apple{{.*}} contents:
98
9997 ; Function Attrs: nounwind uwtable
10098 define void @_Z2f1v() #0 {
10199 entry:
0 ; REQUIRES: object-emission
11
22 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck -implicit-check-not=DW_TAG %s
3 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s
43
54 ; Build from source:
65 ; $ clang++ a.cpp b.cpp -g -c -emit-llvm
5150 ; CHECK: DW_TAG_formal_parameter
5251 ; CHECK: DW_AT_location
5352 ; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_VAR]]} "x"
54
55 ; CHECK-ACCEL: .apple_names contents:
56 ; CHECK-ACCEL: Name{{.*}}"func"
57 ; CHECK-ACCEL-NOT: Name
58 ; CHECK-ACCEL: Atom[0]{{.*}}[[INLINED]]
59 ; CHECK-ACCEL-NOT: Name
60 ; CHECK-ACCEL: Atom[0]{{.*}}[[FUNC]]
61
62 ; CHECK-ACCEL: .apple_types contents:
63 ; CHECK-ACCEL: Name{{.*}}"int"
64 ; CHECK-ACCEL-NOT: Name
65 ; CHECK-ACCEL: Atom[0]{{.*}}[[INT]]
6653
6754 @i = external global i32
6855
+0
-154
test/DebugInfo/dwarfdump-accel.test less more
None RUN: llvm-dwarfdump %p/Inputs/dwarfdump-objc.x86_64.o | FileCheck %s
1
2 CHECK: .apple_names contents:
3 CHECK: Magic = 0x48415348
4 CHECK: Version = 0x0001
5 CHECK: Hash function = 0x00000000
6 CHECK: Bucket count = 11
7 CHECK: Hashes count = 22
8 CHECK: HeaderData length = 12
9 CHECK: DIE offset base = 0
10 CHECK: Number of atoms = 1
11 CHECK: Atom[0] Type: DW_ATOM_die_offset Form: DW_FORM_data4
12 CHECK: Bucket[0]
13 CHECK: Hash = 0x248050fe Offset = 0x000000fc
14 CHECK: Name: 00000165 "-[TestInterface Retain]"
15 CHECK: Data[0] => {Atom[0]: 0x0000024f}
16 CHECK: Bucket[1]
17 CHECK: Hash = 0x926d42cc Offset = 0x0000010c
18 CHECK: Name: 00000057 "ReadWrite"
19 CHECK: Data[0] => {Atom[0]: 0x000001cb}
20 CHECK: Bucket[2]
21 CHECK: EMPTY
22 CHECK: Bucket[3]
23 CHECK: Hash = 0x99254268 Offset = 0x0000011c
24 CHECK: Name: 0000013f "-[TestInterface setReadWrite:]"
25 CHECK: Data[0] => {Atom[0]: 0x00000209}
26 CHECK: Hash = 0x946f52b9 Offset = 0x0000012c
27 CHECK: Name: 000000c6 "-[TestInterface ReadOnly]"
28 CHECK: Data[0] => {Atom[0]: 0x00000109}
29 CHECK: Bucket[4]
30 CHECK: EMPTY
31 CHECK: Bucket[5]
32 CHECK: EMPTY
33 CHECK: Bucket[6]
34 CHECK: Hash = 0x6e8e91a3 Offset = 0x0000013c
35 CHECK: Name: 000001e0 "-[TestInterface NonAtomic]"
36 CHECK: Data[0] => {Atom[0]: 0x00000357}
37 CHECK: Hash = 0x7d1a5012 Offset = 0x0000014c
38 CHECK: Name: 0000014d "setReadWrite:"
39 CHECK: Data[0] => {Atom[0]: 0x00000209}
40 CHECK: Hash = 0xb65f49d3 Offset = 0x0000015c
41 CHECK: Name: 0000020d "setNonAtomic:"
42 CHECK: Data[0] => {Atom[0]: 0x00000395}
43 CHECK: Hash = 0x354997e2 Offset = 0x0000016c
44 CHECK: Name: 00000120 "-[TestInterface ReadWrite]"
45 CHECK: Data[0] => {Atom[0]: 0x000001cb}
46 CHECK: Bucket[7]
47 CHECK: Hash = 0xce8af9c8 Offset = 0x0000017c
48 CHECK: Name: 0000005e "Retain"
49 CHECK: Data[0] => {Atom[0]: 0x0000024f}
50 CHECK: Hash = 0xa7e0338a Offset = 0x0000018c
51 CHECK: Name: 0000004d "Assign"
52 CHECK: Data[0] => {Atom[0]: 0x00000147}
53 CHECK: Hash = 0xa9812410 Offset = 0x0000019c
54 CHECK: Name: 00000105 "setAssign:"
55 CHECK: Data[0] => {Atom[0]: 0x00000185}
56 CHECK: Hash = 0x218d07f6 Offset = 0x000001ac
57 CHECK: Name: 000001a2 "-[TestInterface Copy]"
58 CHECK: Data[0] => {Atom[0]: 0x000002d3}
59 CHECK: Hash = 0x0456817c Offset = 0x000001bc
60 CHECK: Name: 000001bc "-[TestInterface setCopy:]"
61 CHECK: Data[0] => {Atom[0]: 0x00000311}
62 CHECK: Hash = 0x7c83b400 Offset = 0x000001cc
63 CHECK: Name: 0000006c "Copy"
64 CHECK: Data[0] => {Atom[0]: 0x000002d3}
65 CHECK: Bucket[8]
66 CHECK: Hash = 0x0f918046 Offset = 0x000001dc
67 CHECK: Name: 000001c5 "setCopy:"
68 CHECK: Data[0] => {Atom[0]: 0x00000311}
69 CHECK: Hash = 0xfb097449 Offset = 0x000001ec
70 CHECK: Name: 000001ff "-[TestInterface setNonAtomic:]"
71 CHECK: Data[0] => {Atom[0]: 0x00000395}
72 CHECK: Hash = 0x71069de3 Offset = 0x000001fc
73 CHECK: Name: 00000042 "ReadOnly"
74 CHECK: Data[0] => {Atom[0]: 0x00000109}
75 CHECK: Bucket[9]
76 CHECK: Hash = 0xd55908c6 Offset = 0x0000020c
77 CHECK: Name: 000000fa "-[TestInterface setAssign:]"
78 CHECK: Data[0] => {Atom[0]: 0x00000185}
79 CHECK: Hash = 0xa584b20e Offset = 0x0000021c
80 CHECK: Name: 0000018c "setRetain:"
81 CHECK: Data[0] => {Atom[0]: 0x0000028d}
82 CHECK: Hash = 0x9429886d Offset = 0x0000022c
83 CHECK: Name: 00000076 "NonAtomic"
84 CHECK: Data[0] => {Atom[0]: 0x00000357}
85 CHECK: Hash = 0x287cc300 Offset = 0x0000023c
86 CHECK: Name: 000000de "-[TestInterface Assign]"
87 CHECK: Data[0] => {Atom[0]: 0x00000147}
88 CHECK: Hash = 0x51ce5684 Offset = 0x0000024c
89 CHECK: Name: 00000181 "-[TestInterface setRetain:]"
90 CHECK: Data[0] => {Atom[0]: 0x0000028d}
91 CHECK: Bucket[10]
92 CHECK: EMPTY
93
94
95 CHECK: .apple_types contents:
96 CHECK: Magic = 0x48415348
97 CHECK: Version = 0x0001
98 CHECK: Hash function = 0x00000000
99 CHECK: Bucket count = 4
100 CHECK: Hashes count = 4
101 CHECK: HeaderData length = 20
102 CHECK: DIE offset base = 0
103 CHECK: Number of atoms = 3
104 CHECK: Atom[0] Type: DW_ATOM_die_offset Form: DW_FORM_data4
105 CHECK: Atom[1] Type: DW_ATOM_die_tag Form: DW_FORM_data2
106 CHECK: Atom[2] Type: DW_ATOM_type_flags Form: DW_FORM_data1
107 CHECK: Bucket[0]
108 CHECK: Hash = 0x0b888030 Offset = 0x00000058
109 CHECK: Name: 00000046 "int"
110 CHECK: Data[0] => {Atom[0]: 0x000000f4} {Atom[1]: 0x0024} {Atom[2]: 0x00}
111 CHECK: Bucket[1]
112 CHECK: Hash = 0x0b881d29 Offset = 0x0000006b
113 CHECK: Name: 0000021b "SEL"
114 CHECK: Data[0] => {Atom[0]: 0x000003e0} {Atom[1]: 0x0016} {Atom[2]: 0x00}
115 CHECK: Hash = 0x2c549f3d Offset = 0x0000007e
116 CHECK: Name: 00000067 "NSObject"
117 CHECK: Data[0] => {Atom[0]: 0x00000100} {Atom[1]: 0x0013} {Atom[2]: 0x00}
118 CHECK: Bucket[2]
119 CHECK: Hash = 0x16a83cb6 Offset = 0x00000091
120 CHECK: Name: 00000039 "TestInterface"
121 CHECK: Data[0] => {Atom[0]: 0x0000002f} {Atom[1]: 0x0013} {Atom[2]: 0x00}
122 CHECK: Bucket[3]
123 CHECK: EMPTY
124
125
126 CHECK: .apple_namespaces contents:
127 CHECK-NOT: Magic
128
129
130 CHECK: .apple_objc contents:
131 CHECK: Magic = 0x48415348
132 CHECK: Version = 0x0001
133 CHECK: Hash function = 0x00000000
134 CHECK: Bucket count = 1
135 CHECK: Hashes count = 1
136 CHECK: HeaderData length = 12
137 CHECK: DIE offset base = 0
138 CHECK: Number of atoms = 1
139 CHECK: Atom[0] Type: DW_ATOM_die_offset Form: DW_FORM_data4
140 CHECK: Bucket[0]
141 CHECK: Hash = 0x16a83cb6 Offset = 0x0000002c
142 CHECK: Name: 00000039 "TestInterface"
143 CHECK: Data[0] => {Atom[0]: 0x00000109}
144 CHECK: Data[1] => {Atom[0]: 0x00000147}
145 CHECK: Data[2] => {Atom[0]: 0x00000185}
146 CHECK: Data[3] => {Atom[0]: 0x000001cb}
147 CHECK: Data[4] => {Atom[0]: 0x00000209}
148 CHECK: Data[5] => {Atom[0]: 0x0000024f}
149 CHECK: Data[6] => {Atom[0]: 0x0000028d}
150 CHECK: Data[7] => {Atom[0]: 0x000002d3}
151 CHECK: Data[8] => {Atom[0]: 0x00000311}
152 CHECK: Data[9] => {Atom[0]: 0x00000357}
153 CHECK: Data[10] => {Atom[0]: 0x00000395}
4444 clEnumValN(DIDT_All, "all", "Dump all debug sections"),
4545 clEnumValN(DIDT_Abbrev, "abbrev", ".debug_abbrev"),
4646 clEnumValN(DIDT_AbbrevDwo, "abbrev.dwo", ".debug_abbrev.dwo"),
47 clEnumValN(DIDT_AppleNames, "apple_names", ".apple_names"),
48 clEnumValN(DIDT_AppleTypes, "apple_types", ".apple_types"),
49 clEnumValN(DIDT_AppleNamespaces, "apple_namespaces", ".apple_namespaces"),
50 clEnumValN(DIDT_AppleObjC, "apple_objc", ".apple_objc"),
5147 clEnumValN(DIDT_Aranges, "aranges", ".debug_aranges"),
5248 clEnumValN(DIDT_Info, "info", ".debug_info"),
5349 clEnumValN(DIDT_InfoDwo, "info.dwo", ".debug_info.dwo"),