diff options
author | Zachary Turner <zturner@google.com> | 2016-09-09 19:00:49 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-09-09 19:00:49 +0000 |
commit | 36efbfa6d81b3d15144bb2d5683f654a6b4246d4 (patch) | |
tree | 6c250f111c6d63136bc7b2983479523bcb5f1d77 /llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp | |
parent | c236e5a0f1b9b8118428bec5a7adf3e3efc86cf1 (diff) | |
download | bcm5719-llvm-36efbfa6d81b3d15144bb2d5683f654a6b4246d4.tar.gz bcm5719-llvm-36efbfa6d81b3d15144bb2d5683f654a6b4246d4.zip |
[pdb] Print out some more info when dumping a raw stream.
We have various command line options that print the type of a
stream, the size of a stream, etc but nowhere that it can all be
viewed together.
Since a previous patch introduced the ability to dump the bytes
of a stream, this seems like a good place to present a full view
of the stream's properties including its size, what kind of data
it represents, and the blocks it occupies. So I added the
ability to print that information to the -stream-data command
line option.
llvm-svn: 281077
Diffstat (limited to 'llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp')
-rw-r--r-- | llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp index a9706857a12..643b89630b1 100644 --- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp +++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp @@ -157,9 +157,9 @@ Error LLVMOutputStyle::dumpFileHeaders() { return Error::success(); } -Error LLVMOutputStyle::dumpStreamSummary() { - if (!opts::raw::DumpStreamSummary) - return Error::success(); +void LLVMOutputStyle::discoverStreamPurposes() { + if (!StreamPurposes.empty()) + return; // It's OK if we fail to load some of these streams, we still attempt to print // what we can. @@ -168,7 +168,6 @@ Error LLVMOutputStyle::dumpStreamSummary() { auto Ipi = File.getPDBIpiStream(); auto Info = File.getPDBInfoStream(); - ListScope L(P, "Streams"); uint32_t StreamCount = File.getNumStreams(); std::unordered_map<uint16_t, const ModuleInfoEx *> ModStreams; std::unordered_map<uint16_t, std::string> NamedStreams; @@ -185,9 +184,8 @@ Error LLVMOutputStyle::dumpStreamSummary() { } } + StreamPurposes.resize(StreamCount); for (uint16_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) { - std::string Label("Stream "); - Label += to_string(StreamIdx); std::string Value; if (StreamIdx == OldMSFDirectory) Value = "Old MSF Directory"; @@ -258,11 +256,7 @@ Error LLVMOutputStyle::dumpStreamSummary() { Value = "???"; } } - Value = "[" + Value + "]"; - Value = - Value + " (" + to_string(File.getStreamByteSize(StreamIdx)) + " bytes)"; - - P.printString(Label, Value); + StreamPurposes[StreamIdx] = Value; } // Consume errors from missing streams. @@ -274,6 +268,27 @@ Error LLVMOutputStyle::dumpStreamSummary() { consumeError(Ipi.takeError()); if (!Info) consumeError(Info.takeError()); +} + +Error LLVMOutputStyle::dumpStreamSummary() { + if (!opts::raw::DumpStreamSummary) + return Error::success(); + + discoverStreamPurposes(); + + uint32_t StreamCount = File.getNumStreams(); + + ListScope L(P, "Streams"); + for (uint16_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) { + std::string Label("Stream "); + Label += to_string(StreamIdx); + + std::string Value = "[" + StreamPurposes[StreamIdx] + "] ("; + Value += to_string(File.getStreamByteSize(StreamIdx)); + Value += " bytes)"; + + P.printString(Label, Value); + } P.flush(); return Error::success(); @@ -377,6 +392,8 @@ Error LLVMOutputStyle::dumpStreamBytes() { if (opts::raw::DumpStreamData.empty()) return Error::success(); + discoverStreamPurposes(); + DictScope D(P, "Stream Data"); for (uint32_t SI : opts::raw::DumpStreamData) { if (SI >= File.getNumStreams()) @@ -386,15 +403,19 @@ Error LLVMOutputStyle::dumpStreamBytes() { File.getMsfBuffer(), SI); if (!S) continue; + DictScope DD(P, "Stream"); + + P.printNumber("Index", SI); + P.printString("Type", StreamPurposes[SI]); + P.printNumber("Size", S->getLength()); + auto Blocks = File.getMsfLayout().StreamMap[SI]; + P.printList("Blocks", Blocks); + StreamReader R(*S); ArrayRef<uint8_t> StreamData; if (auto EC = R.readBytes(StreamData, S->getLength())) return EC; - std::string Label; - llvm::raw_string_ostream Stream(Label); - Stream << "Stream " << SI; - Stream.flush(); - P.printBinaryBlock(Label, StreamData); + P.printBinaryBlock("Data", StreamData); } return Error::success(); } |