From faa554b2fd6c327cb9cc0ac9983bd3c178f2276c Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 15 Jul 2016 22:16:56 +0000 Subject: [pdb] Use MsfBuilder to handle the writing PDBs. Previously we would read a PDB, then write some of it back out, but write the directory, super block, and other pertinent metadata back out unchanged. This generates incorrect PDBs since the amount of data written was not always the same as the amount of data read. This patch changes things to use the newly introduced `MsfBuilder` class to write out a correct and accurate set of Msf metadata for the data *actually* written, which opens up the door for adding and removing type records, symbol records, and other types of data to an existing PDB. llvm-svn: 275627 --- llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp') diff --git a/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp index 21042e9..5a0e835 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp @@ -18,7 +18,7 @@ using namespace llvm; using namespace llvm::codeview; using namespace llvm::pdb; -InfoStreamBuilder::InfoStreamBuilder(IPDBFile &File) : File(File) {} +InfoStreamBuilder::InfoStreamBuilder() {} void InfoStreamBuilder::setVersion(PdbRaw_ImplVer V) { Ver = V; } @@ -28,7 +28,12 @@ void InfoStreamBuilder::setAge(uint32_t A) { Age = A; } void InfoStreamBuilder::setGuid(PDB_UniqueId G) { Guid = G; } -Expected> InfoStreamBuilder::build() { +uint32_t InfoStreamBuilder::calculateSerializedLength() const { + return sizeof(InfoStream::HeaderInfo) + + NamedStreams.calculateSerializedLength(); +} + +Expected> InfoStreamBuilder::build(PDBFile &File) { if (!Ver.hasValue()) return make_error(raw_error_code::unspecified, "Missing PDB Stream Version"); -- cgit v1.1