summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-10 03:34:47 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-10 03:34:47 +0000
commit6211b1f1f9c1434d9612aada7337ca9c6bca4a10 (patch)
tree10d918ee1534fa39ae367c0a8deac78abee498f6 /llvm/lib/DebugInfo
parentdaaf9f1379539baaeb9e6a6c1a62031d7a0ddf6c (diff)
downloadbcm5719-llvm-6211b1f1f9c1434d9612aada7337ca9c6bca4a10.tar.gz
bcm5719-llvm-6211b1f1f9c1434d9612aada7337ca9c6bca4a10.zip
[llvm-pdbdump] Propagate errors a little more consistently
PDBFile::getBlockData didn't really return any indication that it failed. It merely returned an empty buffer. llvm-svn: 275009
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp19
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp8
2 files changed, 18 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
index 3463871227b..92b2048c3c2 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
@@ -139,8 +139,10 @@ Error MappedBlockStream::readLongestContiguousChunk(
uint32_t BlockSpan = Last - First + 1;
uint32_t ByteSpan =
BytesFromFirstBlock + (BlockSpan - 1) * Pdb.getBlockSize();
- Buffer = Pdb.getBlockData(BlockList[First], Pdb.getBlockSize());
- Buffer = Buffer.drop_front(OffsetInFirstBlock);
+ auto Result = Pdb.getBlockData(BlockList[First], Pdb.getBlockSize());
+ if (!Result)
+ return Result.takeError();
+ Buffer = Result->drop_front(OffsetInFirstBlock);
Buffer = ArrayRef<uint8_t>(Buffer.data(), ByteSpan);
return Error::success();
}
@@ -173,8 +175,12 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size,
}
uint32_t FirstBlockAddr = BlockList[BlockNum];
- auto Data = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize());
- Data = Data.drop_front(OffsetInBlock);
+ auto Result = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize());
+ if (!Result) {
+ consumeError(Result.takeError());
+ return false;
+ }
+ auto Data = Result->drop_front(OffsetInBlock);
Buffer = ArrayRef<uint8_t>(Data.data(), Size);
return true;
}
@@ -197,8 +203,11 @@ Error MappedBlockStream::readBytes(uint32_t Offset,
while (BytesLeft > 0) {
uint32_t StreamBlockAddr = BlockList[BlockNum];
- auto Data = Pdb.getBlockData(StreamBlockAddr, Pdb.getBlockSize());
+ auto Result = Pdb.getBlockData(StreamBlockAddr, Pdb.getBlockSize());
+ if (!Result)
+ return Result.takeError();
+ auto Data = *Result;
const uint8_t *ChunkStart = Data.data() + OffsetInBlock;
uint32_t BytesInChunk =
std::min(BytesLeft, Pdb.getBlockSize() - OffsetInBlock);
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
index 2d8e0d0ed91..b289fd0124b 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
@@ -73,13 +73,13 @@ PDBFile::getStreamBlockList(uint32_t StreamIndex) const {
size_t PDBFile::getFileSize() const { return Buffer->getLength(); }
-ArrayRef<uint8_t> PDBFile::getBlockData(uint32_t BlockIndex,
- uint32_t NumBytes) const {
+Expected<ArrayRef<uint8_t>> PDBFile::getBlockData(uint32_t BlockIndex,
+ uint32_t NumBytes) const {
uint64_t StreamBlockOffset = blockToOffset(BlockIndex, getBlockSize());
ArrayRef<uint8_t> Result;
if (auto EC = Buffer->readBytes(StreamBlockOffset, NumBytes, Result))
- consumeError(std::move(EC));
+ return std::move(EC);
return Result;
}
@@ -460,4 +460,4 @@ Error PDBFile::commit() {
}
return Buffer->commit();
-} \ No newline at end of file
+}
OpenPOWER on IntegriCloud