summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-05-28 05:21:57 +0000
committerZachary Turner <zturner@google.com>2016-05-28 05:21:57 +0000
commit0d43c1c339ab5532c4527e92dc852b6e0f3f1788 (patch)
tree321e2a7cb797ccc76f6d806872e8a12ee8fd475b /llvm/lib/DebugInfo/PDB
parent9a9a3169e35306f396e2d690b157ad03a9521650 (diff)
downloadbcm5719-llvm-0d43c1c339ab5532c4527e92dc852b6e0f3f1788.tar.gz
bcm5719-llvm-0d43c1c339ab5532c4527e92dc852b6e0f3f1788.zip
[pdb] Finish conversion to zero copy pdb access.
This converts remaining uses of ByteStream, which was still left in the symbol stream and type stream, to using the new StreamInterface zero-copy classes. RecordIterator is finally deleted, so this is the only way left now. Additionally, more error checking is added when iterating the various streams. With this, the transition to zero copy pdb access is complete. llvm-svn: 271101
Diffstat (limited to 'llvm/lib/DebugInfo/PDB')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp29
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp11
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp17
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp7
5 files changed, 30 insertions, 38 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
index 67dc81da63a..bae135f77bc 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
@@ -69,28 +69,25 @@ struct ModInfo::FileLayout {
ModInfo::ModInfo() : Layout(nullptr) {}
-ModInfo::ModInfo(codeview::StreamRef Stream) : Layout(nullptr) {
- codeview::StreamReader Reader(Stream);
- if (auto EC = Reader.readObject(Layout)) {
- consumeError(std::move(EC));
- return;
- }
- if (auto EC = Reader.readZeroString(ModuleName)) {
- consumeError(std::move(EC));
- return;
- }
- if (auto EC = Reader.readZeroString(ObjFileName)) {
- consumeError(std::move(EC));
- return;
- }
-}
-
ModInfo::ModInfo(const ModInfo &Info)
: ModuleName(Info.ModuleName), ObjFileName(Info.ObjFileName),
Layout(Info.Layout) {}
ModInfo::~ModInfo() {}
+Error ModInfo::initialize(codeview::StreamRef Stream, ModInfo &Info) {
+ codeview::StreamReader Reader(Stream);
+ if (auto EC = Reader.readObject(Info.Layout))
+ return EC;
+
+ if (auto EC = Reader.readZeroString(Info.ModuleName))
+ return EC;
+
+ if (auto EC = Reader.readZeroString(Info.ObjFileName))
+ return EC;
+ return Error::success();
+}
+
bool ModInfo::hasECInfo() const { return (Layout->Flags & HasECFlagMask) != 0; }
uint16_t ModInfo::getTypeServerIndex() const {
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
index 404208a6487..88c6b7c2444 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
@@ -9,7 +9,6 @@
#include "llvm/DebugInfo/PDB/Raw/ModStream.h"
-#include "llvm/DebugInfo/CodeView/RecordIterator.h"
#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
@@ -58,6 +57,7 @@ Error ModStream::reload() {
return Error::success();
}
-iterator_range<codeview::CVSymbolArray::Iterator> ModStream::symbols() const {
+iterator_range<codeview::CVSymbolArray::Iterator>
+ModStream::symbols(bool *HadError) const {
return llvm::make_range(SymbolsSubstream.begin(), SymbolsSubstream.end());
}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
index f51a8ef17a2..d3a7ffd7f93 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
@@ -113,7 +113,7 @@ Error PublicsStream::reload() {
// A bitmap of a fixed length follows.
size_t BitmapSizeInBits = alignTo(IPHR_HASH + 1, 32);
uint32_t NumBitmapEntries = BitmapSizeInBits / 8;
- if (auto EC = Reader.readBytes(NumBitmapEntries, Bitmap))
+ if (auto EC = Reader.readBytes(Bitmap, NumBitmapEntries))
return joinErrors(std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file,
"Could not read a bitmap."));
@@ -156,13 +156,14 @@ Error PublicsStream::reload() {
return Error::success();
}
-iterator_range<codeview::SymbolIterator> PublicsStream::getSymbols() const {
- using codeview::SymbolIterator;
+iterator_range<codeview::CVSymbolArray::Iterator>
+PublicsStream::getSymbols(bool *HadError) const {
auto SymbolS = Pdb.getPDBSymbolStream();
if (SymbolS.takeError()) {
- return llvm::make_range<SymbolIterator>(SymbolIterator(), SymbolIterator());
+ codeview::CVSymbolArray::Iterator Iter;
+ return llvm::make_range(Iter, Iter);
}
SymbolStream &SS = SymbolS.get();
- return SS.getSymbols();
+ return SS.getSymbols(HadError);
}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
index ba4ea577d81..021e2299dbd 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
@@ -30,20 +30,13 @@ SymbolStream::~SymbolStream() {}
Error SymbolStream::reload() {
codeview::StreamReader Reader(MappedStream);
- if (Stream.load(Reader, MappedStream.getLength()))
- return make_error<RawError>(raw_error_code::corrupt_file,
- "Could not load symbol stream.");
+ if (auto EC = Reader.readArray(SymbolRecords, MappedStream.getLength()))
+ return EC;
return Error::success();
}
-iterator_range<codeview::SymbolIterator> SymbolStream::getSymbols() const {
- using codeview::SymbolIterator;
- ArrayRef<uint8_t> Data;
- if (auto Error = Stream.readBytes(0, Stream.getLength(), Data)) {
- consumeError(std::move(Error));
- return iterator_range<SymbolIterator>(SymbolIterator(), SymbolIterator());
- }
-
- return codeview::makeSymbolRange(Data, nullptr);
+iterator_range<codeview::CVSymbolArray::Iterator>
+SymbolStream::getSymbols(bool *HadError) const {
+ return llvm::make_range(SymbolRecords.begin(HadError), SymbolRecords.end());
}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
index 3345ab27571..6478ad1f77f 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
@@ -92,7 +92,7 @@ Error TpiStream::reload() {
HashFunction = HashBufferV8;
// The actual type records themselves come from this stream
- if (auto EC = RecordsBuffer.load(Reader, Header->TypeRecordBytes))
+ if (auto EC = Reader.readArray(TypeRecords, Header->TypeRecordBytes))
return EC;
// Hash indices, hash values, etc come from the hash stream.
@@ -136,6 +136,7 @@ uint16_t TpiStream::getTypeHashStreamAuxIndex() const {
return Header->HashAuxStreamIndex;
}
-iterator_range<codeview::TypeIterator> TpiStream::types(bool *HadError) const {
- return codeview::makeTypeRange(RecordsBuffer.data(), /*HadError=*/HadError);
+iterator_range<codeview::CVTypeArray::Iterator>
+TpiStream::types(bool *HadError) const {
+ return llvm::make_range(TypeRecords.begin(HadError), TypeRecords.end());
}
OpenPOWER on IntegriCloud