summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-pdbdump')
-rw-r--r--llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp36
-rw-r--r--llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp65
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp118
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.h35
4 files changed, 154 insertions, 100 deletions
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index cd5bf8a095d..cd4645ec0ee 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -89,7 +89,8 @@ public:
: C13DebugFragmentVisitor(F), P(P), IPI(IPI) {}
Error handleLines() override {
- if (Lines.empty())
+ if (Lines.empty() ||
+ !opts::checkModuleSubsection(opts::ModuleSubsection::Lines))
return Error::success();
DictScope DD(P, "Lines");
@@ -132,7 +133,8 @@ public:
}
Error handleFileChecksums() override {
- if (!Checksums.hasValue())
+ if (!Checksums.hasValue() ||
+ !opts::checkModuleSubsection(opts::ModuleSubsection::FileChecksums))
return Error::success();
DictScope DD(P, "FileChecksums");
@@ -149,7 +151,8 @@ public:
}
Error handleInlineeLines() override {
- if (InlineeLines.empty())
+ if (InlineeLines.empty() ||
+ !opts::checkModuleSubsection(opts::ModuleSubsection::InlineeLines))
return Error::success();
DictScope D(P, "InlineeLines");
@@ -177,6 +180,10 @@ public:
}
Error handleCrossModuleExports() override {
+ if (CrossExports.empty() ||
+ !opts::checkModuleSubsection(opts::ModuleSubsection::CrossScopeExports))
+ return Error::success();
+
for (const auto &M : CrossExports) {
DictScope D(P, "CrossModuleExports");
for (const auto &E : M) {
@@ -188,6 +195,10 @@ public:
}
Error handleCrossModuleImports() override {
+ if (CrossImports.empty() ||
+ !opts::checkModuleSubsection(opts::ModuleSubsection::CrossScopeImports))
+ return Error::success();
+
for (const auto &M : CrossImports) {
DictScope D(P, "CrossModuleImports");
for (const auto &ImportGroup : M) {
@@ -755,8 +766,10 @@ LLVMOutputStyle::initializeTypeDatabase(uint32_t SN) {
}
Error LLVMOutputStyle::dumpDbiStream() {
- bool DumpModules = opts::raw::DumpModules || opts::raw::DumpModuleSyms ||
- opts::raw::DumpModuleFiles || opts::raw::DumpLineInfo;
+ bool DumpModules = opts::shared::DumpModules ||
+ opts::shared::DumpModuleSyms ||
+ opts::shared::DumpModuleFiles ||
+ !opts::shared::DumpModuleSubsections.empty();
if (!opts::raw::DumpHeaders && !DumpModules)
return Error::success();
if (!File.hasPDBDbiStream()) {
@@ -806,7 +819,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
P.printNumber("Symbol Byte Size", Modi.getSymbolDebugInfoByteSize());
P.printNumber("Type Server Index", Modi.getTypeServerIndex());
P.printBoolean("Has EC Info", Modi.hasECInfo());
- if (opts::raw::DumpModuleFiles) {
+ if (opts::shared::DumpModuleFiles) {
std::string FileListName = to_string(Modules.getSourceFileCount(I)) +
" Contributing Source Files";
ListScope LL(P, FileListName);
@@ -815,8 +828,9 @@ Error LLVMOutputStyle::dumpDbiStream() {
}
bool HasModuleDI = (Modi.getModuleStreamIndex() < File.getNumStreams());
bool ShouldDumpSymbols =
- (opts::raw::DumpModuleSyms || opts::raw::DumpSymRecordBytes);
- if (HasModuleDI && (ShouldDumpSymbols || opts::raw::DumpLineInfo)) {
+ (opts::shared::DumpModuleSyms || opts::raw::DumpSymRecordBytes);
+ if (HasModuleDI &&
+ (ShouldDumpSymbols || !opts::shared::DumpModuleSubsections.empty())) {
auto ModStreamData = MappedBlockStream::createIndexedStream(
File.getMsfLayout(), File.getMsfBuffer(),
Modi.getModuleStreamIndex(), File.getAllocator());
@@ -837,7 +851,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
bool HadError = false;
for (auto S : ModS.symbols(&HadError)) {
DictScope LL(P, "");
- if (opts::raw::DumpModuleSyms) {
+ if (opts::shared::DumpModuleSyms) {
if (auto EC = SD.dump(S)) {
llvm::consumeError(std::move(EC));
HadError = true;
@@ -852,8 +866,8 @@ Error LLVMOutputStyle::dumpDbiStream() {
raw_error_code::corrupt_file,
"DBI stream contained corrupt symbol record");
}
- if (opts::raw::DumpLineInfo) {
- ListScope SS(P, "LineInfo");
+ if (!opts::shared::DumpModuleSubsections.empty()) {
+ ListScope SS(P, "Subsections");
auto ExpectedTypes = initializeTypeDatabase(StreamIPI);
if (!ExpectedTypes)
return ExpectedTypes.takeError();
diff --git a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
index c28885104ca..105b3ca2a07 100644
--- a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
@@ -38,39 +38,8 @@ YAMLOutputStyle::YAMLOutputStyle(PDBFile &File)
}
Error YAMLOutputStyle::dump() {
- if (opts::pdb2yaml::All) {
- opts::pdb2yaml::StreamMetadata = true;
- opts::pdb2yaml::StreamDirectory = true;
- opts::pdb2yaml::PdbStream = true;
- opts::pdb2yaml::StringTable = true;
- opts::pdb2yaml::DbiStream = true;
- opts::pdb2yaml::DbiModuleInfo = true;
- opts::pdb2yaml::DbiModuleSyms = true;
- opts::pdb2yaml::DbiModuleSourceFileInfo = true;
- opts::pdb2yaml::DbiModuleSourceLineInfo = true;
- opts::pdb2yaml::TpiStream = true;
- opts::pdb2yaml::IpiStream = true;
- }
-
if (opts::pdb2yaml::StreamDirectory)
opts::pdb2yaml::StreamMetadata = true;
- if (opts::pdb2yaml::DbiModuleSyms)
- opts::pdb2yaml::DbiModuleInfo = true;
-
- if (opts::pdb2yaml::DbiModuleSourceLineInfo)
- opts::pdb2yaml::DbiModuleSourceFileInfo = true;
-
- if (opts::pdb2yaml::DbiModuleSourceFileInfo)
- opts::pdb2yaml::DbiModuleInfo = true;
-
- if (opts::pdb2yaml::DbiModuleInfo)
- opts::pdb2yaml::DbiStream = true;
-
- // Some names from the module source file info get pulled from the string
- // table, so if we're writing module source info, we have to write the string
- // table as well.
- if (opts::pdb2yaml::DbiModuleSourceLineInfo)
- opts::pdb2yaml::StringTable = true;
if (auto EC = dumpFileHeaders())
return EC;
@@ -124,8 +93,8 @@ Error YAMLOutputStyle::dumpFileHeaders() {
}
Error YAMLOutputStyle::dumpStringTable() {
- bool RequiresStringTable = opts::pdb2yaml::DbiModuleSourceFileInfo ||
- opts::pdb2yaml::DbiModuleSourceLineInfo;
+ bool RequiresStringTable = opts::shared::DumpModuleFiles ||
+ !opts::shared::DumpModuleSubsections.empty();
bool RequestedStringTable = opts::pdb2yaml::StringTable;
if (!RequiresStringTable && !RequestedStringTable)
return Error::success();
@@ -191,6 +160,24 @@ Error YAMLOutputStyle::dumpPDBStream() {
return Error::success();
}
+static opts::ModuleSubsection convertSubsectionKind(DebugSubsectionKind K) {
+ switch (K) {
+ case DebugSubsectionKind::CrossScopeExports:
+ return opts::ModuleSubsection::CrossScopeExports;
+ case DebugSubsectionKind::CrossScopeImports:
+ return opts::ModuleSubsection::CrossScopeImports;
+ case DebugSubsectionKind::FileChecksums:
+ return opts::ModuleSubsection::FileChecksums;
+ case DebugSubsectionKind::InlineeLines:
+ return opts::ModuleSubsection::InlineeLines;
+ case DebugSubsectionKind::Lines:
+ return opts::ModuleSubsection::Lines;
+ default:
+ return opts::ModuleSubsection::Unknown;
+ }
+ llvm_unreachable("Unreachable!");
+}
+
Error YAMLOutputStyle::dumpDbiStream() {
if (!opts::pdb2yaml::DbiStream)
return Error::success();
@@ -208,7 +195,7 @@ Error YAMLOutputStyle::dumpDbiStream() {
Obj.DbiStream->PdbDllRbld = DS.getPdbDllRbld();
Obj.DbiStream->PdbDllVersion = DS.getPdbDllVersion();
Obj.DbiStream->VerHeader = DS.getDbiVersion();
- if (opts::pdb2yaml::DbiModuleInfo) {
+ if (opts::shared::DumpModules) {
const auto &Modules = DS.modules();
for (uint32_t I = 0; I < Modules.getModuleCount(); ++I) {
DbiModuleDescriptor MI = Modules.getModuleDescriptor(I);
@@ -218,7 +205,7 @@ Error YAMLOutputStyle::dumpDbiStream() {
DMI.Mod = MI.getModuleName();
DMI.Obj = MI.getObjFileName();
- if (opts::pdb2yaml::DbiModuleSourceFileInfo) {
+ if (opts::shared::DumpModuleFiles) {
auto Files = Modules.source_files(I);
DMI.SourceFiles.assign(Files.begin(), Files.end());
}
@@ -238,13 +225,17 @@ Error YAMLOutputStyle::dumpDbiStream() {
auto ExpectedST = File.getStringTable();
if (!ExpectedST)
return ExpectedST.takeError();
- if (opts::pdb2yaml::DbiModuleSourceLineInfo &&
+ if (!opts::shared::DumpModuleSubsections.empty() &&
ModS.hasDebugSubsections()) {
auto ExpectedChecksums = ModS.findChecksumsSubsection();
if (!ExpectedChecksums)
return ExpectedChecksums.takeError();
for (const auto &SS : ModS.subsections()) {
+ opts::ModuleSubsection OptionKind = convertSubsectionKind(SS.kind());
+ if (!opts::checkModuleSubsection(OptionKind))
+ continue;
+
auto Converted =
CodeViewYAML::YAMLDebugSubsection::fromCodeViewSubection(
ExpectedST->getStringTable(), *ExpectedChecksums, SS);
@@ -254,7 +245,7 @@ Error YAMLOutputStyle::dumpDbiStream() {
}
}
- if (opts::pdb2yaml::DbiModuleSyms) {
+ if (opts::shared::DumpModuleSyms) {
DMI.Modi.emplace();
DMI.Modi->Signature = ModS.signature();
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
index 4626de9c444..4d523098750 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -269,7 +269,6 @@ namespace raw {
cl::OptionCategory MsfOptions("MSF Container Options");
cl::OptionCategory TypeOptions("Type Record Options");
-cl::OptionCategory FileOptions("Module & File Options");
cl::OptionCategory SymbolOptions("Symbol Options");
cl::OptionCategory MiscOptions("Miscellaneous Options");
@@ -323,20 +322,9 @@ cl::opt<bool> DumpIpiRecordBytes(
cl::desc("dump CodeView type record raw bytes from IPI stream"),
cl::cat(TypeOptions), cl::sub(RawSubcommand));
-// MODULE & FILE OPTIONS
-cl::opt<bool> DumpModules("modules", cl::desc("dump compiland information"),
- cl::cat(FileOptions), cl::sub(RawSubcommand));
-cl::opt<bool> DumpModuleFiles("module-files", cl::desc("dump file information"),
- cl::cat(FileOptions), cl::sub(RawSubcommand));
-cl::opt<bool> DumpLineInfo("line-info",
- cl::desc("dump file and line information"),
- cl::cat(FileOptions), cl::sub(RawSubcommand));
-
// SYMBOL OPTIONS
cl::opt<bool> DumpGlobals("globals", cl::desc("dump globals stream data"),
cl::cat(SymbolOptions), cl::sub(RawSubcommand));
-cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),
- cl::cat(SymbolOptions), cl::sub(RawSubcommand));
cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"),
cl::cat(SymbolOptions), cl::sub(RawSubcommand));
cl::opt<bool>
@@ -381,11 +369,9 @@ namespace pdb2yaml {
cl::opt<bool> All("all",
cl::desc("Dump everything we know how to dump."),
cl::sub(PdbToYamlSubcommand), cl::init(false));
-cl::opt<bool>
- NoFileHeaders("no-file-headers",
- cl::desc("Do not dump MSF file headers (you will not be able "
- "to generate a fresh PDB from the resulting YAML)"),
- cl::sub(PdbToYamlSubcommand), cl::init(false));
+cl::opt<bool> NoFileHeaders("no-file-headers",
+ cl::desc("Do not dump MSF file headers"),
+ cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> Minimal("minimal",
cl::desc("Don't write fields with default values"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
@@ -406,29 +392,8 @@ cl::opt<bool> StringTable("string-table", cl::desc("Dump the PDB String Table"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> DbiStream("dbi-stream",
- cl::desc("Dump the DBI Stream (Stream 2)"),
+ cl::desc("Dump the DBI Stream Headers (Stream 2)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
-cl::opt<bool>
- DbiModuleInfo("dbi-module-info",
- cl::desc("Dump DBI Module Information (implies -dbi-stream)"),
- cl::sub(PdbToYamlSubcommand), cl::init(false));
-
-cl::opt<bool> DbiModuleSyms(
- "dbi-module-syms",
- cl::desc("Dump DBI Module Information (implies -dbi-module-info)"),
- cl::sub(PdbToYamlSubcommand), cl::init(false));
-
-cl::opt<bool> DbiModuleSourceFileInfo(
- "dbi-module-source-info",
- cl::desc(
- "Dump DBI Module Source File Information (implies -dbi-module-info)"),
- cl::sub(PdbToYamlSubcommand), cl::init(false));
-
-cl::opt<bool>
- DbiModuleSourceLineInfo("dbi-module-lines",
- cl::desc("Dump DBI Module Source Line Information "
- "(implies -dbi-module-source-info)"),
- cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> TpiStream("tpi-stream",
cl::desc("Dump the TPI Stream (Stream 3)"),
@@ -443,6 +408,39 @@ cl::list<std::string> InputFilename(cl::Positional,
cl::sub(PdbToYamlSubcommand));
}
+namespace shared {
+cl::OptionCategory FileOptions("Module & File Options");
+
+// MODULE & FILE OPTIONS
+cl::opt<bool> DumpModules("modules", cl::desc("dump compiland information"),
+ cl::cat(FileOptions), cl::sub(RawSubcommand),
+ cl::sub(PdbToYamlSubcommand));
+cl::opt<bool> DumpModuleFiles("module-files", cl::desc("dump file information"),
+ cl::cat(FileOptions), cl::sub(RawSubcommand),
+ 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::All, "all", "All known subsections")),
+ cl::cat(FileOptions), cl::sub(RawSubcommand), cl::sub(PdbToYamlSubcommand));
+cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),
+ cl::cat(FileOptions), cl::sub(RawSubcommand),
+ cl::sub(PdbToYamlSubcommand));
+} // namespace shared
+
namespace analyze {
cl::opt<bool> StringTable("hash-collisions", cl::desc("Find hash collisions"),
cl::sub(AnalyzeSubcommand), cl::init(false));
@@ -463,6 +461,13 @@ cl::opt<std::string>
static ExitOnError ExitOnErr;
+bool opts::checkModuleSubsection(opts::ModuleSubsection MS) {
+ return any_of(opts::shared::DumpModuleSubsections,
+ [=](opts::ModuleSubsection M) {
+ return M == MS || M == opts::ModuleSubsection::All;
+ });
+}
+
static void yamlToPdb(StringRef Path) {
BumpPtrAllocator Allocator;
ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
@@ -879,12 +884,29 @@ int main(int argc_, const char *argv_[]) {
}
}
+ if ((opts::RawSubcommand && opts::raw::RawAll) ||
+ (opts::PdbToYamlSubcommand && opts::pdb2yaml::All)) {
+ opts::shared::DumpModules = true;
+ opts::shared::DumpModuleFiles = true;
+ opts::shared::DumpModuleSyms = true;
+ opts::shared::DumpModuleSubsections.push_back(opts::ModuleSubsection::All);
+ if (llvm::is_contained(opts::shared::DumpModuleSubsections,
+ opts::ModuleSubsection::All)) {
+ opts::shared::DumpModuleSubsections.reset();
+ opts::shared::DumpModuleSubsections.push_back(
+ opts::ModuleSubsection::All);
+ }
+ }
+
+ if (opts::shared::DumpModuleSyms || opts::shared::DumpModuleFiles)
+ opts::shared::DumpModules = true;
+
+ if (opts::shared::DumpModules)
+ opts::pdb2yaml::DbiStream = true;
+
if (opts::RawSubcommand) {
if (opts::raw::RawAll) {
opts::raw::DumpHeaders = true;
- opts::raw::DumpModules = true;
- opts::raw::DumpModuleFiles = true;
- opts::raw::DumpModuleSyms = true;
opts::raw::DumpGlobals = true;
opts::raw::DumpPublics = true;
opts::raw::DumpSectionHeaders = true;
@@ -896,7 +918,6 @@ int main(int argc_, const char *argv_[]) {
opts::raw::DumpIpiRecords = true;
opts::raw::DumpSectionMap = true;
opts::raw::DumpSectionContribs = true;
- opts::raw::DumpLineInfo = true;
opts::raw::DumpFpo = true;
opts::raw::DumpStringTable = true;
}
@@ -908,6 +929,17 @@ int main(int argc_, const char *argv_[]) {
exit(1);
}
}
+ if (opts::PdbToYamlSubcommand) {
+ if (opts::pdb2yaml::All) {
+ opts::pdb2yaml::StreamMetadata = true;
+ opts::pdb2yaml::StreamDirectory = true;
+ opts::pdb2yaml::PdbStream = true;
+ opts::pdb2yaml::StringTable = true;
+ opts::pdb2yaml::DbiStream = true;
+ opts::pdb2yaml::TpiStream = true;
+ opts::pdb2yaml::IpiStream = true;
+ }
+ }
llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded);
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.h b/llvm/tools/llvm-pdbdump/llvm-pdbdump.h
index b344129d217..b1f527516fb 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.h
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.h
@@ -27,6 +27,25 @@ uint32_t getTypeLength(const PDBSymbolData &Symbol);
namespace opts {
+enum class ModuleSubsection {
+ Unknown,
+ Lines,
+ FileChecksums,
+ InlineeLines,
+ CrossScopeImports,
+ CrossScopeExports,
+ All
+};
+
+bool checkModuleSubsection(ModuleSubsection Kind);
+
+template <typename... Ts>
+bool checkModuleSubsection(ModuleSubsection K1, ModuleSubsection K2,
+ Ts &&... Rest) {
+ return checkModuleSubsection(K1) ||
+ checkModuleSubsection(K2, std::forward<Ts>(Rest)...);
+}
+
namespace pretty {
enum class ClassDefinitionFormat { None, Layout, All };
@@ -96,13 +115,8 @@ extern llvm::cl::opt<bool> DumpTpiRecordBytes;
extern llvm::cl::opt<bool> DumpTpiRecords;
extern llvm::cl::opt<bool> DumpIpiRecords;
extern llvm::cl::opt<bool> DumpIpiRecordBytes;
-extern llvm::cl::opt<bool> DumpModules;
-extern llvm::cl::opt<bool> DumpModuleFiles;
-extern llvm::cl::opt<bool> DumpModuleLines;
-extern llvm::cl::opt<bool> DumpModuleSyms;
extern llvm::cl::opt<bool> DumpPublics;
extern llvm::cl::opt<bool> DumpSectionContribs;
-extern llvm::cl::opt<bool> DumpLineInfo;
extern llvm::cl::opt<bool> DumpSectionMap;
extern llvm::cl::opt<bool> DumpSymRecordBytes;
extern llvm::cl::opt<bool> DumpSectionHeaders;
@@ -123,14 +137,17 @@ extern llvm::cl::opt<bool> StreamDirectory;
extern llvm::cl::opt<bool> StringTable;
extern llvm::cl::opt<bool> PdbStream;
extern llvm::cl::opt<bool> DbiStream;
-extern llvm::cl::opt<bool> DbiModuleInfo;
-extern llvm::cl::opt<bool> DbiModuleSyms;
-extern llvm::cl::opt<bool> DbiModuleSourceFileInfo;
-extern llvm::cl::opt<bool> DbiModuleSourceLineInfo;
extern llvm::cl::opt<bool> TpiStream;
extern llvm::cl::opt<bool> IpiStream;
extern llvm::cl::list<std::string> InputFilename;
}
+
+namespace shared {
+extern llvm::cl::opt<bool> DumpModules;
+extern llvm::cl::opt<bool> DumpModuleFiles;
+extern llvm::cl::list<ModuleSubsection> DumpModuleSubsections;
+extern llvm::cl::opt<bool> DumpModuleSyms;
+} // namespace shared
}
#endif
OpenPOWER on IntegriCloud