summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-05-24 20:31:48 +0000
committerZachary Turner <zturner@google.com>2016-05-24 20:31:48 +0000
commit96e60f7573a55ccf70b29cbfd4dfab28024f0447 (patch)
tree2b9376b1683acd651b1903492122cf67653163c2 /llvm/lib/DebugInfo
parent0fcdc730adac4bd873051fb88f5396918766a725 (diff)
downloadbcm5719-llvm-96e60f7573a55ccf70b29cbfd4dfab28024f0447.tar.gz
bcm5719-llvm-96e60f7573a55ccf70b29cbfd4dfab28024f0447.zip
[llvm-pdbdump] Rework command line options.
When dumping huge PDB files, too many of the options were grouped together so you would get neverending spew of output. This patch introduces more granular display options so you can only dump the fields you actually care about. llvm-svn: 270607
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp28
2 files changed, 29 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
index 7e1811daf09..2cc2a73a0d1 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
@@ -188,6 +188,10 @@ uint16_t DbiStream::getPublicSymbolStreamIndex() const {
return Header->PublicSymbolStreamIndex;
}
+uint16_t DbiStream::getGlobalSymbolStreamIndex() const {
+ return Header->GlobalSymbolStreamIndex;
+}
+
bool DbiStream::isIncrementallyLinked() const {
return (Header->Flags & FlagIncrementalMask) != 0;
}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
index af047f73abd..09d71985031 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
@@ -15,8 +15,12 @@ using namespace llvm;
using namespace llvm::pdb;
MappedBlockStream::MappedBlockStream(uint32_t StreamIdx, const PDBFile &File) : Pdb(File) {
- StreamLength = Pdb.getStreamByteSize(StreamIdx);
- BlockList = Pdb.getStreamBlockList(StreamIdx);
+ if (StreamIdx >= Pdb.getNumStreams()) {
+ StreamLength = 0;
+ } else {
+ StreamLength = Pdb.getStreamByteSize(StreamIdx);
+ BlockList = Pdb.getStreamBlockList(StreamIdx);
+ }
}
Error MappedBlockStream::readBytes(uint32_t Offset,
@@ -54,5 +58,23 @@ Error MappedBlockStream::readBytes(uint32_t Offset,
Error MappedBlockStream::getArrayRef(uint32_t Offset, ArrayRef<uint8_t> &Buffer,
uint32_t Length) const {
- return make_error<RawError>(raw_error_code::feature_unsupported);
+ uint32_t BlockNum = Offset / Pdb.getBlockSize();
+ uint32_t OffsetInBlock = Offset % Pdb.getBlockSize();
+ uint32_t BytesAvailableInBlock = Pdb.getBlockSize() - OffsetInBlock;
+
+ // If this is the last block in the stream, not all of the data is valid.
+ if (BlockNum == BlockList.size() - 1) {
+ uint32_t AllocatedBytesInBlock = StreamLength % Pdb.getBlockSize();
+ if (AllocatedBytesInBlock < BytesAvailableInBlock)
+ BytesAvailableInBlock = AllocatedBytesInBlock;
+ }
+ if (BytesAvailableInBlock < Length)
+ return make_error<RawError>(raw_error_code::feature_unsupported);
+
+ uint32_t StreamBlockAddr = BlockList[BlockNum];
+ StringRef Data = Pdb.getBlockData(StreamBlockAddr, Pdb.getBlockSize());
+ Data = Data.substr(OffsetInBlock, Length);
+
+ Buffer = ArrayRef<uint8_t>(Data.bytes_begin(), Data.bytes_end());
+ return Error::success();
}
OpenPOWER on IntegriCloud