[llvm] r305532 - [llvm-pdbutil] Add support for dumping cross module imports/exports.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 17:04:25 PDT 2017
Author: zturner
Date: Thu Jun 15 19:04:24 2017
New Revision: 305532
URL: http://llvm.org/viewvc/llvm-project?rev=305532&view=rev
Log:
[llvm-pdbutil] Add support for dumping cross module imports/exports.
Modified:
llvm/trunk/tools/llvm-pdbutil/FormatUtil.cpp
llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp
llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h
llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
Modified: llvm/trunk/tools/llvm-pdbutil/FormatUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/FormatUtil.cpp?rev=305532&r1=305531&r2=305532&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/FormatUtil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/FormatUtil.cpp Thu Jun 15 19:04:24 2017
@@ -17,7 +17,7 @@ using namespace llvm;
using namespace llvm::pdb;
std::string llvm::pdb::typesetItemList(ArrayRef<std::string> Opts,
- uint32_t GroupSize, uint32_t IndentLevel,
+ uint32_t IndentLevel, uint32_t GroupSize,
StringRef Sep) {
std::string Result;
while (!Opts.empty()) {
Modified: llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp?rev=305532&r1=305531&r2=305532&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp Thu Jun 15 19:04:24 2017
@@ -119,6 +119,16 @@ Error RawOutputStyle::dump() {
return EC;
}
+ if (opts::raw::DumpXmi) {
+ if (auto EC = dumpXmi())
+ return EC;
+ }
+
+ if (opts::raw::DumpXme) {
+ if (auto EC = dumpXme())
+ return EC;
+ }
+
if (opts::raw::DumpTypes || opts::raw::DumpTypeExtras) {
if (auto EC = dumpTpiStream(StreamTPI))
return EC;
@@ -566,7 +576,6 @@ static void typesetLinesAndColumns(PDBFi
Error RawOutputStyle::dumpLines() {
printHeader(P, "Lines");
- ExitOnError Err("Unexpected error processing modules");
uint32_t LastModi = UINT32_MAX;
uint32_t LastNameIndex = UINT32_MAX;
@@ -603,7 +612,6 @@ Error RawOutputStyle::dumpLines() {
Error RawOutputStyle::dumpInlineeLines() {
printHeader(P, "Inlinee Lines");
- ExitOnError Err("Unexpected error processing modules");
iterateModuleSubsections<DebugInlineeLinesSubsectionRef>(
File, P, 2,
@@ -621,6 +629,58 @@ Error RawOutputStyle::dumpInlineeLines()
return Error::success();
}
+Error RawOutputStyle::dumpXmi() {
+ printHeader(P, "Cross Module Imports");
+ iterateModuleSubsections<DebugCrossModuleImportsSubsectionRef>(
+ File, P, 2,
+ [this](uint32_t Modi, StringsAndChecksumsPrinter &Strings,
+ DebugCrossModuleImportsSubsectionRef &Imports) {
+ P.formatLine("{0,=32} | {1}", "Imported Module", "Type IDs");
+
+ for (const auto &Xmi : Imports) {
+ auto ExpectedModule =
+ Strings.getNameFromStringTable(Xmi.Header->ModuleNameOffset);
+ StringRef Module;
+ SmallString<32> ModuleStorage;
+ if (!ExpectedModule) {
+ Module = "(unknown module)";
+ consumeError(ExpectedModule.takeError());
+ } else
+ Module = *ExpectedModule;
+ if (Module.size() > 32) {
+ ModuleStorage = "...";
+ ModuleStorage += Module.take_back(32 - 3);
+ Module = ModuleStorage;
+ }
+ std::vector<std::string> TIs;
+ for (const auto I : Xmi.Imports)
+ TIs.push_back(formatv("{0,+10:X+}", fmtle(I)));
+ std::string Result =
+ typesetItemList(TIs, P.getIndentLevel() + 35, 12, " ");
+ P.formatLine("{0,+32} | {1}", Module, Result);
+ }
+ });
+
+ return Error::success();
+}
+
+Error RawOutputStyle::dumpXme() {
+ printHeader(P, "Cross Module Exports");
+
+ iterateModuleSubsections<DebugCrossModuleExportsSubsectionRef>(
+ File, P, 2,
+ [this](uint32_t Modi, StringsAndChecksumsPrinter &Strings,
+ DebugCrossModuleExportsSubsectionRef &Exports) {
+ P.formatLine("{0,-10} | {1}", "Local ID", "Global ID");
+ for (const auto &Export : Exports) {
+ P.formatLine("{0,+10:X+} | {1}", TypeIndex(Export.Local),
+ TypeIndex(Export.Global));
+ }
+ });
+
+ return Error::success();
+}
+
Error RawOutputStyle::dumpStringTable() {
printHeader(P, "String Table");
@@ -909,7 +969,7 @@ static std::string formatSectionCharacte
PUSH_FLAG(SC, IMAGE_SCN_MEM_EXECUTE, C, "IMAGE_SCN_MEM_EXECUTE");
PUSH_FLAG(SC, IMAGE_SCN_MEM_READ, C, "IMAGE_SCN_MEM_READ");
PUSH_FLAG(SC, IMAGE_SCN_MEM_WRITE, C, "IMAGE_SCN_MEM_WRITE");
- return typesetItemList(Opts, 3, IndentLevel, " | ");
+ return typesetItemList(Opts, IndentLevel, 3, " | ");
}
static std::string formatSegMapDescriptorFlag(uint32_t IndentLevel,
@@ -925,7 +985,7 @@ static std::string formatSegMapDescripto
PUSH_FLAG(OMFSegDescFlags, IsSelector, Flags, "selector");
PUSH_FLAG(OMFSegDescFlags, IsAbsoluteAddress, Flags, "absolute addr");
PUSH_FLAG(OMFSegDescFlags, IsGroup, Flags, "group");
- return typesetItemList(Opts, 4, IndentLevel, " | ");
+ return typesetItemList(Opts, IndentLevel, 4, " | ");
}
Error RawOutputStyle::dumpSectionContribs() {
Modified: llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h?rev=305532&r1=305531&r2=305532&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h Thu Jun 15 19:04:24 2017
@@ -44,6 +44,8 @@ private:
Error dumpStringTable();
Error dumpLines();
Error dumpInlineeLines();
+ Error dumpXmi();
+ Error dumpXme();
Error dumpTpiStream(uint32_t StreamIdx);
Error dumpModules();
Error dumpModuleFiles();
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=305532&r1=305531&r2=305532&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Thu Jun 15 19:04:24 2017
@@ -344,6 +344,16 @@ cl::opt<bool> DumpInlineeLines(
"il",
cl::desc("dump inlinee line information (DEBUG_S_INLINEELINES subsection)"),
cl::cat(FileOptions), cl::sub(RawSubcommand));
+cl::opt<bool> DumpXmi(
+ "xmi",
+ cl::desc(
+ "dump cross module imports (DEBUG_S_CROSSSCOPEIMPORTS subsection)"),
+ cl::cat(FileOptions), cl::sub(RawSubcommand));
+cl::opt<bool> DumpXme(
+ "xme",
+ cl::desc(
+ "dump cross module exports (DEBUG_S_CROSSSCOPEEXPORTS subsection)"),
+ cl::cat(FileOptions), cl::sub(RawSubcommand));
// MISCELLANEOUS OPTIONS
cl::opt<bool> DumpStringTable("string-table", cl::desc("dump PDB String Table"),
@@ -903,6 +913,8 @@ int main(int argc_, const char *argv_[])
if (opts::raw::RawAll) {
opts::raw::DumpLines = true;
opts::raw::DumpInlineeLines = true;
+ opts::raw::DumpXme = true;
+ opts::raw::DumpXmi = true;
opts::raw::DumpIds = true;
opts::raw::DumpPublics = true;
opts::raw::DumpSectionContribs = true;
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=305532&r1=305531&r2=305532&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h Thu Jun 15 19:04:24 2017
@@ -105,6 +105,8 @@ extern llvm::cl::list<std::string> DumpS
extern llvm::cl::opt<bool> DumpLines;
extern llvm::cl::opt<bool> DumpInlineeLines;
+extern llvm::cl::opt<bool> DumpXmi;
+extern llvm::cl::opt<bool> DumpXme;
extern llvm::cl::opt<bool> DumpStringTable;
extern llvm::cl::opt<bool> DumpTypes;
extern llvm::cl::opt<bool> DumpTypeData;
More information about the llvm-commits
mailing list