summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/DebugInfo/DIContext.h3
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h3
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h41
-rw-r--r--llvm/lib/DebugInfo/DWARF/CMakeLists.txt1
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp10
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp41
-rw-r--r--llvm/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.obin0 -> 1904 bytes
-rw-r--r--llvm/test/DebugInfo/dwarfdump-dwp.test19
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp1
9 files changed, 118 insertions, 1 deletions
diff --git a/llvm/include/llvm/DebugInfo/DIContext.h b/llvm/include/llvm/DebugInfo/DIContext.h
index 1ca7b044df1..87308470507 100644
--- a/llvm/include/llvm/DebugInfo/DIContext.h
+++ b/llvm/include/llvm/DebugInfo/DIContext.h
@@ -123,7 +123,8 @@ enum DIDumpType {
DIDT_AppleNames,
DIDT_AppleTypes,
DIDT_AppleNamespaces,
- DIDT_AppleObjC
+ DIDT_AppleObjC,
+ DIDT_CUIndex,
};
class DIContext {
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
index 423c0d32f1b..01d25f7aa8a 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -203,6 +203,7 @@ public:
virtual const DWARFSection& getAppleTypesSection() = 0;
virtual const DWARFSection& getAppleNamespacesSection() = 0;
virtual const DWARFSection& getAppleObjCSection() = 0;
+ virtual StringRef getCUIndexSection() = 0;
static bool isSupportedVersion(unsigned version) {
return version == 2 || version == 3 || version == 4;
@@ -251,6 +252,7 @@ class DWARFContextInMemory : public DWARFContext {
DWARFSection AppleTypesSection;
DWARFSection AppleNamespacesSection;
DWARFSection AppleObjCSection;
+ StringRef CUIndexSection;
SmallVector<SmallString<32>, 4> UncompressedSections;
@@ -293,6 +295,7 @@ public:
StringRef getAddrSection() override {
return AddrSection;
}
+ StringRef getCUIndexSection() override { return CUIndexSection; }
};
}
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
new file mode 100644
index 00000000000..d50b6b1eea1
--- /dev/null
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
@@ -0,0 +1,41 @@
+//===-- DWARFUnitIndex.h --------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_DEBUGINFO_DWARFUNITINDEX_H
+#define LLVM_LIB_DEBUGINFO_DWARFUNITINDEX_H
+
+#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cstdint>
+
+namespace llvm {
+
+class DWARFUnitIndex {
+ class Header {
+ uint32_t Version;
+ uint32_t NumColumns;
+ uint32_t NumUnits;
+ uint32_t NumBuckets;
+
+ public:
+ bool parse(DataExtractor IndexData, uint32_t *OffsetPtr);
+ void dump(raw_ostream &OS) const;
+ };
+
+ class Header Header;
+
+public:
+ bool parse(DataExtractor IndexData);
+ void dump(raw_ostream &OS) const;
+};
+
+}
+
+#endif
diff --git a/llvm/lib/DebugInfo/DWARF/CMakeLists.txt b/llvm/lib/DebugInfo/DWARF/CMakeLists.txt
index d5f8a6f24ee..b3df0422acf 100644
--- a/llvm/lib/DebugInfo/DWARF/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/DWARF/CMakeLists.txt
@@ -13,6 +13,7 @@ add_llvm_library(LLVMDebugInfoDWARF
DWARFDebugRangeList.cpp
DWARFFormValue.cpp
DWARFTypeUnit.cpp
+ DWARFUnitIndex.cpp
DWARFUnit.cpp
SyntaxHighlighting.cpp
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index aecd991ff0d..7ece6787d07 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -12,6 +12,7 @@
#include "llvm/ADT/StringSwitch.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
+#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Format.h"
@@ -155,6 +156,14 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) {
}
}
+ if (DumpType == DIDT_All || DumpType == DIDT_CUIndex) {
+ OS << "\n.debug_cu_index contents:\n";
+ DataExtractor CUIndexData(getCUIndexSection(), isLittleEndian(), savedAddressByteSize);
+ DWARFUnitIndex CUIndex;
+ CUIndex.parse(CUIndexData);
+ CUIndex.dump(OS);
+ }
+
if (DumpType == DIDT_All || DumpType == DIDT_LineDwo) {
OS << "\n.debug_line.dwo contents:\n";
unsigned stmtOffset = 0;
@@ -608,6 +617,7 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
.Case("apple_namespaces", &AppleNamespacesSection.Data)
.Case("apple_namespac", &AppleNamespacesSection.Data)
.Case("apple_objc", &AppleObjCSection.Data)
+ .Case("debug_cu_index", &CUIndexSection)
// Any more debug info sections go here.
.Default(nullptr);
if (SectionData) {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
new file mode 100644
index 00000000000..5970fe03360
--- /dev/null
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -0,0 +1,41 @@
+//===-- DWARFUnitIndex.cpp ------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
+
+namespace llvm {
+
+bool DWARFUnitIndex::Header::parse(DataExtractor IndexData, uint32_t *OffsetPtr) {
+ Version = IndexData.getU32(OffsetPtr);
+ NumColumns = IndexData.getU32(OffsetPtr);
+ NumUnits = IndexData.getU32(OffsetPtr);
+ NumBuckets = IndexData.getU32(OffsetPtr);
+ return Version <= 2;
+}
+
+void DWARFUnitIndex::Header::dump(raw_ostream &OS) const {
+ OS << "Index header:\n" << format(" version: %u\n", Version)
+ << format(" columns: %u\n", NumColumns)
+ << format(" units: %u\n", NumUnits)
+ << format(" buckets: %u\n", NumBuckets);
+}
+
+bool DWARFUnitIndex::parse(DataExtractor IndexData) {
+ uint32_t Offset = 0;
+ if (!Header.parse(IndexData, &Offset))
+ return false;
+
+ return true;
+}
+
+void DWARFUnitIndex::dump(raw_ostream &OS) const {
+ Header.dump(OS);
+}
+
+}
diff --git a/llvm/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o b/llvm/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o
new file mode 100644
index 00000000000..3588369af47
--- /dev/null
+++ b/llvm/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o
Binary files differ
diff --git a/llvm/test/DebugInfo/dwarfdump-dwp.test b/llvm/test/DebugInfo/dwarfdump-dwp.test
new file mode 100644
index 00000000000..38630f6bb78
--- /dev/null
+++ b/llvm/test/DebugInfo/dwarfdump-dwp.test
@@ -0,0 +1,19 @@
+RUN: llvm-dwarfdump %p/Inputs/dwarfdump-dwp.x86_64.o | FileCheck %s
+
+; Testing the following simple dwp file:
+; a.cpp:
+; struct foo { };
+; foo a;
+; b.cpp:
+; struct foo { };
+; foo b;
+
+; CHECK: .debug_cu_index contents:
+; CHECK: version: 2
+; CHECK: columns: 4
+; CHECK: units: 2
+; CHECK: buckets: 16
+
+; TODO: debug_tu_index
+; TODO: dump the index contents
+; TODO: use the index section offset info to correctly dump debug_info
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index f641c6be536..9ab2047c352 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -68,6 +68,7 @@ DumpType("debug-dump", cl::init(DIDT_All),
clEnumValN(DIDT_Str, "str", ".debug_str"),
clEnumValN(DIDT_StrDwo, "str.dwo", ".debug_str.dwo"),
clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo", ".debug_str_offsets.dwo"),
+ clEnumValN(DIDT_CUIndex, "cu_index", ".debug_cu_index"),
clEnumValEnd));
static void error(StringRef Filename, std::error_code EC) {
OpenPOWER on IntegriCloud