diff options
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native')
| -rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp | 28 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp | 4 |
3 files changed, 20 insertions, 14 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp index 04e6664c68d..edaa783398c 100644 --- a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp @@ -45,12 +45,12 @@ static Error loadSectionContribs(FixedStreamArray<ContribType> &Output, return Error::success(); } -DbiStream::DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream) - : Pdb(File), Stream(std::move(Stream)), Header(nullptr) {} +DbiStream::DbiStream(std::unique_ptr<BinaryStream> Stream) + : Stream(std::move(Stream)), Header(nullptr) {} DbiStream::~DbiStream() = default; -Error DbiStream::reload() { +Error DbiStream::reload(PDBFile *Pdb) { BinaryStreamReader Reader(*Stream); if (Stream->getLength() < sizeof(DbiStreamHeader)) @@ -123,11 +123,11 @@ Error DbiStream::reload() { if (auto EC = initializeSectionContributionData()) return EC; - if (auto EC = initializeSectionHeadersData()) + if (auto EC = initializeSectionHeadersData(Pdb)) return EC; if (auto EC = initializeSectionMapData()) return EC; - if (auto EC = initializeFpoRecords()) + if (auto EC = initializeFpoRecords(Pdb)) return EC; if (Reader.bytesRemaining() > 0) @@ -246,7 +246,10 @@ Error DbiStream::initializeSectionContributionData() { } // Initializes this->SectionHeaders. -Error DbiStream::initializeSectionHeadersData() { +Error DbiStream::initializeSectionHeadersData(PDBFile *Pdb) { + if (!Pdb) + return Error::success(); + if (DbgStreams.size() == 0) return Error::success(); @@ -254,11 +257,11 @@ Error DbiStream::initializeSectionHeadersData() { if (StreamNum == kInvalidStreamIndex) return Error::success(); - if (StreamNum >= Pdb.getNumStreams()) + if (StreamNum >= Pdb->getNumStreams()) return make_error<RawError>(raw_error_code::no_stream); auto SHS = MappedBlockStream::createIndexedStream( - Pdb.getMsfLayout(), Pdb.getMsfBuffer(), StreamNum, Pdb.getAllocator()); + Pdb->getMsfLayout(), Pdb->getMsfBuffer(), StreamNum, Pdb->getAllocator()); size_t StreamLen = SHS->getLength(); if (StreamLen % sizeof(object::coff_section)) @@ -276,7 +279,10 @@ Error DbiStream::initializeSectionHeadersData() { } // Initializes this->Fpos. -Error DbiStream::initializeFpoRecords() { +Error DbiStream::initializeFpoRecords(PDBFile *Pdb) { + if (!Pdb) + return Error::success(); + if (DbgStreams.size() == 0) return Error::success(); @@ -286,11 +292,11 @@ Error DbiStream::initializeFpoRecords() { if (StreamNum == kInvalidStreamIndex) return Error::success(); - if (StreamNum >= Pdb.getNumStreams()) + if (StreamNum >= Pdb->getNumStreams()) return make_error<RawError>(raw_error_code::no_stream); auto FS = MappedBlockStream::createIndexedStream( - Pdb.getMsfLayout(), Pdb.getMsfBuffer(), StreamNum, Pdb.getAllocator()); + Pdb->getMsfLayout(), Pdb->getMsfBuffer(), StreamNum, Pdb->getAllocator()); size_t StreamLen = FS->getLength(); if (StreamLen % sizeof(object::FpoData)) diff --git a/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp b/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp index 0bb543e8c64..973a520ffca 100644 --- a/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp @@ -20,7 +20,7 @@ using namespace llvm::codeview; using namespace llvm::msf; using namespace llvm::pdb; -InfoStream::InfoStream(std::unique_ptr<MappedBlockStream> Stream) +InfoStream::InfoStream(std::unique_ptr<BinaryStream> Stream) : Stream(std::move(Stream)), Header(nullptr) {} Error InfoStream::reload() { diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp index 6b1d28a3731..78b11937f05 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp @@ -289,8 +289,8 @@ Expected<DbiStream &> PDBFile::getPDBDbiStream() { auto DbiS = safelyCreateIndexedStream(ContainerLayout, *Buffer, StreamDBI); if (!DbiS) return DbiS.takeError(); - auto TempDbi = llvm::make_unique<DbiStream>(*this, std::move(*DbiS)); - if (auto EC = TempDbi->reload()) + auto TempDbi = llvm::make_unique<DbiStream>(std::move(*DbiS)); + if (auto EC = TempDbi->reload(this)) return std::move(EC); Dbi = std::move(TempDbi); } |

