dwarfdump: DWP type unit index dumping skeleton
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 11 Nov 2015 19:40:49 +0000 (19:40 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 11 Nov 2015 19:40:49 +0000 (19:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252786 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DIContext.h
include/llvm/DebugInfo/DWARF/DWARFContext.h
lib/DebugInfo/DWARF/DWARFContext.cpp
test/DebugInfo/dwarfdump-dwp.test

index 873084705079be856599df7b15f06dc6103bd482..eff0e3e6786c6f90ad9294c6055cb2f094f2d274 100644 (file)
@@ -125,6 +125,7 @@ enum DIDumpType {
   DIDT_AppleNamespaces,
   DIDT_AppleObjC,
   DIDT_CUIndex,
+  DIDT_TUIndex,
 };
 
 class DIContext {
index 01d25f7aa8a0445656dfe7acbf8de66bfc77c296..66204d7443ecdcdd50e1584986224dfba8101b4c 100644 (file)
@@ -204,6 +204,7 @@ public:
   virtual const DWARFSection& getAppleNamespacesSection() = 0;
   virtual const DWARFSection& getAppleObjCSection() = 0;
   virtual StringRef getCUIndexSection() = 0;
+  virtual StringRef getTUIndexSection() = 0;
 
   static bool isSupportedVersion(unsigned version) {
     return version == 2 || version == 3 || version == 4;
@@ -253,6 +254,7 @@ class DWARFContextInMemory : public DWARFContext {
   DWARFSection AppleNamespacesSection;
   DWARFSection AppleObjCSection;
   StringRef CUIndexSection;
+  StringRef TUIndexSection;
 
   SmallVector<SmallString<32>, 4> UncompressedSections;
 
@@ -296,6 +298,7 @@ public:
     return AddrSection;
   }
   StringRef getCUIndexSection() override { return CUIndexSection; }
+  StringRef getTUIndexSection() override { return TUIndexSection; }
 };
 
 }
index 9d5a78a05708a5fa19860dce6e5daab48f7ec5c5..d6ed6f842070c87cc1ba503d081a210c996ffd09 100644 (file)
@@ -165,6 +165,15 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) {
     CUIndex.dump(OS);
   }
 
+  if (DumpType == DIDT_All || DumpType == DIDT_TUIndex) {
+    OS << "\n.debug_tu_index contents:\n";
+    DataExtractor TUIndexData(getTUIndexSection(), isLittleEndian(),
+                              savedAddressByteSize);
+    DWARFUnitIndex TUIndex;
+    TUIndex.parse(TUIndexData);
+    TUIndex.dump(OS);
+  }
+
   if (DumpType == DIDT_All || DumpType == DIDT_LineDwo) {
     OS << "\n.debug_line.dwo contents:\n";
     unsigned stmtOffset = 0;
@@ -619,6 +628,7 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
             .Case("apple_namespac", &AppleNamespacesSection.Data)
             .Case("apple_objc", &AppleObjCSection.Data)
             .Case("debug_cu_index", &CUIndexSection)
+            .Case("debug_tu_index", &TUIndexSection)
             // Any more debug info sections go here.
             .Default(nullptr);
     if (SectionData) {
index 38630f6bb784e3bd15fafedf0d66327fff6f9213..c3b8e1c4f9fa4d7bbfb8cb62312318953dff5234 100644 (file)
@@ -9,11 +9,18 @@ RUN: llvm-dwarfdump %p/Inputs/dwarfdump-dwp.x86_64.o | FileCheck %s
 ;   foo b;
 
 ; CHECK: .debug_cu_index contents:
-; CHECK: version: 2
-; CHECK: columns: 4
-; CHECK:   units: 2
-; CHECK: buckets: 16
+; CHECK-NEXT: Index header:
+; CHECK-NEXT: version: 2
+; CHECK-NEXT: columns: 4
+; CHECK-NEXT:   units: 2
+; CHECK-NEXT: buckets: 16
+
+; CHECK: .debug_tu_index contents:
+; CHECK-NEXT: Index header:
+; CHECK-NEXT: version: 2
+; CHECK-NEXT: columns: 4
+; CHECK-NEXT:   units: 1
+; CHECK-NEXT: buckets: 16
 
-; TODO: debug_tu_index
 ; TODO: dump the index contents
 ; TODO: use the index section offset info to correctly dump debug_info