[PDB] Improve GSI hash table dumping for publics and globals
The PDB "symbol stream" actually contains symbol records for the publics
and the globals stream. The globals and publics streams are essentially
hash tables that point into a single stream of records. In order to
match cvdump's behavior, we need to only dump symbol records referenced
from the hash table. This patch implements that, and then implements
global stream dumping, since it's just a subset of public stream
dumping.
Now we shouldn't see S_PROCREF or S_GDATA32 records when dumping
publics, and instead we should see those record in the globals stream.
llvm-svn: 309066
diff --git a/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
index 3b4e18d..7a48e3d 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
@@ -41,9 +41,8 @@
using namespace llvm::support;
using namespace llvm::pdb;
-PublicsStream::PublicsStream(PDBFile &File,
- std::unique_ptr<MappedBlockStream> Stream)
- : Pdb(File), Stream(std::move(Stream)) {}
+PublicsStream::PublicsStream(std::unique_ptr<MappedBlockStream> Stream)
+ : Stream(std::move(Stream)) {}
PublicsStream::~PublicsStream() = default;
@@ -64,20 +63,14 @@
return make_error<RawError>(raw_error_code::corrupt_file,
"Publics Stream does not contain a header.");
- // Read PSGSIHDR and GSIHashHdr structs.
+ // Read PSGSIHDR struct.
if (Reader.readObject(Header))
return make_error<RawError>(raw_error_code::corrupt_file,
"Publics Stream does not contain a header.");
- if (auto EC = readGSIHashHeader(HashHdr, Reader))
- return EC;
-
- if (auto EC = readGSIHashRecords(HashRecords, HashHdr, Reader))
- return EC;
-
- if (auto EC = readGSIHashBuckets(HashBuckets, HashBitmap, HashHdr, Reader))
- return EC;
- NumBuckets = HashBuckets.size();
+ // Read the hash table.
+ if (auto E = PublicsTable.read(Reader))
+ return E;
// Something called "address map" follows.
uint32_t NumAddressMapEntries = Header->AddrMap / sizeof(uint32_t);
@@ -105,26 +98,3 @@
"Corrupted publics stream.");
return Error::success();
}
-
-iterator_range<codeview::CVSymbolArray::Iterator>
-PublicsStream::getSymbols(bool *HadError) const {
- auto SymbolS = Pdb.getPDBSymbolStream();
- if (SymbolS.takeError()) {
- codeview::CVSymbolArray::Iterator Iter;
- return make_range(Iter, Iter);
- }
- SymbolStream &SS = SymbolS.get();
-
- return SS.getSymbols(HadError);
-}
-
-Expected<const codeview::CVSymbolArray &>
-PublicsStream::getSymbolArray() const {
- auto SymbolS = Pdb.getPDBSymbolStream();
- if (!SymbolS)
- return SymbolS.takeError();
-
- return SymbolS->getSymbolArray();
-}
-
-Error PublicsStream::commit() { return Error::success(); }