llvm.org GIT mirror llvm / 7f08d4a
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336407 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 1 year, 2 months ago
4 changed file(s) with 62 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
150150 }
151151 }
152152
153 if (opts::dump::DumpGSIRecords) {
154 if (auto EC = dumpGSIRecords())
155 return EC;
156 }
157
153158 if (opts::dump::DumpGlobals) {
154159 if (auto EC = dumpGlobals())
155160 return EC;
13561361 return Error::success();
13571362 }
13581363
1364 Error DumpOutputStyle::dumpGSIRecords() {
1365 printHeader(P, "GSI Records");
1366 AutoIndent Indent(P);
1367
1368 if (File.isObj()) {
1369 P.formatLine("Dumping Globals is not supported for object files");
1370 return Error::success();
1371 }
1372
1373 if (!getPdb().hasPDBSymbolStream()) {
1374 P.formatLine("GSI Common Symbol Stream not present");
1375 return Error::success();
1376 }
1377
1378 auto &Records = cantFail(getPdb().getPDBSymbolStream());
1379 auto &Types = File.types();
1380 auto &Ids = File.ids();
1381
1382 P.printLine("Records");
1383 SymbolVisitorCallbackPipeline Pipeline;
1384 SymbolDeserializer Deserializer(nullptr, CodeViewContainer::Pdb);
1385 MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes, Ids, Types);
1386
1387 Pipeline.addCallbackToPipeline(Deserializer);
1388 Pipeline.addCallbackToPipeline(Dumper);
1389 CVSymbolVisitor Visitor(Pipeline);
1390
1391 BinaryStreamRef SymStream = Records.getSymbolArray().getUnderlyingStream();
1392 if (auto E = Visitor.visitSymbolStream(Records.getSymbolArray(), 0))
1393 return E;
1394 return Error::success();
1395 }
1396
13591397 Error DumpOutputStyle::dumpGlobals() {
13601398 printHeader(P, "Global Symbols");
13611399 AutoIndent Indent(P);
14601498 Pipeline.addCallbackToPipeline(Deserializer);
14611499 Pipeline.addCallbackToPipeline(Dumper);
14621500 CVSymbolVisitor Visitor(Pipeline);
1501
14631502
14641503 BinaryStreamRef SymStream =
14651504 ExpectedSyms->getSymbolArray().getUnderlyingStream();
14731512 }
14741513
14751514 // Return early if we aren't dumping public hash table and address map info.
1476 if (!HashExtras)
1477 return Error::success();
1478
1479 P.formatLine("Hash Entries");
1480 {
1481 AutoIndent Indent2(P);
1482 for (const PSHashRecord &HR : Table.HashRecords)
1483 P.formatLine("off = {0}, refcnt = {1}", uint32_t(HR.Off),
1484 uint32_t(HR.CRef));
1485 }
1486
1487 // FIXME: Dump the bitmap.
1488
1489 P.formatLine("Hash Buckets");
1490 {
1491 AutoIndent Indent2(P);
1492 for (uint32_t Hash : Table.HashBuckets)
1493 P.formatLine("{0:x8}", Hash);
1515 if (HashExtras) {
1516 P.formatBinary("Hash Bitmap", Table.HashBitmap, 0);
1517
1518 P.formatLine("Hash Entries");
1519 {
1520 AutoIndent Indent2(P);
1521 for (const PSHashRecord &HR : Table.HashRecords)
1522 P.formatLine("off = {0}, refcnt = {1}", uint32_t(HR.Off),
1523 uint32_t(HR.CRef));
1524 }
1525
1526 P.formatLine("Hash Buckets");
1527 {
1528 AutoIndent Indent2(P);
1529 for (uint32_t Hash : Table.HashBuckets)
1530 P.formatLine("{0:x8}", Hash);
1531 }
14941532 }
14951533
14961534 return Error::success();
8787 Error dumpModuleFiles();
8888 Error dumpModuleSymsForPdb();
8989 Error dumpModuleSymsForObj();
90 Error dumpGSIRecords();
9091 Error dumpGlobals();
9192 Error dumpPublics();
9293 Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
457457 cl::opt DumpPublicExtras("public-extras",
458458 cl::desc("dump Publics hashes and address maps"),
459459 cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
460 cl::opt
461 DumpGSIRecords("gsi-records",
462 cl::desc("dump public / global common record stream"),
463 cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
460464 cl::opt DumpSymbols("symbols", cl::desc("dump module symbols"),
461465 cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
462466
159159 extern llvm::cl::opt JustMyCode;
160160 extern llvm::cl::opt DumpSymbols;
161161 extern llvm::cl::opt DumpSymRecordBytes;
162 extern llvm::cl::opt DumpGSIRecords;
162163 extern llvm::cl::opt DumpGlobals;
163164 extern llvm::cl::opt DumpGlobalExtras;
164165 extern llvm::cl::opt DumpPublics;