[llvm] r308764 - [PDB] Dump extra info about the publics stream

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 21 11:28:55 PDT 2017


Author: rnk
Date: Fri Jul 21 11:28:55 2017
New Revision: 308764

URL: http://llvm.org/viewvc/llvm-project?rev=308764&view=rev
Log:
[PDB] Dump extra info about the publics stream

This includes the hash table, the address map, and the thunk table and
section offset table. The last two are only used for incremental
linking, which LLD doesn't support, so they are less interesting. The
hash table is particularly important to get right, since this is the one
of the streams that debuggers use to translate addresses to symbols.

Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
    llvm/trunk/lib/DebugInfo/PDB/Native/GSI.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/GSI.h
    llvm/trunk/lib/DebugInfo/PDB/Native/PublicsStream.cpp
    llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
    llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
    llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h?rev=308764&r1=308763&r2=308764&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PublicsStream.h Fri Jul 21 11:28:55 2017
@@ -36,6 +36,8 @@ public:
   Expected<const codeview::CVSymbolArray &> getSymbolArray() const;
   iterator_range<codeview::CVSymbolArray::Iterator>
   getSymbols(bool *HadError) const;
+  FixedStreamArray<PSHashRecord> getHashRecords() const { return HashRecords; }
+  FixedStreamArray<PSHashRecord> getHashBitmap() const { return HashBitmap; }
   FixedStreamArray<support::ulittle32_t> getHashBuckets() const {
     return HashBuckets;
   }
@@ -56,8 +58,8 @@ private:
 
   std::unique_ptr<msf::MappedBlockStream> Stream;
   uint32_t NumBuckets = 0;
-  ArrayRef<uint8_t> Bitmap;
   FixedStreamArray<PSHashRecord> HashRecords;
