diff options
| author | Zachary Turner <zturner@google.com> | 2017-06-23 21:11:54 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2017-06-23 21:11:54 +0000 |
| commit | dd7396825626c1f0331887821d5bcabbf8b7c3ff (patch) | |
| tree | 1daf68affc15b6a014de50bd1901ed0c20842d90 /llvm/tools | |
| parent | 9e0d3878fbc87ee9ace95773bda583426f0775d9 (diff) | |
| download | bcm5719-llvm-dd7396825626c1f0331887821d5bcabbf8b7c3ff.tar.gz bcm5719-llvm-dd7396825626c1f0331887821d5bcabbf8b7c3ff.zip | |
[llvm-pdbutil] Dump raw bytes of various DBI stream subsections.
llvm-svn: 306160
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp | 98 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/BytesOutputStyle.h | 7 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/LinePrinter.cpp | 7 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp | 25 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/llvm-pdbutil.h | 8 |
5 files changed, 138 insertions, 7 deletions
diff --git a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp index 5cf15685fe3..166136affed 100644 --- a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp @@ -13,6 +13,7 @@ #include "llvm-pdbutil.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/DbiStream.h" #include "llvm/DebugInfo/PDB/Native/InfoStream.h" #include "llvm/DebugInfo/PDB/Native/PDBFile.h" #include "llvm/DebugInfo/PDB/Native/RawError.h" @@ -122,6 +123,37 @@ Error BytesOutputStyle::dump() { dumpNameMap(); P.NewLine(); } + + if (opts::bytes::SectionContributions) { + dumpSectionContributions(); + P.NewLine(); + } + + if (opts::bytes::SectionMap) { + dumpSectionMap(); + P.NewLine(); + } + + if (opts::bytes::ModuleInfos) { + dumpModuleInfos(); + P.NewLine(); + } + + if (opts::bytes::FileInfo) { + dumpFileInfo(); + P.NewLine(); + } + + if (opts::bytes::TypeServerMap) { + dumpTypeServerMap(); + P.NewLine(); + } + + if (opts::bytes::ECData) { + dumpECData(); + P.NewLine(); + } + return Error::success(); } @@ -155,6 +187,72 @@ void BytesOutputStyle::dumpBlockRanges(uint32_t Min, uint32_t Max) { } } +void BytesOutputStyle::dumpSectionContributions() { + printHeader(P, "Section Contributions"); + + AutoIndent Indent(P); + + auto &DbiS = Err(File.getPDBDbiStream()); + BinarySubstreamRef NS = DbiS.getSectionContributionData(); + auto Layout = File.getStreamLayout(StreamDBI); + P.formatMsfStreamData("Section Contributions", File, Layout, NS); +} + +void BytesOutputStyle::dumpSectionMap() { + printHeader(P, "Section Map"); + + AutoIndent Indent(P); + + auto &DbiS = Err(File.getPDBDbiStream()); + BinarySubstreamRef NS = DbiS.getSecMapSubstreamData(); + auto Layout = File.getStreamLayout(StreamDBI); + P.formatMsfStreamData("Section Map", File, Layout, NS); +} + +void BytesOutputStyle::dumpModuleInfos() { + printHeader(P, "Module Infos"); + + AutoIndent Indent(P); + + auto &DbiS = Err(File.getPDBDbiStream()); + BinarySubstreamRef NS = DbiS.getModiSubstreamData(); + auto Layout = File.getStreamLayout(StreamDBI); + P.formatMsfStreamData("Module Infos", File, Layout, NS); +} + +void BytesOutputStyle::dumpFileInfo() { + printHeader(P, "File Info"); + + AutoIndent Indent(P); + + auto &DbiS = Err(File.getPDBDbiStream()); + BinarySubstreamRef NS = DbiS.getFileInfoSubstreamData(); + auto Layout = File.getStreamLayout(StreamDBI); + P.formatMsfStreamData("File Info", File, Layout, NS); +} + +void BytesOutputStyle::dumpTypeServerMap() { + printHeader(P, "Type Server Map"); + + AutoIndent Indent(P); + + auto &DbiS = Err(File.getPDBDbiStream()); + BinarySubstreamRef NS = DbiS.getTypeServerMapSubstreamData(); + auto Layout = File.getStreamLayout(StreamDBI); + P.formatMsfStreamData("Type Server Map", File, Layout, NS); +} + +void BytesOutputStyle::dumpECData() { + printHeader(P, "Edit and Continue Data"); + + AutoIndent Indent(P); + + auto &DbiS = Err(File.getPDBDbiStream()); + BinarySubstreamRef NS = DbiS.getECSubstreamData(); + auto Layout = File.getStreamLayout(StreamDBI); + P.formatMsfStreamData("Edit and Continue Data", File, Layout, NS); +} + void BytesOutputStyle::dumpByteRanges(uint32_t Min, uint32_t Max) { printHeader(P, "MSF Bytes"); diff --git a/llvm/tools/llvm-pdbutil/BytesOutputStyle.h b/llvm/tools/llvm-pdbutil/BytesOutputStyle.h index 4cf6937d99b..0895ee6532a 100644 --- a/llvm/tools/llvm-pdbutil/BytesOutputStyle.h +++ b/llvm/tools/llvm-pdbutil/BytesOutputStyle.h @@ -33,6 +33,13 @@ private: void dumpByteRanges(uint32_t Min, uint32_t Max); void dumpStreamBytes(); + void dumpSectionContributions(); + void dumpSectionMap(); + void dumpModuleInfos(); + void dumpFileInfo(); + void dumpTypeServerMap(); + void dumpECData(); + PDBFile &File; LinePrinter P; ExitOnError Err; diff --git a/llvm/tools/llvm-pdbutil/LinePrinter.cpp b/llvm/tools/llvm-pdbutil/LinePrinter.cpp index a9761b4337b..6e4d95af944 100644 --- a/llvm/tools/llvm-pdbutil/LinePrinter.cpp +++ b/llvm/tools/llvm-pdbutil/LinePrinter.cpp @@ -146,18 +146,19 @@ static std::vector<Run> computeBlockRuns(uint32_t BlockSize, ArrayRef<support::ulittle32_t> Blocks = Layout.Blocks; assert(!Blocks.empty()); uint32_t StreamBytesRemaining = Layout.Length; - Runs.emplace_back(Blocks[0]); + uint32_t CurrentBlock = Blocks[0]; + Runs.emplace_back(CurrentBlock); while (!Blocks.empty()) { Run *CurrentRun = &Runs.back(); uint32_t NextBlock = Blocks.front(); - if (NextBlock < CurrentRun->Block || (NextBlock - CurrentRun->Block > 1)) { + if (NextBlock < CurrentBlock || (NextBlock - CurrentBlock > 1)) { Runs.emplace_back(NextBlock); CurrentRun = &Runs.back(); } - uint32_t Used = std::min(BlockSize, StreamBytesRemaining); CurrentRun->ByteLen += Used; StreamBytesRemaining -= Used; + CurrentBlock = NextBlock; Blocks = Blocks.drop_front(); } return Runs; diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp index e1eb1b487b6..48dabc8a57a 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -267,27 +267,44 @@ cl::list<std::string> InputFilenames(cl::Positional, cl::OptionCategory FileOptions("Module & File Options"); namespace bytes { +cl::OptionCategory MsfBytes("MSF File Options"); +cl::OptionCategory DbiBytes("Dbi Stream Options"); +cl::OptionCategory PdbBytes("PDB Stream Options"); + llvm::Optional<NumberRange> DumpBlockRange; llvm::Optional<NumberRange> DumpByteRange; cl::opt<std::string> DumpBlockRangeOpt( "block-range", cl::value_desc("start[-end]"), cl::desc("Dump binary data from specified range of blocks."), - cl::sub(BytesSubcommand)); + cl::sub(BytesSubcommand), cl::cat(MsfBytes)); cl::opt<std::string> DumpByteRangeOpt("byte-range", cl::value_desc("start[-end]"), cl::desc("Dump binary data from specified range of bytes"), - cl::sub(BytesSubcommand)); + cl::sub(BytesSubcommand), cl::cat(MsfBytes)); cl::list<std::string> DumpStreamData("stream-data", cl::CommaSeparated, cl::ZeroOrMore, cl::desc("Dump binary data from specified streams. Format " "is SN[:Start][@Size]"), - cl::sub(BytesSubcommand)); + cl::sub(BytesSubcommand), cl::cat(MsfBytes)); cl::opt<bool> NameMap("name-map", cl::desc("Dump bytes of PDB Name Map"), - cl::sub(BytesSubcommand)); + cl::sub(BytesSubcommand), cl::cat(PdbBytes)); + +cl::opt<bool> SectionContributions("sc", cl::desc("Dump section contributions"), + cl::sub(BytesSubcommand), cl::cat(DbiBytes)); +cl::opt<bool> SectionMap("sm", cl::desc("Dump section map"), + cl::sub(BytesSubcommand), cl::cat(DbiBytes)); +cl::opt<bool> ModuleInfos("modi", cl::desc("Dump module info"), + cl::sub(BytesSubcommand), cl::cat(DbiBytes)); +cl::opt<bool> FileInfo("files", cl::desc("Dump source file info"), + cl::sub(BytesSubcommand), cl::cat(DbiBytes)); +cl::opt<bool> TypeServerMap("type-server", cl::desc("Dump type server map"), + cl::sub(BytesSubcommand), cl::cat(DbiBytes)); +cl::opt<bool> ECData("ec", cl::desc("Dump edit and continue map"), + cl::sub(BytesSubcommand), cl::cat(DbiBytes)); cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input PDB files>"), diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h index 882104c1d0b..b7fedd3ae43 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h @@ -102,6 +102,14 @@ extern llvm::Optional<NumberRange> DumpBlockRange; extern llvm::Optional<NumberRange> DumpByteRange; extern llvm::cl::list<std::string> DumpStreamData; extern llvm::cl::opt<bool> NameMap; + +extern llvm::cl::opt<bool> SectionContributions; +extern llvm::cl::opt<bool> SectionMap; +extern llvm::cl::opt<bool> ModuleInfos; +extern llvm::cl::opt<bool> FileInfo; +extern llvm::cl::opt<bool> TypeServerMap; +extern llvm::cl::opt<bool> ECData; + } // namespace bytes namespace dump { |

