summaryrefslogtreecommitdiff
path: root/lib/DebugInfo/PDB/Native/PDBFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DebugInfo/PDB/Native/PDBFile.cpp')
-rw-r--r--lib/DebugInfo/PDB/Native/PDBFile.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/lib/DebugInfo/PDB/Native/PDBFile.cpp b/lib/DebugInfo/PDB/Native/PDBFile.cpp
index 0b6492efc70f..15b31d821b1c 100644
--- a/lib/DebugInfo/PDB/Native/PDBFile.cpp
+++ b/lib/DebugInfo/PDB/Native/PDBFile.cpp
@@ -85,6 +85,11 @@ uint32_t PDBFile::getNumStreams() const {
return ContainerLayout.StreamSizes.size();
}
+uint32_t PDBFile::getMaxStreamSize() const {
+ return *std::max_element(ContainerLayout.StreamSizes.begin(),
+ ContainerLayout.StreamSizes.end());
+}
+
uint32_t PDBFile::getStreamByteSize(uint32_t StreamIndex) const {
return ContainerLayout.StreamSizes[StreamIndex];
}
@@ -150,8 +155,7 @@ Error PDBFile::parseFileHeaders() {
MappedBlockStream::createFpmStream(ContainerLayout, *Buffer, Allocator);
BinaryStreamReader FpmReader(*FpmStream);
ArrayRef<uint8_t> FpmBytes;
- if (auto EC = FpmReader.readBytes(FpmBytes,
- msf::getFullFpmByteSize(ContainerLayout)))
+ if (auto EC = FpmReader.readBytes(FpmBytes, FpmReader.bytesRemaining()))
return EC;
uint32_t BlocksRemaining = getBlockCount();
uint32_t BI = 0;
@@ -230,6 +234,13 @@ ArrayRef<support::ulittle32_t> PDBFile::getDirectoryBlockArray() const {
return ContainerLayout.DirectoryBlocks;
}
+std::unique_ptr<MappedBlockStream> PDBFile::createIndexedStream(uint16_t SN) {
+ if (SN == kInvalidStreamIndex)
+ return nullptr;
+ return MappedBlockStream::createIndexedStream(ContainerLayout, *Buffer, SN,
+ Allocator);
+}
+
MSFStreamLayout PDBFile::getStreamLayout(uint32_t StreamIdx) const {
MSFStreamLayout Result;
auto Blocks = getStreamBlockList(StreamIdx);
@@ -238,6 +249,10 @@ MSFStreamLayout PDBFile::getStreamLayout(uint32_t StreamIdx) const {
return Result;
}
+msf::MSFStreamLayout PDBFile::getFpmStreamLayout() const {
+ return msf::getFpmStreamLayout(ContainerLayout);
+}
+
Expected<GlobalsStream &> PDBFile::getPDBGlobalsStream() {
if (!Globals) {
auto DbiS = getPDBDbiStream();
@@ -297,6 +312,9 @@ Expected<TpiStream &> PDBFile::getPDBTpiStream() {
Expected<TpiStream &> PDBFile::getPDBIpiStream() {
if (!Ipi) {
+ if (!hasPDBIpiStream())
+ return make_error<RawError>(raw_error_code::no_stream);
+
auto IpiS = safelyCreateIndexedStream(ContainerLayout, *Buffer, StreamIPI);
if (!IpiS)
return IpiS.takeError();
@@ -318,8 +336,7 @@ Expected<PublicsStream &> PDBFile::getPDBPublicsStream() {
ContainerLayout, *Buffer, DbiS->getPublicSymbolStreamIndex());
if (!PublicS)
return PublicS.takeError();
- auto TempPublics =
- llvm::make_unique<PublicsStream>(*this, std::move(*PublicS));
+ auto TempPublics = llvm::make_unique<PublicsStream>(std::move(*PublicS));
if (auto EC = TempPublics->reload())
return std::move(EC);
Publics = std::move(TempPublics);
@@ -393,9 +410,18 @@ bool PDBFile::hasPDBGlobalsStream() {
return DbiS->getGlobalSymbolStreamIndex() < getNumStreams();
}
-bool PDBFile::hasPDBInfoStream() { return StreamPDB < getNumStreams(); }
+bool PDBFile::hasPDBInfoStream() const { return StreamPDB < getNumStreams(); }
+
+bool PDBFile::hasPDBIpiStream() const {
+ if (!hasPDBInfoStream())
+ return false;
+
+ if (StreamIPI >= getNumStreams())
+ return false;
-bool PDBFile::hasPDBIpiStream() const { return StreamIPI < getNumStreams(); }
+ auto &InfoStream = cantFail(const_cast<PDBFile *>(this)->getPDBInfoStream());
+ return InfoStream.containsIdStream();
+}
bool PDBFile::hasPDBPublicsStream() {
auto DbiS = getPDBDbiStream();