diff options
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp index 6e4bb16479f..ebe88dfa587 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp @@ -19,6 +19,8 @@ #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/InfoStreamBuilder.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" +#include "llvm/DebugInfo/PDB/Raw/TpiStream.h" +#include "llvm/DebugInfo/PDB/Raw/TpiStreamBuilder.h" using namespace llvm; using namespace llvm::codeview; @@ -58,6 +60,12 @@ DbiStreamBuilder &PDBFileBuilder::getDbiBuilder() { return *Dbi; } +TpiStreamBuilder &PDBFileBuilder::getTpiBuilder() { + if (!Tpi) + Tpi = llvm::make_unique<TpiStreamBuilder>(Allocator); + return *Tpi; +} + Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() const { if (Info) { uint32_t Length = Info->calculateSerializedLength(); @@ -69,6 +77,11 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() const { if (auto EC = Msf->setStreamSize(StreamDBI, Length)) return std::move(EC); } + if (Tpi) { + uint32_t Length = Tpi->calculateSerializedLength(); + if (auto EC = Msf->setStreamSize(StreamTPI, Length)) + return std::move(EC); + } return Msf->build(); } @@ -96,6 +109,13 @@ PDBFileBuilder::build(std::unique_ptr<msf::WritableStream> PdbFileBuffer) { File->Dbi = std::move(*ExpectedDbi); } + if (Tpi) { + auto ExpectedTpi = Tpi->build(*File, *PdbFileBuffer); + if (!ExpectedTpi) + return ExpectedTpi.takeError(); + File->Tpi = std::move(*ExpectedTpi); + } + if (File->Info && File->Dbi && File->Info->getAge() != File->Dbi->getAge()) return llvm::make_error<RawError>( raw_error_code::corrupt_file, @@ -144,5 +164,10 @@ Error PDBFileBuilder::commit(const msf::WritableStream &Buffer) { return EC; } + if (Tpi) { + if (auto EC = Tpi->commit(Layout, Buffer)) + return EC; + } + return Buffer.commit(); }
\ No newline at end of file |