llvm.org GIT mirror llvm / 1040f99
dwarfdump: First piece of support for DWP dumping Just a tiny piece of index dumping - the header in this instance. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252781 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 4 years ago
9 changed file(s) with 118 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
122122 DIDT_AppleNames,
123123 DIDT_AppleTypes,
124124 DIDT_AppleNamespaces,
125 DIDT_AppleObjC
125 DIDT_AppleObjC,
126 DIDT_CUIndex,
126127 };
127128
128129 class DIContext {
202202 virtual const DWARFSection& getAppleTypesSection() = 0;
203203 virtual const DWARFSection& getAppleNamespacesSection() = 0;
204204 virtual const DWARFSection& getAppleObjCSection() = 0;
205 virtual StringRef getCUIndexSection() = 0;
205206
206207 static bool isSupportedVersion(unsigned version) {
207208 return version == 2 || version == 3 || version == 4;
250251 DWARFSection AppleTypesSection;
251252 DWARFSection AppleNamespacesSection;
252253 DWARFSection AppleObjCSection;
254 StringRef CUIndexSection;
253255
254256 SmallVector, 4> UncompressedSections;
255257
292294 StringRef getAddrSection() override {
293295 return AddrSection;
294296 }
297 StringRef getCUIndexSection() override { return CUIndexSection; }
295298 };
296299
297300 }
0 //===-- DWARFUnitIndex.h --------------------------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_LIB_DEBUGINFO_DWARFUNITINDEX_H
10 #define LLVM_LIB_DEBUGINFO_DWARFUNITINDEX_H
11
12 #include "llvm/Support/DataExtractor.h"
13 #include "llvm/Support/Format.h"
14 #include "llvm/Support/raw_ostream.h"
15 #include
16
17 namespace llvm {
18
19 class DWARFUnitIndex {
20 class Header {
21 uint32_t Version;
22 uint32_t NumColumns;
23 uint32_t NumUnits;
24 uint32_t NumBuckets;
25
26 public:
27 bool parse(DataExtractor IndexData, uint32_t *OffsetPtr);
28 void dump(raw_ostream &OS) const;
29 };
30
31 class Header Header;
32
33 public:
34 bool parse(DataExtractor IndexData);
35 void dump(raw_ostream &OS) const;
36 };
37
38 }
39
40 #endif
1212 DWARFDebugRangeList.cpp
1313 DWARFFormValue.cpp
1414 DWARFTypeUnit.cpp
15 DWARFUnitIndex.cpp
1516 DWARFUnit.cpp
1617 SyntaxHighlighting.cpp
1718
1111 #include "llvm/ADT/StringSwitch.h"
1212 #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
1313 #include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
14 #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
1415 #include "llvm/Support/Compression.h"
1516 #include "llvm/Support/Dwarf.h"
1617 #include "llvm/Support/Format.h"
152153 LineTable.dump(OS);
153154 }
154155 }
156 }
157
158 if (DumpType == DIDT_All || DumpType == DIDT_CUIndex) {
159 OS << "\n.debug_cu_index contents:\n";
160 DataExtractor CUIndexData(getCUIndexSection(), isLittleEndian(), savedAddressByteSize);
161 DWARFUnitIndex CUIndex;
162 CUIndex.parse(CUIndexData);
163 CUIndex.dump(OS);
155164 }
156165
157166 if (DumpType == DIDT_All || DumpType == DIDT_LineDwo) {
607616 .Case("apple_namespaces", &AppleNamespacesSection.Data)
608617 .Case("apple_namespac", &AppleNamespacesSection.Data)
609618 .Case("apple_objc", &AppleObjCSection.Data)
619 .Case("debug_cu_index", &CUIndexSection)
610620 // Any more debug info sections go here.
611621 .Default(nullptr);
612622 if (SectionData) {
0 //===-- DWARFUnitIndex.cpp ------------------------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
10
11 namespace llvm {
12
13 bool DWARFUnitIndex::Header::parse(DataExtractor IndexData, uint32_t *OffsetPtr) {
14 Version = IndexData.getU32(OffsetPtr);
15 NumColumns = IndexData.getU32(OffsetPtr);
16 NumUnits = IndexData.getU32(OffsetPtr);
17 NumBuckets = IndexData.getU32(OffsetPtr);
18 return Version <= 2;
19 }
20
21 void DWARFUnitIndex::Header::dump(raw_ostream &OS) const {
22 OS << "Index header:\n" << format(" version: %u\n", Version)
23 << format(" columns: %u\n", NumColumns)
24 << format(" units: %u\n", NumUnits)
25 << format(" buckets: %u\n", NumBuckets);
26 }
27
28 bool DWARFUnitIndex::parse(DataExtractor IndexData) {
29 uint32_t Offset = 0;
30 if (!Header.parse(IndexData, &Offset))
31 return false;
32
33 return true;
34 }
35
36 void DWARFUnitIndex::dump(raw_ostream &OS) const {
37 Header.dump(OS);
38 }
39
40 }
0 RUN: llvm-dwarfdump %p/Inputs/dwarfdump-dwp.x86_64.o | FileCheck %s
1
2 ; Testing the following simple dwp file:
3 ; a.cpp:
4 ; struct foo { };
5 ; foo a;
6 ; b.cpp:
7 ; struct foo { };
8 ; foo b;
9
10 ; CHECK: .debug_cu_index contents:
11 ; CHECK: version: 2
12 ; CHECK: columns: 4
13 ; CHECK: units: 2
14 ; CHECK: buckets: 16
15
16 ; TODO: debug_tu_index
17 ; TODO: dump the index contents
18 ; TODO: use the index section offset info to correctly dump debug_info
6767 clEnumValN(DIDT_Str, "str", ".debug_str"),
6868 clEnumValN(DIDT_StrDwo, "str.dwo", ".debug_str.dwo"),
6969 clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo", ".debug_str_offsets.dwo"),
70 clEnumValN(DIDT_CUIndex, "cu_index", ".debug_cu_index"),
7071 clEnumValEnd));
7172
7273 static void error(StringRef Filename, std::error_code EC) {