+  ArrayRef<uint8_t> HashBitmap;
   FixedStreamArray<support::ulittle32_t> HashBuckets;
   FixedStreamArray<support::ulittle32_t> AddressMap;
   FixedStreamArray<support::ulittle32_t> ThunkMap;

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/GSI.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/GSI.cpp?rev=308764&r1=308763&r2=308764&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/GSI.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/GSI.cpp Fri Jul 21 11:28:55 2017
@@ -29,6 +29,7 @@ static Error checkHashHdrVersion(const G
 }
 
 Error readGSIHashBuckets(FixedStreamArray<support::ulittle32_t> &HashBuckets,
+                         ArrayRef<uint8_t> &HashBitmap,
                          const GSIHashHeader *HashHdr,
                          BinaryStreamReader &Reader) {
   if (auto EC = checkHashHdrVersion(HashHdr))
@@ -36,15 +37,14 @@ Error readGSIHashBuckets(FixedStreamArra
 
   // Before the actual hash buckets, there is a bitmap of length determined by
   // IPHR_HASH.
-  ArrayRef<uint8_t> Bitmap;
   size_t BitmapSizeInBits = alignTo(IPHR_HASH + 1, 32);
   uint32_t NumBitmapEntries = BitmapSizeInBits / 8;
-  if (auto EC = Reader.readBytes(Bitmap, NumBitmapEntries))
+  if (auto EC = Reader.readBytes(HashBitmap, NumBitmapEntries))
     return joinErrors(std::move(EC),
                       make_error<RawError>(raw_error_code::corrupt_file,
                                            "Could not read a bitmap."));
   uint32_t NumBuckets = 0;
-  for (uint8_t B : Bitmap)
+  for (uint8_t B : HashBitmap)
     NumBuckets += countPopulation(B);
 
   // Hash buckets follow.

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/GSI.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/GSI.h?rev=308764&r1=308763&r2=308764&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/GSI.h (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/GSI.h Fri Jul 21 11:28:55 2017
@@ -41,7 +41,7 @@ namespace pdb {
 static const unsigned IPHR_HASH = 4096;
 
 /// Header of the hash tables found in the globals and publics sections.
-/// Based on GSIHashHeader in
+/// Based on GSIHashHdr in
 /// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
 struct GSIHashHeader {
   enum : unsigned {

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/PublicsStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PublicsStream.cpp?rev=308764&r1=308763&r2=308764&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PublicsStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PublicsStream.cpp Fri Jul 21 11:28:55 2017
@@ -75,7 +75,7 @@ Error PublicsStream::reload() {
   if (auto EC = readGSIHashRecords(HashRecords, HashHdr, Reader))
     return EC;
 
-  if (auto EC = readGSIHashBuckets(HashBuckets, HashHdr, Reader))
+  if (auto EC = readGSIHashBuckets(HashBuckets, HashBitmap, HashHdr, Reader))
     return EC;
   NumBuckets = HashBuckets.size();
 

Modified: llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp?rev=308764&r1=308763&r2=308764&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp Fri Jul 21 11:28:55 2017
@@ -882,6 +882,52 @@ Error DumpOutputStyle::dumpPublics() {
     P.formatLine("Error while processing public symbol records.  {0}",
                  toString(std::move(EC)));
 
+  // Return early if we aren't dumping public hash table and address map info.
+  if (!opts::dump::DumpPublicExtras)
+    return Error::success();
+
+  P.formatLine("Hash Records");
+  {
+    AutoIndent Indent2(P);
+    for (const PSHashRecord &HR : Publics.getHashRecords())
+      P.formatLine("off = {0}, refcnt = {1}", uint32_t(HR.Off),
+                   uint32_t(HR.CRef));
+  }
+
+  // FIXME: Dump the bitmap.
+
+  P.formatLine("Hash Buckets");
+  {
+    AutoIndent Indent2(P);
+    for (uint32_t Hash : Publics.getHashBuckets())
+      P.formatLine("{0:x8}", Hash);
+  }
+
+  P.formatLine("Address Map");
+  {
+    // These are offsets into the publics stream sorted by secidx:secrel.
+    AutoIndent Indent2(P);
+    for (uint32_t Addr : Publics.getAddressMap())
+      P.formatLine("off = {0}", Addr);
+  }
+
+  // The thunk map is optional debug info used for ILT thunks.
+  if (!Publics.getThunkMap().empty()) {
+    P.formatLine("Thunk Map");
+    AutoIndent Indent2(P);
+    for (uint32_t Addr : Publics.getThunkMap())
+      P.formatLine("{0:x8}", Addr);
+  }
+
+  // The section offsets table appears to be empty when incremental linking
+  // isn't in use.
+  if (!Publics.getSectionOffsets().empty()) {
+    P.formatLine("Section Offsets");
+    AutoIndent Indent2(P);
+    for (const SectionOffset &SO : Publics.getSectionOffsets())
+      P.formatLine("{0:x4}:{1:x8}", uint16_t(SO.Isect), uint32_t(SO.Off));
+  }
+
   return Error::success();
 }
 

Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp?rev=308764&r1=308763&r2=308764&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Fri Jul 21 11:28:55 2017
@@ -452,6 +452,9 @@ cl::opt<bool> DumpTypeDependents(
 // SYMBOL OPTIONS
 cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"),
                           cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
+cl::opt<bool> DumpPublicExtras("public-extras",
+                               cl::desc("dump Publics hashes and address maps"),
+                               cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
 cl::opt<bool> DumpSymbols("symbols", cl::desc("dump module symbols"),
                           cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
 

Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h?rev=308764&r1=308763&r2=308764&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h Fri Jul 21 11:28:55 2017
@@ -144,6 +144,7 @@ extern llvm::cl::list<uint32_t> DumpIdIn
 extern llvm::cl::opt<bool> DumpSymbols;
 extern llvm::cl::opt<bool> DumpSymRecordBytes;
 extern llvm::cl::opt<bool> DumpPublics;
+extern llvm::cl::opt<bool> DumpPublicExtras;
 extern llvm::cl::opt<bool> DumpSectionContribs;
 extern llvm::cl::opt<bool> DumpSectionMap;
 extern llvm::cl::opt<bool> DumpModules;




More information about the llvm-commits mailing list