llvm.org GIT mirror llvm / f3aabb0
Dump public symbol records in pdb2yaml mode git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345348 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 9 months ago
6 changed file(s) with 61 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
109109 IO.mapOptional("DbiStream", Obj.DbiStream);
110110 IO.mapOptional("TpiStream", Obj.TpiStream);
111111 IO.mapOptional("IpiStream", Obj.IpiStream);
112 IO.mapOptional("PublicsStream", Obj.PublicsStream);
112113 }
113114
114115 void MappingTraits::mapping(IO &IO, MSFHeaders &Obj) {
162163 IO.mapRequired("Records", Obj.Records);
163164 }
164165
166 void MappingTraits::mapping(
167 IO &IO, pdb::yaml::PdbPublicsStream &Obj) {
168 IO.mapRequired("Records", Obj.PubSyms);
169 }
170
165171 void MappingTraits::mapping(IO &IO,
166172 NamedStreamMapping &Obj) {
167173 IO.mapRequired("Name", Obj.StreamName);
9191 std::vector Records;
9292 };
9393
94 struct PdbPublicsStream {
95 std::vector PubSyms;
96 };
97
9498 struct PdbObject {
9599 explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}
96100
101105 Optional DbiStream;
102106 Optional TpiStream;
103107 Optional IpiStream;
108 Optional PublicsStream;
104109
105110 Optional> StringTable;
106111
117122 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream)
118123 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream)
119124 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream)
125 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbPublicsStream)
120126 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping)
121127 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream)
122128 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo)
1717 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
1818 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
1919 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
20 #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
2021 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
2122 #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
2223 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
24 #include "llvm/DebugInfo/PDB/Native/PublicsStream.h"
2325 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
26 #include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
2427 #include "llvm/DebugInfo/PDB/Native/TpiStream.h"
2528
2629 using namespace llvm;
6568 return EC;
6669
6770 if (auto EC = dumpIpiStream())
71 return EC;
72
73 if (auto EC = dumpPublics())
6874 return EC;
6975
7076 flush();
325331 return Error::success();
326332 }
327333
334 Error YAMLOutputStyle::dumpPublics() {
335 if (!opts::pdb2yaml::PublicsStream)
336 return Error::success();
337
338 Obj.PublicsStream.emplace();
339 auto ExpectedPublics = File.getPDBPublicsStream();
340 if (!ExpectedPublics) {
341 llvm::consumeError(ExpectedPublics.takeError());
342 return Error::success();
343 }
344
345 PublicsStream &Publics = *ExpectedPublics;
346 const GSIHashTable &PublicsTable = Publics.getPublicsTable();
347
348 auto ExpectedSyms = File.getPDBSymbolStream();
349 if (!ExpectedSyms) {
350 llvm::consumeError(ExpectedSyms.takeError());
351 return Error::success();
352 }
353
354 BinaryStreamRef SymStream =
355 ExpectedSyms->getSymbolArray().getUnderlyingStream();
356 for (uint32_t PubSymOff : PublicsTable) {
357 Expected Sym = readSymbolFromStream(SymStream, PubSymOff);
358 if (!Sym)
359 return Sym.takeError();
360 auto ES = CodeViewYAML::SymbolRecord::fromCodeViewSymbol(*Sym);
361 if (!ES)
362 return ES.takeError();
363
364 Obj.PublicsStream->PubSyms.push_back(*ES);
365 }
366
367 return Error::success();
368 }
369
328370 void YAMLOutputStyle::flush() {
329371 Out << Obj;
330372 outs().flush();
3434 Error dumpDbiStream();
3535 Error dumpTpiStream();
3636 Error dumpIpiStream();
37 Error dumpPublics();
3738
3839 void flush();
3940
662662 cl::desc("Dump the IPI Stream (Stream 5)"),
663663 cl::sub(PdbToYamlSubcommand), cl::init(false));
664664
665 cl::opt PublicsStream("publics-stream",
666 cl::desc("Dump the Publics Stream"),
667 cl::sub(PdbToYamlSubcommand), cl::init(false));
668
665669 // MODULE & FILE OPTIONS
666670 cl::opt DumpModules("modules", cl::desc("dump compiland information"),
667671 cl::cat(FileOptions), cl::sub(PdbToYamlSubcommand));
14941498 opts::pdb2yaml::DbiStream = true;
14951499 opts::pdb2yaml::TpiStream = true;
14961500 opts::pdb2yaml::IpiStream = true;
1501 opts::pdb2yaml::PublicsStream = true;
14971502 opts::pdb2yaml::DumpModules = true;
14981503 opts::pdb2yaml::DumpModuleFiles = true;
14991504 opts::pdb2yaml::DumpModuleSyms = true;
191191 extern llvm::cl::opt DbiStream;
192192 extern llvm::cl::opt TpiStream;
193193 extern llvm::cl::opt IpiStream;
194 extern llvm::cl::opt PublicsStream;
194195 extern llvm::cl::list InputFilename;
195196 extern llvm::cl::opt DumpModules;
196197 extern llvm::cl::opt DumpModuleFiles;