From 3b14764ce55170ef470fc233c02c16d39a831c5d Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Sat, 8 Oct 2016 01:12:01 +0000 Subject: [pdb] Dump Module Symbols to Yaml. This is the first step towards round-tripping symbol information, and thusly being able to write symbol information to a PDB. This patch writes the symbol information for each compiland to the Yaml when running in pdb2yaml mode. There's still some loose ends, such as what to do about relocations (necessary in order to print linkage names), how to print enums with friendly names, and how to give the dumper access to the StringTable, but this is a good first start. llvm-svn: 283641 --- llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp') diff --git a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp index ee1875c6b67..3f2733d701a 100644 --- a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp +++ b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp @@ -12,8 +12,10 @@ #include "PdbYaml.h" #include "llvm-pdbdump.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" +#include "llvm/DebugInfo/PDB/Raw/ModStream.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/TpiStream.h" @@ -27,6 +29,8 @@ YAMLOutputStyle::YAMLOutputStyle(PDBFile &File) Error YAMLOutputStyle::dump() { if (opts::pdb2yaml::StreamDirectory) opts::pdb2yaml::StreamMetadata = true; + if (opts::pdb2yaml::DbiModuleSyms) + opts::pdb2yaml::DbiModuleInfo = true; if (opts::pdb2yaml::DbiModuleSourceFileInfo) opts::pdb2yaml::DbiModuleInfo = true; if (opts::pdb2yaml::DbiModuleInfo) @@ -152,6 +156,25 @@ Error YAMLOutputStyle::dumpDbiStream() { DMI.Obj = MI.Info.getObjFileName(); if (opts::pdb2yaml::DbiModuleSourceFileInfo) DMI.SourceFiles = MI.SourceFiles; + + if (opts::pdb2yaml::DbiModuleSyms && + MI.Info.getModuleStreamIndex() != kInvalidStreamIndex) { + DMI.Modi.emplace(); + auto ModStreamData = msf::MappedBlockStream::createIndexedStream( + File.getMsfLayout(), File.getMsfBuffer(), + MI.Info.getModuleStreamIndex()); + + pdb::ModStream ModS(MI.Info, std::move(ModStreamData)); + if (auto EC = ModS.reload()) + return EC; + + DMI.Modi->Signature = ModS.signature(); + bool HadError = false; + for (auto &Sym : ModS.symbols(&HadError)) { + pdb::yaml::PdbSymbolRecord Record{Sym}; + DMI.Modi->Symbols.push_back(Record); + } + } Obj.DbiStream->ModInfos.push_back(DMI); } } -- cgit v1.2.3