const DbiModuleList &Modules, uint32_t I,
uint32_t Digits, uint32_t IndentLevel,
CallbackT Callback) {
+ if (I >= Modules.getModuleCount()) {
+ P.formatLine("Mod {0:4} | Invalid module index ",
+ fmt_align(I, AlignStyle::Right, std::max(Digits, 4U)));
+ return;
+ }
+
auto Modi = Modules.getModuleDescriptor(I);
P.formatLine("Mod {0:4} | `{1}`: ",
fmt_align(I, AlignStyle::Right, std::max(Digits, 4U)),
Modi.getModuleName());
uint16_t ModiStream = Modi.getModuleStreamIndex();
-
AutoIndent Indent2(P, IndentLevel);
+ if (ModiStream == kInvalidStreamIndex)
+ return;
+
auto ModStreamData = MappedBlockStream::createIndexedStream(
File.getMsfLayout(), File.getMsfBuffer(), ModiStream,
File.getAllocator());
});
}
+static std::string formatChunkKind(DebugSubsectionKind Kind) {
+ switch (Kind) {
+ RETURN_CASE(DebugSubsectionKind, None, "none");
+ RETURN_CASE(DebugSubsectionKind, Symbols, "symbols");
+ RETURN_CASE(DebugSubsectionKind, Lines, "lines");
+ RETURN_CASE(DebugSubsectionKind, StringTable, "strings");
+ RETURN_CASE(DebugSubsectionKind, FileChecksums, "checksums");
+ RETURN_CASE(DebugSubsectionKind, FrameData, "frames");
+ RETURN_CASE(DebugSubsectionKind, InlineeLines, "inlinee lines");
+ RETURN_CASE(DebugSubsectionKind, CrossScopeImports, "xmi");
+ RETURN_CASE(DebugSubsectionKind, CrossScopeExports, "xme");
+ RETURN_CASE(DebugSubsectionKind, ILLines, "il lines");
+ RETURN_CASE(DebugSubsectionKind, FuncMDTokenMap, "func md token map");
+ RETURN_CASE(DebugSubsectionKind, TypeMDTokenMap, "type md token map");
+ RETURN_CASE(DebugSubsectionKind, MergedAssemblyInput,
+ "merged assembly input");
+ RETURN_CASE(DebugSubsectionKind, CoffSymbolRVA, "coff symbol rva");
+ }
+ return formatUnknownEnum(Kind);
+}
+
void BytesOutputStyle::dumpModuleC13() {
printHeader(P, "Debug Chunks");
AutoIndent Indent(P);
- iterateModules(File, P, 2,
- [this](uint32_t Modi, const ModuleDebugStreamRef &Stream,
- const MSFStreamLayout &Layout) {
- auto Chunks = Stream.getC13LinesSubstream();
- P.formatMsfStreamData("Debug Chunks", File, Layout, Chunks);
- });
+ iterateModules(
+ File, P, 2,
+ [this](uint32_t Modi, const ModuleDebugStreamRef &Stream,
+ const MSFStreamLayout &Layout) {
+ auto Chunks = Stream.getC13LinesSubstream();
+ if (opts::bytes::SplitChunks) {
+ for (const auto &SS : Stream.subsections()) {
+ BinarySubstreamRef ThisChunk;
+ std::tie(ThisChunk, Chunks) = Chunks.split(SS.getRecordLength());
+ P.formatMsfStreamData(formatChunkKind(SS.kind()), File, Layout,
+ ThisChunk);
+ }
+ } else {
+ P.formatMsfStreamData("Debug Chunks", File, Layout, Chunks);
+ }
+ });
}
void BytesOutputStyle::dumpByteRanges(uint32_t Min, uint32_t Max) {
cl::OptionCategory FilterCategory("Filtering and Sorting Options");
cl::OptionCategory OtherOptions("Other Options");
+cl::ValuesClass ChunkValues = cl::values(
+ clEnumValN(ModuleSubsection::CrossScopeExports, "cme",
+ "Cross module exports (DEBUG_S_CROSSSCOPEEXPORTS subsection)"),
+ clEnumValN(ModuleSubsection::CrossScopeImports, "cmi",
+ "Cross module imports (DEBUG_S_CROSSSCOPEIMPORTS subsection)"),
+ clEnumValN(ModuleSubsection::FileChecksums, "fc",
+ "File checksums (DEBUG_S_CHECKSUMS subsection)"),
+ clEnumValN(ModuleSubsection::InlineeLines, "ilines",
+ "Inlinee lines (DEBUG_S_INLINEELINES subsection)"),
+ clEnumValN(ModuleSubsection::Lines, "lines",
+ "Lines (DEBUG_S_LINES subsection)"),
+ clEnumValN(ModuleSubsection::StringTable, "strings",
+ "String Table (DEBUG_S_STRINGTABLE subsection) (not "
+ "typically present in PDB file)"),
+ clEnumValN(ModuleSubsection::FrameData, "frames",
+ "Frame Data (DEBUG_S_FRAMEDATA subsection)"),
+ clEnumValN(ModuleSubsection::Symbols, "symbols",
+ "Symbols (DEBUG_S_SYMBOLS subsection) (not typically "
+ "present in PDB file)"),
+ clEnumValN(ModuleSubsection::CoffSymbolRVAs, "rvas",
+ "COFF Symbol RVAs (DEBUG_S_COFF_SYMBOL_RVA subsection)"),
+ clEnumValN(ModuleSubsection::Unknown, "unknown",
+ "Any subsection not covered by another option"),
+ clEnumValN(ModuleSubsection::All, "all", "All known subsections"));
+
namespace pretty {
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::opt<bool> ModuleC11("c11-chunks", cl::Hidden,
cl::desc("Dump C11 CodeView debug chunks"),
cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
-cl::opt<bool> ModuleC13("chunks", cl::desc("Dump C13 CodeView debug chunks"),
+cl::opt<bool> ModuleC13("chunks",
+ cl::desc("Dump C13 CodeView debug chunk subsection"),
cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
-
+cl::opt<bool> SplitChunks(
+ "split-chunks",
+ cl::desc(
+ "When dumping debug chunks, show a different section for each chunk"),
+ cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::OneOrMore, cl::sub(BytesSubcommand));
cl::sub(PdbToYamlSubcommand));
cl::list<ModuleSubsection> DumpModuleSubsections(
"subsections", cl::ZeroOrMore, cl::CommaSeparated,
- cl::desc("dump subsections from each module's debug stream"),
- cl::values(
- clEnumValN(
- ModuleSubsection::CrossScopeExports, "cme",
- "Cross module exports (DEBUG_S_CROSSSCOPEEXPORTS subsection)"),
- clEnumValN(
- ModuleSubsection::CrossScopeImports, "cmi",
- "Cross module imports (DEBUG_S_CROSSSCOPEIMPORTS subsection)"),
- clEnumValN(ModuleSubsection::FileChecksums, "fc",
- "File checksums (DEBUG_S_CHECKSUMS subsection)"),
- clEnumValN(ModuleSubsection::InlineeLines, "ilines",
- "Inlinee lines (DEBUG_S_INLINEELINES subsection)"),
- clEnumValN(ModuleSubsection::Lines, "lines",
- "Lines (DEBUG_S_LINES subsection)"),
- clEnumValN(ModuleSubsection::StringTable, "strings",
- "String Table (DEBUG_S_STRINGTABLE subsection) (not "
- "typically present in PDB file)"),
- clEnumValN(ModuleSubsection::FrameData, "frames",
- "Frame Data (DEBUG_S_FRAMEDATA subsection)"),
- clEnumValN(ModuleSubsection::Symbols, "symbols",
- "Symbols (DEBUG_S_SYMBOLS subsection) (not typically "
- "present in PDB file)"),
- clEnumValN(ModuleSubsection::CoffSymbolRVAs, "rvas",
- "COFF Symbol RVAs (DEBUG_S_COFF_SYMBOL_RVA subsection)"),
- clEnumValN(ModuleSubsection::Unknown, "unknown",
- "Any subsection not covered by another option"),
- clEnumValN(ModuleSubsection::All, "all", "All known subsections")),
+ cl::desc("dump subsections from each module's debug stream"), ChunkValues,
cl::cat(FileOptions), cl::sub(PdbToYamlSubcommand));
cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),
cl::cat(FileOptions),
return true;
}
+static void simplifyChunkList(llvm::cl::list<opts::ModuleSubsection> &Chunks) {
+ // If this list contains "All" plus some other stuff, remove the other stuff
+ // and just keep "All" in the list.
+ if (!llvm::is_contained(Chunks, opts::ModuleSubsection::All))
+ return;
+ Chunks.reset();
+ Chunks.push_back(opts::ModuleSubsection::All);
+}
+
int main(int argc_, const char *argv_[]) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal(argv_[0]);
opts::pdb2yaml::DumpModuleSyms = true;
opts::pdb2yaml::DumpModuleSubsections.push_back(
opts::ModuleSubsection::All);
- if (llvm::is_contained(opts::pdb2yaml::DumpModuleSubsections,
- opts::ModuleSubsection::All)) {
- opts::pdb2yaml::DumpModuleSubsections.reset();
- opts::pdb2yaml::DumpModuleSubsections.push_back(
- opts::ModuleSubsection::All);
- }
}
+ simplifyChunkList(opts::pdb2yaml::DumpModuleSubsections);
if (opts::pdb2yaml::DumpModuleSyms || opts::pdb2yaml::DumpModuleFiles)
opts::pdb2yaml::DumpModules = true;