[llvm-pdbutil] Add missing --id-stats to dump the IPI stream

Before this patch, llvm-pdbutil supported only --type-stats to dump stats about a PDB TPI stream.
Adding --id-stats for completion.
This commit is contained in:
Alexandre Ganea 2020-06-04 15:30:45 -04:00
parent eaa8af9322
commit b67f860208
3 changed files with 10 additions and 6 deletions

View File

@ -110,7 +110,7 @@ Error DumpOutputStyle::dump() {
P.NewLine();
}
if (opts::dump::DumpTypeStats) {
if (opts::dump::DumpTypeStats || opts::dump::DumpIDStats) {
if (auto EC = dumpTypeStats())
return EC;
P.NewLine();
@ -701,7 +701,8 @@ Error DumpOutputStyle::dumpTypeStats() {
// Iterate the types, categorize by kind, accumulate size stats.
StatCollection TypeStats;
LazyRandomTypeCollection &Types = File.types();
LazyRandomTypeCollection &Types =
opts::dump::DumpTypeStats ? File.types() : File.ids();
for (Optional<TypeIndex> TI = Types.getFirst(); TI; TI = Types.getNext(*TI)) {
CVType Type = Types.getType(*TI);
TypeStats.update(uint32_t(Type.kind()), Type.length());
@ -710,18 +711,16 @@ Error DumpOutputStyle::dumpTypeStats() {
P.NewLine();
P.formatLine(" Types");
AutoIndent Indent(P);
P.formatLine("{0,14}: {1,7} entries ({2,12:N} bytes, {3,7} avg)", "Total",
P.formatLine("{0,16}: {1,7} entries ({2,12:N} bytes, {3,7} avg)", "Total",
TypeStats.Totals.Count, TypeStats.Totals.Size,
(double)TypeStats.Totals.Size / TypeStats.Totals.Count);
P.formatLine("{0}", fmt_repeat('-', 74));
for (const auto &K : TypeStats.getStatsSortedBySize()) {
P.formatLine("{0,14}: {1,7} entries ({2,12:N} bytes, {3,7} avg)",
P.formatLine("{0,16}: {1,7} entries ({2,12:N} bytes, {3,7} avg)",
formatTypeLeafKind(TypeLeafKind(K.first)), K.second.Count,
K.second.Size, (double)K.second.Size / K.second.Count);
}
return Error::success();
}

View File

@ -466,6 +466,10 @@ cl::opt<bool> DumpTypeStats(
"type-stats",
cl::desc("Dump a detailed breakdown of type usage/size"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpIDStats(
"id-stats",
cl::desc("Dump a detailed breakdown of IPI types usage/size"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpUdtStats(
"udt-stats",
cl::desc("Dump a detailed breakdown of S_UDT record usage / stats"),

View File

@ -141,6 +141,7 @@ extern llvm::cl::opt<bool> DumpFpm;
extern llvm::cl::opt<bool> DumpStreams;
extern llvm::cl::opt<bool> DumpSymbolStats;
extern llvm::cl::opt<bool> DumpTypeStats;
extern llvm::cl::opt<bool> DumpIDStats;
extern llvm::cl::opt<bool> DumpUdtStats;
extern llvm::cl::opt<bool> DumpStreamBlocks;