[llvm] r282239 - Revert r282238 "Revert r282235 "[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section.""

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 23 04:01:54 PDT 2016


Author: grimar
Date: Fri Sep 23 06:01:53 2016
New Revision: 282239

URL: http://llvm.org/viewvc/llvm-project?rev=282239&view=rev
Log:
Revert r282238 "Revert r282235 "[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section.""

Build bot issues (http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15856/steps/ninja%20check%201/logs/FAIL%3A%20LLVM%3A%3Adwarfdump-dump-gdbindex.test)
should be fixed in that version. Issue was that MSVS does not support "%zu". Though it works fine on MSCS 2015,
Bot looks running MSVS 2013 that does not like it. MSDN also says that "z" prefix is not supported: https://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
I had to use PRId64 instead.

Original commit message:

[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section.

gold linker's --gdb-index option currently is able to create the .gdb_index section that allows GDB to locate and read the .dwo files as it needs them,
this helps reduce the total size of the object files processed by the linker.

More info about that:
https://gcc.gnu.org/wiki/DebugFission
https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html

Patch teaches dwarfdump tool to dump this section.

Differential revision: https://reviews.llvm.org/D21503

Added:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h
      - copied unchanged from r282237, llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
      - copied, changed from r282237, llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-gdbindex-v7.elf-x86-64
      - copied unchanged from r282237, llvm/trunk/test/DebugInfo/Inputs/dwarfdump-gdbindex-v7.elf-x86-64
    llvm/trunk/test/DebugInfo/dwarfdump-dump-gdbindex.test
      - copied unchanged from r282237, llvm/trunk/test/DebugInfo/dwarfdump-dump-gdbindex.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=282239&r1=282238&r2=282239&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Fri Sep 23 06:01:53 2016
@@ -124,6 +124,7 @@ enum DIDumpType {
   DIDT_AppleNamespaces,
   DIDT_AppleObjC,
   DIDT_CUIndex,
+  DIDT_GdbIndex,
   DIDT_TUIndex,
 };
 

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=282239&r1=282238&r2=282239&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Fri Sep 23 06:01:53 2016
@@ -20,6 +20,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
+#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
 #include "llvm/DebugInfo/DWARF/DWARFSection.h"
 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
 
@@ -41,6 +42,7 @@ class DWARFContext : public DIContext {
   DWARFUnitSection<DWARFCompileUnit> CUs;
   std::deque<DWARFUnitSection<DWARFTypeUnit>> TUs;
   std::unique_ptr<DWARFUnitIndex> CUIndex;
+  std::unique_ptr<DWARFGdbIndex> GdbIndex;
   std::unique_ptr<DWARFUnitIndex> TUIndex;
   std::unique_ptr<DWARFDebugAbbrev> Abbrev;
   std::unique_ptr<DWARFDebugLoc> Loc;
@@ -149,6 +151,7 @@ public:
   }
 
   const DWARFUnitIndex &getCUIndex();
+  DWARFGdbIndex &getGdbIndex();
   const DWARFUnitIndex &getTUIndex();
 
   /// Get a pointer to the parsed DebugAbbrev object.
@@ -220,6 +223,7 @@ public:
   virtual const DWARFSection& getAppleNamespacesSection() = 0;
   virtual const DWARFSection& getAppleObjCSection() = 0;
   virtual StringRef getCUIndexSection() = 0;
+  virtual StringRef getGdbIndexSection() = 0;
   virtual StringRef getTUIndexSection() = 0;
 
   static bool isSupportedVersion(unsigned version) {
@@ -272,6 +276,7 @@ class DWARFContextInMemory : public DWAR
   DWARFSection AppleNamespacesSection;
   DWARFSection AppleObjCSection;
   StringRef CUIndexSection;
+  StringRef GdbIndexSection;
   StringRef TUIndexSection;
 
   SmallVector<SmallString<32>, 4> UncompressedSections;
@@ -318,6 +323,7 @@ public:
     return AddrSection;
   }
   StringRef getCUIndexSection() override { return CUIndexSection; }
+  StringRef getGdbIndexSection() override { return GdbIndexSection; }
   StringRef getTUIndexSection() override { return TUIndexSection; }
 };
 

Modified: llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt?rev=282239&r1=282238&r2=282239&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt Fri Sep 23 06:01:53 2016
@@ -13,6 +13,7 @@ add_llvm_library(LLVMDebugInfoDWARF
   DWARFDebugMacro.cpp
   DWARFDebugRangeList.cpp
   DWARFFormValue.cpp
+  DWARFGdbIndex.cpp
   DWARFTypeUnit.cpp
   DWARFUnitIndex.cpp
   DWARFUnit.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=282239&r1=282238&r2=282239&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Fri Sep 23 06:01:53 2016
@@ -256,6 +256,12 @@ void DWARFContext::dump(raw_ostream &OS,
     }
   }
 
+  if ((DumpType == DIDT_All || DumpType == DIDT_GdbIndex) &&
+      !getGdbIndexSection().empty()) {
+    OS << "\n.gnu_index contents:\n";
+    getGdbIndex().dump(OS);
+  }
+
   if (DumpType == DIDT_All || DumpType == DIDT_AppleNames)
     dumpAccelSection(OS, "apple_names", getAppleNamesSection(),
                      getStringSection(), isLittleEndian());
@@ -295,6 +301,16 @@ const DWARFUnitIndex &DWARFContext::getT
   return *TUIndex;
 }
 
+DWARFGdbIndex &DWARFContext::getGdbIndex() {
+  if (GdbIndex)
+    return *GdbIndex;
+
+  DataExtractor GdbIndexData(getGdbIndexSection(), true /*LE*/, 0);
+  GdbIndex = llvm::make_unique<DWARFGdbIndex>();
+  GdbIndex->parse(GdbIndexData);
+  return *GdbIndex;
+}
+
 const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
   if (Abbrev)
     return Abbrev.get();
@@ -718,6 +734,7 @@ DWARFContextInMemory::DWARFContextInMemo
             .Case("apple_objc", &AppleObjCSection.Data)
             .Case("debug_cu_index", &CUIndexSection)
             .Case("debug_tu_index", &TUIndexSection)
+            .Case("gdb_index", &GdbIndexSection)
             // Any more debug info sections go here.
             .Default(nullptr);
     if (SectionData) {

Copied: llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp (from r282237, llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp?p2=llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp&p1=llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp&r1=282237&r2=282239&rev=282239&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp Fri Sep 23 06:01:53 2016
@@ -18,8 +18,8 @@ using namespace llvm;
 // https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html
 
 void DWARFGdbIndex::dumpCUList(raw_ostream &OS) const {
-  OS << format("\n  CU list offset = 0x%x, has %zu entries:", CuListOffset,
-               CuList.size())
+  OS << format("\n  CU list offset = 0x%x, has %" PRId64 " entries:",
+               CuListOffset, (uint64_t)CuList.size())
      << '\n';
   uint32_t I = 0;
   for (const CompUnitEntry &CU : CuList)
@@ -28,8 +28,8 @@ void DWARFGdbIndex::dumpCUList(raw_ostre
 }
 
 void DWARFGdbIndex::dumpAddressArea(raw_ostream &OS) const {
-  OS << format("\n  Address area offset = 0x%x, has %zu entries:",
-               AddressAreaOffset, AddressArea.size())
+  OS << format("\n  Address area offset = 0x%x, has %" PRId64 " entries:",
+               AddressAreaOffset, (uint64_t)AddressArea.size())
      << '\n';
   for (const AddressEntry &Addr : AddressArea)
     OS << format(
@@ -38,8 +38,9 @@ void DWARFGdbIndex::dumpAddressArea(raw_
 }
 
 void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
-  OS << format("\n  Symbol table offset = 0x%x, size = %zu, filled slots:",
-               SymbolTableOffset, SymbolTable.size())
+  OS << format("\n  Symbol table offset = 0x%x, size = %" PRId64
+               ", filled slots:",
+               SymbolTableOffset, (uint64_t)SymbolTable.size())
      << '\n';
   uint32_t I = -1;
   for (const SymTableEntry &E : SymbolTable) {
@@ -66,8 +67,8 @@ void DWARFGdbIndex::dumpSymbolTable(raw_
 }
 
 void DWARFGdbIndex::dumpConstantPool(raw_ostream &OS) const {
-  OS << format("\n  Constant pool offset = 0x%x, has %zu CU vectors:",
-               ConstantPoolOffset, ConstantPoolVectors.size());
+  OS << format("\n  Constant pool offset = 0x%x, has %" PRId64 " CU vectors:",
+               ConstantPoolOffset, (uint64_t)ConstantPoolVectors.size());
   uint32_t I = 0;
   for (const auto &V : ConstantPoolVectors) {
     OS << format("\n    %d(0x%x): ", I++, V.first);

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=282239&r1=282238&r2=282239&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Fri Sep 23 06:01:53 2016
@@ -71,6 +71,7 @@ static cl::opt<DIDumpType> DumpType(
         clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo",
                    ".debug_str_offsets.dwo"),
         clEnumValN(DIDT_CUIndex, "cu_index", ".debug_cu_index"),
+        clEnumValN(DIDT_GdbIndex, "gdb_index", ".gdb_index"),
         clEnumValN(DIDT_TUIndex, "tu_index", ".debug_tu_index"), clEnumValEnd));
 
 static void error(StringRef Filename, std::error_code EC) {




More information about the llvm-commits mailing list