[llvm] r252781 - dwarfdump: First piece of support for DWP dumping
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 11 11:28:21 PST 2015
Author: dblaikie
Date: Wed Nov 11 13:28:21 2015
New Revision: 252781
URL: http://llvm.org/viewvc/llvm-project?rev=252781&view=rev
Log:
dwarfdump: First piece of support for DWP dumping
Just a tiny piece of index dumping - the header in this instance.
Added:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o
llvm/trunk/test/DebugInfo/dwarfdump-dwp.test
Modified:
llvm/trunk/include/llvm/DebugInfo/DIContext.h
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=252781&r1=252780&r2=252781&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Wed Nov 11 13:28:21 2015
@@ -123,7 +123,8 @@ enum DIDumpType {
DIDT_AppleNames,
DIDT_AppleTypes,
DIDT_AppleNamespaces,
- DIDT_AppleObjC
+ DIDT_AppleObjC,
+ DIDT_CUIndex,
};
class DIContext {
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=252781&r1=252780&r2=252781&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Wed Nov 11 13:28:21 2015
@@ -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 DWAR
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; }
};
}
Added: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h?rev=252781&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h Wed Nov 11 13:28:21 2015
@@ -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
Modified: llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt?rev=252781&r1=252780&r2=252781&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt Wed Nov 11 13:28:21 2015
@@ -13,6 +13,7 @@ add_llvm_library(LLVMDebugInfoDWARF
DWARFDebugRangeList.cpp
DWARFFormValue.cpp
DWARFTypeUnit.cpp
+ DWARFUnitIndex.cpp
DWARFUnit.cpp
SyntaxHighlighting.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=252781&r1=252780&r2=252781&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Wed Nov 11 13:28:21 2015
@@ -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,
}
}
+ 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::DWARFContextInMemo
.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) {
Added: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp?rev=252781&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp (added)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp Wed Nov 11 13:28:21 2015
@@ -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);
+}
+
+}
Added: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o?rev=252781&view=auto
==============================================================================
Binary files llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o (added) and llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o Wed Nov 11 13:28:21 2015 differ
Added: llvm/trunk/test/DebugInfo/dwarfdump-dwp.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-dwp.test?rev=252781&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-dwp.test (added)
+++ llvm/trunk/test/DebugInfo/dwarfdump-dwp.test Wed Nov 11 13:28:21 2015
@@ -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
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=252781&r1=252780&r2=252781&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Wed Nov 11 13:28:21 2015
@@ -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) {
More information about the llvm-commits
mailing list