DIDT_AppleNames,
DIDT_AppleTypes,
DIDT_AppleNamespaces,
- DIDT_AppleObjC
+ DIDT_AppleObjC,
+ DIDT_CUIndex,
};
class DIContext {
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;
DWARFSection AppleTypesSection;
DWARFSection AppleNamespacesSection;
DWARFSection AppleObjCSection;
+ StringRef CUIndexSection;
SmallVector<SmallString<32>, 4> UncompressedSections;
StringRef getAddrSection() override {
return AddrSection;
}
+ StringRef getCUIndexSection() override { return CUIndexSection; }
};
}
--- /dev/null
+//===-- 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
DWARFDebugRangeList.cpp
DWARFFormValue.cpp
DWARFTypeUnit.cpp
+ DWARFUnitIndex.cpp
DWARFUnit.cpp
SyntaxHighlighting.cpp
#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"
}
}
+ 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;
.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) {
--- /dev/null
+//===-- 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);
+}
+
+}
--- /dev/null
+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
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) {