1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[llvm-pdbutil] Dump more info about globals.

We add an option to dump the entire global / public symbol record
stream.  Previously we would dump globals or publics, but not both.
And when we did dump them, we would always dump them in the order
they were referenced by the corresponding hash streams, not in
the order they were serialized in.  This patch adds a lower level
mode that just dumps the whole stream in serialization order.

Additionally, when dumping global-extras, we now dump the hash
bitmap as well as the record offset instead of dumping all zeros
for the offsets.

llvm-svn: 336407
This commit is contained in:
Zachary Turner 2018-07-06 02:59:25 +00:00
parent 7ad5f995e3
commit 0e8592d45d
4 changed files with 60 additions and 16 deletions

View File

@ -151,6 +151,11 @@ Error DumpOutputStyle::dump() {
}
}
if (opts::dump::DumpGSIRecords) {
if (auto EC = dumpGSIRecords())
return EC;
}
if (opts::dump::DumpGlobals) {
if (auto EC = dumpGlobals())
return EC;
@ -1357,6 +1362,39 @@ Error DumpOutputStyle::dumpModuleSymsForPdb() {
return Error::success();
}
Error DumpOutputStyle::dumpGSIRecords() {
printHeader(P, "GSI Records");
AutoIndent Indent(P);
if (File.isObj()) {
P.formatLine("Dumping Globals is not supported for object files");
return Error::success();
}
if (!getPdb().hasPDBSymbolStream()) {
P.formatLine("GSI Common Symbol Stream not present");
return Error::success();
}
auto &Records = cantFail(getPdb().getPDBSymbolStream());
auto &Types = File.types();
auto &Ids = File.ids();
P.printLine("Records");
SymbolVisitorCallbackPipeline Pipeline;
SymbolDeserializer Deserializer(nullptr, CodeViewContainer::Pdb);
MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes, Ids, Types);
Pipeline.addCallbackToPipeline(Deserializer);
Pipeline.addCallbackToPipeline(Dumper);
CVSymbolVisitor Visitor(Pipeline);
BinaryStreamRef SymStream = Records.getSymbolArray().getUnderlyingStream();
if (auto E = Visitor.visitSymbolStream(Records.getSymbolArray(), 0))
return E;
return Error::success();
}
Error DumpOutputStyle::dumpGlobals() {
printHeader(P, "Global Symbols");
AutoIndent Indent(P);
@ -1462,6 +1500,7 @@ Error DumpOutputStyle::dumpSymbolsFromGSI(const GSIHashTable &Table,
Pipeline.addCallbackToPipeline(Dumper);
CVSymbolVisitor Visitor(Pipeline);
BinaryStreamRef SymStream =
ExpectedSyms->getSymbolArray().getUnderlyingStream();
for (uint32_t PubSymOff : Table) {
@ -1474,24 +1513,23 @@ Error DumpOutputStyle::dumpSymbolsFromGSI(const GSIHashTable &Table,
}
// Return early if we aren't dumping public hash table and address map info.
if (!HashExtras)
return Error::success();
if (HashExtras) {
P.formatBinary("Hash Bitmap", Table.HashBitmap, 0);
P.formatLine("Hash Entries");
{
AutoIndent Indent2(P);
for (const PSHashRecord &HR : Table.HashRecords)
P.formatLine("off = {0}, refcnt = {1}", uint32_t(HR.Off),
uint32_t(HR.CRef));
}
P.formatLine("Hash Entries");
{
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);
P.formatLine("Hash Buckets");
{
AutoIndent Indent2(P);
for (uint32_t Hash : Table.HashBuckets)
P.formatLine("{0:x8}", Hash);
}
}
return Error::success();

View File

@ -88,6 +88,7 @@ private:
Error dumpModuleFiles();
Error dumpModuleSymsForPdb();
Error dumpModuleSymsForObj();
Error dumpGSIRecords();
Error dumpGlobals();
Error dumpPublics();
Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);

View File

@ -458,6 +458,10 @@ cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"),
cl::opt<bool> DumpPublicExtras("public-extras",
cl::desc("dump Publics hashes and address maps"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool>
DumpGSIRecords("gsi-records",
cl::desc("dump public / global common record stream"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpSymbols("symbols", cl::desc("dump module symbols"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));

View File

@ -160,6 +160,7 @@ extern llvm::cl::opt<uint32_t> DumpModi;
extern llvm::cl::opt<bool> JustMyCode;
extern llvm::cl::opt<bool> DumpSymbols;
extern llvm::cl::opt<bool> DumpSymRecordBytes;
extern llvm::cl::opt<bool> DumpGSIRecords;
extern llvm::cl::opt<bool> DumpGlobals;
extern llvm::cl::opt<bool> DumpGlobalExtras;
extern llvm::cl::opt<bool> DumpPublics;