summaryrefslogtreecommitdiff
path: root/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp')
-rw-r--r--lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp b/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
index 6450ae752f96..54d6835f1121 100644
--- a/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
+++ b/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
@@ -25,15 +25,17 @@ using namespace llvm::pdb;
InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf,
NamedStreamMap &NamedStreams)
- : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Sig(-1), Age(0),
- NamedStreams(NamedStreams) {}
+ : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Age(0),
+ NamedStreams(NamedStreams) {
+ ::memset(&Guid, 0, sizeof(Guid));
+}
void InfoStreamBuilder::setVersion(PdbRaw_ImplVer V) { Ver = V; }
-void InfoStreamBuilder::setSignature(uint32_t S) { Sig = S; }
-
void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
+void InfoStreamBuilder::setSignature(uint32_t S) { Signature = S; }
+
void InfoStreamBuilder::setGuid(GUID G) { Guid = G; }
void InfoStreamBuilder::addFeature(PdbRaw_FeatureSig Sig) {
@@ -41,7 +43,8 @@ void InfoStreamBuilder::addFeature(PdbRaw_FeatureSig Sig) {
}
Error InfoStreamBuilder::finalizeMsfLayout() {
- uint32_t Length = sizeof(InfoStreamHeader) + NamedStreams.finalize() +
+ uint32_t Length = sizeof(InfoStreamHeader) +
+ NamedStreams.calculateSerializedLength() +
(Features.size() + 1) * sizeof(uint32_t);
if (auto EC = Msf.setStreamSize(StreamPDB, Length))
return EC;
@@ -55,10 +58,10 @@ Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout,
BinaryStreamWriter Writer(*InfoS);
InfoStreamHeader H;
- H.Age = Age;
- H.Signature = Sig;
+ // Leave the build id fields 0 so they can be set as the last step before
+ // committing the file to disk.
+ ::memset(&H, 0, sizeof(H));
H.Version = Ver;
- H.Guid = Guid;
if (auto EC = Writer.writeObject(H))
return EC;
@@ -70,5 +73,6 @@ Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout,
if (auto EC = Writer.writeEnum(E))
return EC;
}
+ assert(Writer.bytesRemaining() == 0);
return Error::success();
}