diff options
author | Zachary Turner <zturner@google.com> | 2017-06-23 18:52:13 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-23 18:52:13 +0000 |
commit | 0b36c3ebd008e04ad2e1fc557403c97e04e9052e (patch) | |
tree | 08d0af0f39970bd2c43152abfa39eddb8b2f989b /llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp | |
parent | c0a102f505c8207d8fa6f586edcc1c00eecd8b5b (diff) | |
download | llvm-0b36c3ebd008e04ad2e1fc557403c97e04e9052e.zip llvm-0b36c3ebd008e04ad2e1fc557403c97e04e9052e.tar.gz llvm-0b36c3ebd008e04ad2e1fc557403c97e04e9052e.tar.bz2 |
[llvm-pdbutil] Add a function for formatting MSF data.
The goal here is to make it possible to display absolute
file offsets when dumping byets from an MSF. The problem is
that when dumping bytes from an MSF, often the bytes will
cross a block boundary and encounter a discontinuity. We
can't use the normal formatBinary() function for this because
this would just treat the sequence as entirely ascending, and
not account out-of-order blocks.
This patch adds a formatMsfData() function to our printer, and
then uses this function to improve the output of the -stream-data
command line option for dumping bytes from a particular stream.
Test coverage is also expanded to make sure to include all possible
scenarios of offsets, sizes, and crossing block boundaries.
llvm-svn: 306141
Diffstat (limited to 'llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp')
-rw-r--r-- | llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp index af56092..123c55d 100644 --- a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp @@ -132,36 +132,12 @@ void BytesOutputStyle::dumpStreamBytes() { auto Specs = parseStreamSpecs(P); for (const auto &Spec : Specs) { - uint32_t End = 0; - AutoIndent Indent(P); - if (Spec.SI >= File.getNumStreams()) { - P.formatLine("Stream {0}: Not present", Spec.SI); - continue; - } - - auto S = MappedBlockStream::createIndexedStream( - File.getMsfLayout(), File.getMsfBuffer(), Spec.SI, File.getAllocator()); - if (!S) { - P.NewLine(); + if (Spec.SI >= StreamPurposes.size()) { P.formatLine("Stream {0}: Not present", Spec.SI); continue; } - - if (Spec.Size == 0) - End = S->getLength(); - else - End = std::min(Spec.Begin + Spec.Size, S->getLength()); - uint32_t Size = End - Spec.Begin; - - P.formatLine("Stream {0} ({1:N} bytes): {2}", Spec.SI, S->getLength(), - StreamPurposes[Spec.SI]); - AutoIndent Indent2(P); - - BinaryStreamReader R(*S); - ArrayRef<uint8_t> StreamData; - Err(R.readBytes(StreamData, S->getLength())); - StreamData = StreamData.slice(Spec.Begin, Size); - P.formatBinary("Data", StreamData, Spec.Begin); + P.formatMsfStreamData("Data", File, Spec.SI, StreamPurposes[Spec.SI], + Spec.Begin, Spec.Size); } } |