diff options
author | Rui Ueyama <ruiu@google.com> | 2016-05-20 19:55:17 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2016-05-20 19:55:17 +0000 |
commit | 0fcd82605e448f52d80de4c74bd0a19376b9052e (patch) | |
tree | d4a605b46337baaea7bd2dcb1ed1f50559876dc6 /llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp | |
parent | f7449a179b5398295ece62dbcc250686179a6dfd (diff) | |
download | llvm-0fcd82605e448f52d80de4c74bd0a19376b9052e.zip llvm-0fcd82605e448f52d80de4c74bd0a19376b9052e.tar.gz llvm-0fcd82605e448f52d80de4c74bd0a19376b9052e.tar.bz2 |
pdbdump: print out symbol names referred by publics stream.
DBI stream contains a stream number of the symbol record stream.
Symbol record streams is an array of length-type-value members.
Each member represents one symbol.
Publics stream contains offsets to the symbol record stream.
This patch is to print out all symbols that are referenced by
the publics stream.
Note that even with this patch, llvm-pdbdump cannot dump all the
information in a publics stream since it contains more information
than symbol names. I'll improve it in followup patches.
Differential Revision: http://reviews.llvm.org/D20480
llvm-svn: 270262
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp index a8b7874..2e0b8971 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp @@ -27,9 +27,11 @@ #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/StreamReader.h" +#include "llvm/DebugInfo/PDB/Raw/SymbolStream.h" #include "llvm/ADT/BitVector.h" #include "llvm/Support/Endian.h" @@ -56,8 +58,7 @@ struct PublicsStream::HeaderInfo { ulittle32_t NumSections; }; - -// This is GSIHashHdr struct defined in +// This is GSIHashHdr. struct PublicsStream::GSIHashHeader { enum : unsigned { HdrSignature = ~0U, @@ -69,8 +70,9 @@ struct PublicsStream::GSIHashHeader { ulittle32_t NumBuckets; }; -struct PublicsStream::HRFile { - ulittle32_t Off; +// This is HRFile. +struct PublicsStream::HashRecord { + ulittle32_t Off; // Offset in the symbol record stream ulittle32_t CRef; }; @@ -84,7 +86,7 @@ struct SectionOffset { } PublicsStream::PublicsStream(PDBFile &File, uint32_t StreamNum) - : StreamNum(StreamNum), Stream(StreamNum, File) {} + : Pdb(File), StreamNum(StreamNum), Stream(StreamNum, File) {} PublicsStream::~PublicsStream() {} @@ -114,12 +116,12 @@ Error PublicsStream::reload() { return make_error<RawError>(raw_error_code::corrupt_file, "Publics Stream does not contain a header."); - // An array of HRFile follows. Read them. - if (HashHdr->HrSize % sizeof(HRFile)) + // An array of HashRecord follows. Read them. + if (HashHdr->HrSize % sizeof(HashRecord)) return make_error<RawError>(raw_error_code::corrupt_file, "Invalid HR array size."); - std::vector<HRFile> HRs(HashHdr->HrSize / sizeof(HRFile)); - if (auto EC = Reader.readArray<HRFile>(HRs)) + HashRecords.resize(HashHdr->HrSize / sizeof(HashRecord)); + if (auto EC = Reader.readArray<HashRecord>(HashRecords)) return make_error<RawError>(raw_error_code::corrupt_file, "Could not read an HR array"); @@ -178,3 +180,20 @@ Error PublicsStream::reload() { "Corrupted publics stream."); return Error::success(); } + +std::vector<std::string> PublicsStream::getSymbols() const { + auto SymbolS = Pdb.getPDBSymbolStream(); + if (SymbolS.takeError()) + return {}; + SymbolStream &SS = SymbolS.get(); + + std::vector<std::string> Ret; + for (const HashRecord &HR : HashRecords) { + // For some reason, symbol offset is biased by one. + Expected<std::string> Name = SS.getSymbolName(HR.Off - 1); + if (Name.takeError()) + return Ret; + Ret.push_back(std::move(Name.get())); + } + return Ret; +} |