diff options
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp | 112 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbutil/DumpOutputStyle.h | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp | 5 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbutil/llvm-pdbutil.h | 2 |
4 files changed, 85 insertions, 38 deletions
diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp index 07fc38d4406..605fff92167 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -49,6 +49,7 @@ #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h" #include "llvm/DebugInfo/PDB/Native/PDBFile.h" #include "llvm/DebugInfo/PDB/Native/PublicsStream.h" +#include "llvm/DebugInfo/PDB/Native/SymbolStream.h" #include "llvm/DebugInfo/PDB/Native/RawError.h" #include "llvm/DebugInfo/PDB/Native/TpiHashing.h" #include "llvm/DebugInfo/PDB/Native/TpiStream.h" @@ -129,6 +130,11 @@ Error DumpOutputStyle::dump() { return EC; } + if (opts::dump::DumpGlobals) { + if (auto EC = dumpGlobals()) + return EC; + } + if (opts::dump::DumpPublics) { if (auto EC = dumpPublics()) return EC; @@ -851,58 +857,38 @@ Error DumpOutputStyle::dumpModuleSyms() { return Error::success(); } +Error DumpOutputStyle::dumpGlobals() { + printHeader(P, "Global Symbols"); + AutoIndent Indent(P); + if (!File.hasPDBGlobalsStream()) { + P.formatLine("Globals stream not present"); + return Error::success(); + } + ExitOnError Err("Error dumping globals stream"); + auto &Globals = Err(File.getPDBGlobalsStream()); + + const GSIHashTable &Table = Globals.getGlobalsTable(); + Err(dumpSymbolsFromGSI(Table, opts::dump::DumpGlobalExtras)); + return Error::success(); +} + Error DumpOutputStyle::dumpPublics() { printHeader(P, "Public Symbols"); - AutoIndent Indent(P); if (!File.hasPDBPublicsStream()) { P.formatLine("Publics stream not present"); return Error::success(); } - ExitOnError Err("Error dumping publics stream"); - - auto &Types = Err(initializeTypes(StreamTPI)); auto &Publics = Err(File.getPDBPublicsStream()); - SymbolVisitorCallbackPipeline Pipeline; - SymbolDeserializer Deserializer(nullptr, CodeViewContainer::Pdb); - MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes, Types); - Pipeline.addCallbackToPipeline(Deserializer); - Pipeline.addCallbackToPipeline(Dumper); - CVSymbolVisitor Visitor(Pipeline); - - auto ExpectedSymbols = Publics.getSymbolArray(); - if (!ExpectedSymbols) { - P.formatLine("Could not read public symbol record stream"); - return Error::success(); - } - - if (auto EC = Visitor.visitSymbolStream(*ExpectedSymbols, 0)) - P.formatLine("Error while processing public symbol records. {0}", - toString(std::move(EC))); + const GSIHashTable &PublicsTable = Publics.getPublicsTable(); + Err(dumpSymbolsFromGSI(PublicsTable, opts::dump::DumpPublicExtras)); - // Return early if we aren't dumping public hash table and address map info. + // Skip the rest if we aren't dumping extras. 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. @@ -931,6 +917,56 @@ Error DumpOutputStyle::dumpPublics() { return Error::success(); } +Error DumpOutputStyle::dumpSymbolsFromGSI(const GSIHashTable &Table, + bool HashExtras) { + auto ExpectedSyms = File.getPDBSymbolStream(); + if (!ExpectedSyms) + return ExpectedSyms.takeError(); + auto ExpectedTypes = initializeTypes(StreamTPI); + if (!ExpectedTypes) + return ExpectedTypes.takeError(); + SymbolVisitorCallbackPipeline Pipeline; + SymbolDeserializer Deserializer(nullptr, CodeViewContainer::Pdb); + MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes, *ExpectedTypes); + + Pipeline.addCallbackToPipeline(Deserializer); + Pipeline.addCallbackToPipeline(Dumper); + CVSymbolVisitor Visitor(Pipeline); + + BinaryStreamRef SymStream = + ExpectedSyms->getSymbolArray().getUnderlyingStream(); + for (uint32_t PubSymOff : Table) { + Expected<CVSymbol> Sym = readSymbolFromStream(SymStream, PubSymOff); + if (!Sym) + return Sym.takeError(); + if (auto E = Visitor.visitSymbolRecord(*Sym, PubSymOff)) + return E; + } + + // Return early if we aren't dumping public hash table and address map info. + if (!HashExtras) + return Error::success(); + + P.formatLine("Hash Records"); + { + AutoIndent Indent2(P); + for (const PSHashRecord &HR : Table.HashRecords) + 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 : Table.HashBuckets) + P.formatLine("{0:x8}", Hash); + } + + return Error::success(); +} + static std::string formatSectionCharacteristics(uint32_t IndentLevel, uint32_t C) { using SC = COFF::SectionCharacteristics; diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.h b/llvm/tools/llvm-pdbutil/DumpOutputStyle.h index 4c52289f052..d1d3e1d4892 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.h +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.h @@ -26,6 +26,8 @@ class LazyRandomTypeCollection; } namespace pdb { +class GSIHashTable; + class DumpOutputStyle : public OutputStyle { public: DumpOutputStyle(PDBFile &File); @@ -46,7 +48,9 @@ private: Error dumpModules(); Error dumpModuleFiles(); Error dumpModuleSyms(); + Error dumpGlobals(); Error dumpPublics(); + Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras); Error dumpSectionContribs(); Error dumpSectionMap(); diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp index 338e4ee9250..aae5de2b95c 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -450,6 +450,10 @@ cl::opt<bool> DumpTypeDependents( cl::cat(TypeOptions), cl::sub(DumpSubcommand)); // SYMBOL OPTIONS +cl::opt<bool> DumpGlobals("globals", cl::desc("dump Globals symbol records"), + cl::cat(SymbolOptions), cl::sub(DumpSubcommand)); +cl::opt<bool> DumpGlobalExtras("global-extras", cl::desc("dump Globals hashes"), + cl::cat(SymbolOptions), cl::sub(DumpSubcommand)); cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"), cl::cat(SymbolOptions), cl::sub(DumpSubcommand)); cl::opt<bool> DumpPublicExtras("public-extras", @@ -1066,6 +1070,7 @@ int main(int argc_, const char *argv_[]) { opts::dump::DumpXme = true; opts::dump::DumpXmi = true; opts::dump::DumpIds = true; + opts::dump::DumpGlobals = true; opts::dump::DumpPublics = true; opts::dump::DumpSectionContribs = true; opts::dump::DumpSectionMap = true; diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h index 4aeff99d6c7..0c01fae911c 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h @@ -143,6 +143,8 @@ extern llvm::cl::opt<bool> DumpIdExtras; extern llvm::cl::list<uint32_t> DumpIdIndex; extern llvm::cl::opt<bool> DumpSymbols; extern llvm::cl::opt<bool> DumpSymRecordBytes; +extern llvm::cl::opt<bool> DumpGlobals; +extern llvm::cl::opt<bool> DumpGlobalExtras; extern llvm::cl::opt<bool> DumpPublics; extern llvm::cl::opt<bool> DumpPublicExtras; extern llvm::cl::opt<bool> DumpSectionContribs; |