[llvm] r310000 - [llvm-pdbutil] Add an option to only dump specific module indices.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 3 16:11:52 PDT 2017
Author: zturner
Date: Thu Aug 3 16:11:52 2017
New Revision: 310000
URL: http://llvm.org/viewvc/llvm-project?rev=310000&view=rev
Log:
[llvm-pdbutil] Add an option to only dump specific module indices.
Often something interesting (like a symbol) is in a particular
module, and you don't want to dump symbols from all other 300
modules to see the one you want. This adds a -modi option so that
we only dump the specified module.
Modified:
llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
Modified: llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp?rev=310000&r1=309999&r2=310000&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp Thu Aug 3 16:11:52 2017
@@ -344,6 +344,20 @@ public:
} // namespace
template <typename CallbackT>
+static void iterateOneModule(PDBFile &File, LinePrinter &P,
+ const DbiModuleDescriptor &Descriptor,
+ uint32_t Modi, uint32_t IndentLevel,
+ uint32_t Digits, CallbackT Callback) {
+ P.formatLine(
+ "Mod {0:4} | `{1}`: ", fmt_align(Modi, AlignStyle::Right, Digits),
+ Descriptor.getModuleName());
+
+ StringsAndChecksumsPrinter Strings(File, Modi);
+ AutoIndent Indent2(P, IndentLevel);
+ Callback(Modi, Strings);
+}
+
+template <typename CallbackT>
static void iterateModules(PDBFile &File, LinePrinter &P, uint32_t IndentLevel,
CallbackT Callback) {
AutoIndent Indent(P);
@@ -357,16 +371,21 @@ static void iterateModules(PDBFile &File
auto &Stream = Err(File.getPDBDbiStream());
const DbiModuleList &Modules = Stream.modules();
+
+ if (opts::dump::DumpModi.getNumOccurrences() > 0) {
+ assert(opts::dump::DumpModi.getNumOccurrences() == 1);
+ uint32_t Modi = opts::dump::DumpModi;
+ auto Descriptor = Modules.getModuleDescriptor(Modi);
+ iterateOneModule(File, P, Descriptor, Modi, IndentLevel, NumDigits(Modi),
+ Callback);
+ return;
+ }
+
uint32_t Count = Modules.getModuleCount();
uint32_t Digits = NumDigits(Count);
for (uint32_t I = 0; I < Count; ++I) {
- auto Modi = Modules.getModuleDescriptor(I);
- P.formatLine("Mod {0:4} | `{1}`: ", fmt_align(I, AlignStyle::Right, Digits),
- Modi.getModuleName());
-
- StringsAndChecksumsPrinter Strings(File, I);
- AutoIndent Indent2(P, IndentLevel);
- Callback(I, Strings);
+ auto Descriptor = Modules.getModuleDescriptor(I);
+ iterateOneModule(File, P, Descriptor, I, IndentLevel, Digits, Callback);
}
}
@@ -813,47 +832,34 @@ Error DumpOutputStyle::dumpModuleSyms()
ExitOnError Err("Unexpected error processing symbols: ");
- auto &Stream = Err(File.getPDBDbiStream());
-
auto &Types = Err(initializeTypes(StreamTPI));
- const DbiModuleList &Modules = Stream.modules();
- uint32_t Count = Modules.getModuleCount();
- uint32_t Digits = NumDigits(Count);
- for (uint32_t I = 0; I < Count; ++I) {
- auto Modi = Modules.getModuleDescriptor(I);
- P.formatLine("Mod {0:4} | `{1}`: ", fmt_align(I, AlignStyle::Right, Digits),
- Modi.getModuleName());
- uint16_t ModiStream = Modi.getModuleStreamIndex();
- if (ModiStream == kInvalidStreamIndex) {
- P.formatLine(" <symbols not present>");
- continue;
- }
- auto ModStreamData = MappedBlockStream::createIndexedStream(
- File.getMsfLayout(), File.getMsfBuffer(), ModiStream,
- File.getAllocator());
-
- ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData));
- if (auto EC = ModS.reload()) {
- P.formatLine("Error loading module stream {0}. {1}", I,
- toString(std::move(EC)));
- continue;
- }
+ iterateModules(
+ File, P, 2, [&](uint32_t I, StringsAndChecksumsPrinter &Strings) {
+ auto ExpectedModS = getModuleDebugStream(File, I);
+ if (!ExpectedModS) {
+ P.formatLine("Error loading module stream {0}. {1}", I,
+ toString(ExpectedModS.takeError()));
+ return;
+ }
- SymbolVisitorCallbackPipeline Pipeline;
- SymbolDeserializer Deserializer(nullptr, CodeViewContainer::Pdb);
- MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes, Types);
-
- Pipeline.addCallbackToPipeline(Deserializer);
- Pipeline.addCallbackToPipeline(Dumper);
- CVSymbolVisitor Visitor(Pipeline);
- auto SS = ModS.getSymbolsSubstream();
- if (auto EC = Visitor.visitSymbolStream(ModS.getSymbolArray(), SS.Offset)) {
- P.formatLine("Error while processing symbol records. {0}",
- toString(std::move(EC)));
- continue;
- }
- }
+ ModuleDebugStreamRef &ModS = *ExpectedModS;
+
+ SymbolVisitorCallbackPipeline Pipeline;
+ SymbolDeserializer Deserializer(nullptr, CodeViewContainer::Pdb);
+ MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes, Types);
+
+ Pipeline.addCallbackToPipeline(Deserializer);
+ Pipeline.addCallbackToPipeline(Dumper);
+ CVSymbolVisitor Visitor(Pipeline);
+ auto SS = ModS.getSymbolsSubstream();
+ if (auto EC =
+ Visitor.visitSymbolStream(ModS.getSymbolArray(), SS.Offset)) {
+ P.formatLine("Error while processing symbol records. {0}",
+ toString(std::move(EC)));
+ return;
+ }
+ });
return Error::success();
}
Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp?rev=310000&r1=309999&r2=310000&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Thu Aug 3 16:11:52 2017
@@ -503,6 +503,10 @@ cl::opt<bool> DumpXme(
cl::desc(
"dump cross module exports (DEBUG_S_CROSSSCOPEEXPORTS subsection)"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
+cl::opt<uint32_t> DumpModi("modi", cl::Optional,
+ cl::desc("For all options that iterate over "
+ "modules, limit to the specified module"),
+ cl::cat(FileOptions), cl::sub(DumpSubcommand));
// MISCELLANEOUS OPTIONS
cl::opt<bool> DumpStringTable("string-table", cl::desc("dump PDB String Table"),
Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h?rev=310000&r1=309999&r2=310000&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h Thu Aug 3 16:11:52 2017
@@ -144,6 +144,7 @@ extern llvm::cl::opt<bool> DumpIds;
extern llvm::cl::opt<bool> DumpIdData;
extern llvm::cl::opt<bool> DumpIdExtras;
extern llvm::cl::list<uint32_t> DumpIdIndex;
+extern llvm::cl::opt<uint32_t> DumpModi;
extern llvm::cl::opt<bool> DumpSymbols;
extern llvm::cl::opt<bool> DumpSymRecordBytes;
extern llvm::cl::opt<bool> DumpGlobals;
More information about the llvm-commits
mailing list