diff options
author | Zachary Turner <zturner@google.com> | 2018-10-26 00:17:31 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2018-10-26 00:17:31 +0000 |
commit | ed2597e9090d56ce2e6247688f0411737a5f8eb6 (patch) | |
tree | 0520fc185f49acc4adbb95a2dde4d08db31fbca5 /llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp | |
parent | e2c5cbc1643f8324fa84c2a44918262cacbbe2c4 (diff) | |
download | bcm5719-llvm-ed2597e9090d56ce2e6247688f0411737a5f8eb6.tar.gz bcm5719-llvm-ed2597e9090d56ce2e6247688f0411737a5f8eb6.zip |
Dump public symbol records in pdb2yaml mode
llvm-svn: 345348
Diffstat (limited to 'llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp')
-rw-r--r-- | llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp b/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp index 521e27fc089..62b5c428d41 100644 --- a/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/YAMLOutputStyle.cpp @@ -18,10 +18,13 @@ #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Native/DbiStream.h" +#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" #include "llvm/DebugInfo/PDB/Native/InfoStream.h" #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/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/SymbolStream.h" #include "llvm/DebugInfo/PDB/Native/TpiStream.h" using namespace llvm; @@ -68,6 +71,9 @@ Error YAMLOutputStyle::dump() { if (auto EC = dumpIpiStream()) return EC; + if (auto EC = dumpPublics()) + return EC; + flush(); return Error::success(); } @@ -326,6 +332,42 @@ Error YAMLOutputStyle::dumpIpiStream() { return Error::success(); } +Error YAMLOutputStyle::dumpPublics() { + if (!opts::pdb2yaml::PublicsStream) + return Error::success(); + + Obj.PublicsStream.emplace(); + auto ExpectedPublics = File.getPDBPublicsStream(); + if (!ExpectedPublics) { + llvm::consumeError(ExpectedPublics.takeError()); + return Error::success(); + } + + PublicsStream &Publics = *ExpectedPublics; + const GSIHashTable &PublicsTable = Publics.getPublicsTable(); + + auto ExpectedSyms = File.getPDBSymbolStream(); + if (!ExpectedSyms) { + llvm::consumeError(ExpectedSyms.takeError()); + return Error::success(); + } + + BinaryStreamRef SymStream = + ExpectedSyms->getSymbolArray().getUnderlyingStream(); + for (uint32_t PubSymOff : PublicsTable) { + Expected<CVSymbol> Sym = readSymbolFromStream(SymStream, PubSymOff); + if (!Sym) + return Sym.takeError(); + auto ES = CodeViewYAML::SymbolRecord::fromCodeViewSymbol(*Sym); + if (!ES) + return ES.takeError(); + + Obj.PublicsStream->PubSyms.push_back(*ES); + } + + return Error::success(); +} + void YAMLOutputStyle::flush() { Out << Obj; outs().flush(); |