summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-03-01 18:00:29 +0000
committerZachary Turner <zturner@google.com>2018-03-01 18:00:29 +0000
commitc6a75a69f15e42dd4c6b1a79f6d1a4e3df9f75ea (patch)
treed4d58a047c8d2637ccfa968decf1ba642a6e7a19 /llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
parent621cef600b4d7c466113d0a8b05ee1bf5cc07fc5 (diff)
downloadbcm5719-llvm-c6a75a69f15e42dd4c6b1a79f6d1a4e3df9f75ea.tar.gz
bcm5719-llvm-c6a75a69f15e42dd4c6b1a79f6d1a4e3df9f75ea.zip
[PDB] Defer writing the build id until the rest of the PDB is written.
For now this is NFC, but this small refactor opens the door to letting us embed a hash of the PDB in the build id field of the PDB. Differential Revision: https://reviews.llvm.org/D43913 llvm-svn: 326453
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
index dee27c621fa..1cb890ff799 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -178,6 +178,8 @@ Error PDBFileBuilder::commit(StringRef Filename) {
auto OutFileOrError = FileOutputBuffer::create(Filename, Filesize);
if (auto E = OutFileOrError.takeError())
return E;
+ FileOutputBuffer *FOB = OutFileOrError->get();
+
FileBufferByteStream Buffer(std::move(*OutFileOrError),
llvm::support::little);
BinaryStreamWriter Writer(Buffer);
@@ -242,5 +244,20 @@ Error PDBFileBuilder::commit(StringRef Filename) {
return EC;
}
+ auto InfoStreamBlocks = Layout.StreamMap[StreamPDB];
+ assert(!InfoStreamBlocks.empty());
+ uint64_t InfoStreamFileOffset =
+ blockToOffset(InfoStreamBlocks.front(), Layout.SB->BlockSize);
+ InfoStreamHeader *H = reinterpret_cast<InfoStreamHeader *>(
+ FOB->getBufferStart() + InfoStreamFileOffset);
+
+ // Set the build id at the very end, after every other byte of the PDB
+ // has been written.
+ // FIXME: Use a hash of the PDB rather than time(nullptr) for the signature.
+ H->Age = Info->getAge();
+ H->Guid = Info->getGuid();
+ Optional<uint32_t> Sig = Info->getSignature();
+ H->Signature = Sig.hasValue() ? *Sig : time(nullptr);
+
return Buffer.commit();
}
OpenPOWER on IntegriCloud