diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h | 5 | ||||
-rw-r--r-- | llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h | 13 | ||||
-rw-r--r-- | llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h | 5 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp | 11 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 5 |
7 files changed, 34 insertions, 22 deletions
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h index 9a08b858f19..9db38934734 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h @@ -42,7 +42,8 @@ class PDBFile : public msf::IMsfFile { friend PDBFileBuilder; public: - explicit PDBFile(std::unique_ptr<msf::StreamInterface> PdbFileBuffer); + PDBFile(std::unique_ptr<msf::StreamInterface> PdbFileBuffer, + BumpPtrAllocator &Allocator); ~PDBFile() override; uint32_t getFreeBlockMapBlock() const; @@ -89,7 +90,7 @@ public: private: Error setSuperBlock(const msf::SuperBlock *Block); - BumpPtrAllocator Allocator; + BumpPtrAllocator &Allocator; std::unique_ptr<msf::StreamInterface> Buffer; const msf::SuperBlock *SB; diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h index 891e919e585..b008b7d4769 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h @@ -14,6 +14,7 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/Optional.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" @@ -28,11 +29,10 @@ class StreamInterface; namespace pdb { class DbiStreamBuilder; class InfoStreamBuilder; -class PDBFile; class PDBFileBuilder { public: - explicit PDBFileBuilder(std::unique_ptr<msf::StreamInterface> FileBuffer); + explicit PDBFileBuilder(BumpPtrAllocator &Allocator); PDBFileBuilder(const PDBFileBuilder &) = delete; PDBFileBuilder &operator=(const PDBFileBuilder &) = delete; @@ -42,14 +42,15 @@ public: InfoStreamBuilder &getInfoBuilder(); DbiStreamBuilder &getDbiBuilder(); - Expected<std::unique_ptr<PDBFile>> build(); + Expected<std::unique_ptr<PDBFile>> + build(std::unique_ptr<msf::StreamInterface> PdbFileBuffer); private: - std::unique_ptr<InfoStreamBuilder> Info; - std::unique_ptr<DbiStreamBuilder> Dbi; + BumpPtrAllocator &Allocator; - std::unique_ptr<PDBFile> File; std::unique_ptr<msf::MsfBuilder> Msf; + std::unique_ptr<InfoStreamBuilder> Info; + std::unique_ptr<DbiStreamBuilder> Dbi; }; } } diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h b/llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h index 73d281eab1a..5a6c469fcc8 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/RawSession.h @@ -12,6 +12,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/PDB/IPDBSession.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" namespace llvm { @@ -20,7 +21,8 @@ class PDBFile; class RawSession : public IPDBSession { public: - explicit RawSession(std::unique_ptr<PDBFile> PdbFile); + RawSession(std::unique_ptr<PDBFile> PdbFile, + std::unique_ptr<BumpPtrAllocator> Allocator); ~RawSession() override; static Error createFromPdb(StringRef Path, @@ -68,6 +70,7 @@ public: private: std::unique_ptr<PDBFile> Pdb; + std::unique_ptr<BumpPtrAllocator> Allocator; }; } } diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp index b44a474b63d..e2edf38e594 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -36,8 +36,9 @@ namespace { typedef FixedStreamArray<support::ulittle32_t> ulittle_array; } -PDBFile::PDBFile(std::unique_ptr<StreamInterface> PdbFileBuffer) - : Buffer(std::move(PdbFileBuffer)), SB(nullptr) {} +PDBFile::PDBFile(std::unique_ptr<StreamInterface> PdbFileBuffer, + BumpPtrAllocator &Allocator) + : Allocator(Allocator), Buffer(std::move(PdbFileBuffer)), SB(nullptr) {} PDBFile::~PDBFile() {} diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp index c6bcd5106ca..6312cc25dba 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp @@ -26,12 +26,12 @@ using namespace llvm::msf; using namespace llvm::pdb; using namespace llvm::support; -PDBFileBuilder::PDBFileBuilder(std::unique_ptr<msf::StreamInterface> FileBuffer) - : File(llvm::make_unique<PDBFile>(std::move(FileBuffer))) {} +PDBFileBuilder::PDBFileBuilder(BumpPtrAllocator &Allocator) + : Allocator(Allocator) {} Error PDBFileBuilder::initialize(const msf::SuperBlock &Super) { auto ExpectedMsf = - MsfBuilder::create(File->Allocator, Super.BlockSize, Super.NumBlocks); + MsfBuilder::create(Allocator, Super.BlockSize, Super.NumBlocks); if (!ExpectedMsf) return ExpectedMsf.takeError(); @@ -54,11 +54,12 @@ InfoStreamBuilder &PDBFileBuilder::getInfoBuilder() { DbiStreamBuilder &PDBFileBuilder::getDbiBuilder() { if (!Dbi) - Dbi = llvm::make_unique<DbiStreamBuilder>(File->Allocator); + Dbi = llvm::make_unique<DbiStreamBuilder>(Allocator); return *Dbi; } -Expected<std::unique_ptr<PDBFile>> PDBFileBuilder::build() { +Expected<std::unique_ptr<PDBFile>> +PDBFileBuilder::build(std::unique_ptr<msf::StreamInterface> PdbFileBuffer) { if (Info) { uint32_t Length = Info->calculateSerializedLength(); if (auto EC = Msf->setStreamSize(StreamPDB, Length)) @@ -74,6 +75,7 @@ Expected<std::unique_ptr<PDBFile>> PDBFileBuilder::build() { if (!ExpectedLayout) return ExpectedLayout.takeError(); + auto File = llvm::make_unique<PDBFile>(std::move(PdbFileBuffer), Allocator); const msf::Layout &L = *ExpectedLayout; File->StreamMap = L.StreamMap; File->StreamSizes = L.StreamSizes; diff --git a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp index e734aebf47f..e6d915fcaee 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp @@ -41,8 +41,9 @@ public: }; } -RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile) - : Pdb(std::move(PdbFile)) {} +RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile, + std::unique_ptr<BumpPtrAllocator> Allocator) + : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {} RawSession::~RawSession() {} @@ -58,13 +59,15 @@ Error RawSession::createFromPdb(StringRef Path, std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer); auto Stream = llvm::make_unique<InputByteStream>(std::move(Buffer)); - std::unique_ptr<PDBFile> File(new PDBFile(std::move(Stream))); + auto Allocator = llvm::make_unique<BumpPtrAllocator>(); + auto File = llvm::make_unique<PDBFile>(std::move(Stream), *Allocator); if (auto EC = File->parseFileHeaders()) return EC; if (auto EC = File->parseStreamData()) return EC; - Session.reset(new RawSession(std::move(File))); + Session = + llvm::make_unique<RawSession>(std::move(File), std::move(Allocator)); return Error::success(); } diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index 53e27d6cf13..6c7d6058e8d 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -307,6 +307,7 @@ cl::list<std::string> InputFilename(cl::Positional, static ExitOnError ExitOnErr; static void yamlToPdb(StringRef Path) { + BumpPtrAllocator Allocator; ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer = MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1, /*RequiresNullTerminator=*/false); @@ -332,7 +333,7 @@ static void yamlToPdb(StringRef Path) { auto FileByteStream = llvm::make_unique<FileBufferByteStream>(std::move(*OutFileOrError)); - PDBFileBuilder Builder(std::move(FileByteStream)); + PDBFileBuilder Builder(Allocator); ExitOnErr(Builder.initialize(YamlObj.Headers->SuperBlock)); ExitOnErr(Builder.getMsfBuilder().setDirectoryBlocksHint( @@ -394,7 +395,7 @@ static void yamlToPdb(StringRef Path) { } } - auto Pdb = Builder.build(); + auto Pdb = Builder.build(std::move(FileByteStream)); ExitOnErr(Pdb.takeError()); auto &PdbFile = *Pdb; |