42 InjectedSourceTable(2) {}
49 return ExpectedMsf.takeError();
50 Msf = std::make_unique<MSFBuilder>(
std::move(*ExpectedMsf));
58 Info = std::make_unique<InfoStreamBuilder>(*Msf, NamedStreams);
64 Dbi = std::make_unique<DbiStreamBuilder>(*Msf);
70 Tpi = std::make_unique<TpiStreamBuilder>(*Msf,
StreamTPI);
76 Ipi = std::make_unique<TpiStreamBuilder>(*Msf,
StreamIPI);
86 Gsi = std::make_unique<GSIStreamBuilder>(*Msf);
92 auto ExpectedStream = Msf->addStream(
Size);
94 NamedStreams.
set(
Name, *ExpectedStream);
95 return ExpectedStream;
102 assert(NamedStreamData.
count(*ExpectedIndex) == 0);
103 NamedStreamData[*ExpectedIndex] = std::string(
Data);
108 std::unique_ptr<MemoryBuffer> Buffer) {
118 InjectedSourceDescriptor Desc;
121 Desc.VNameIndex = VNI;
122 Desc.StreamName =
"/src/files/";
124 Desc.StreamName += VName;
126 InjectedSources.push_back(
std::move(Desc));
129 Error PDBFileBuilder::finalizeMsfLayout() {
131 if (Ipi && Ipi->getRecordCount() > 0) {
147 if (
auto EC = Gsi->finalizeMsfLayout())
150 Dbi->setPublicsStreamIndex(Gsi->getPublicsStreamIndex());
151 Dbi->setGlobalsStreamIndex(Gsi->getGlobalsStreamIndex());
152 Dbi->setSymbolRecordStreamIndex(Gsi->getRecordStreamIndex());
156 if (
auto EC = Tpi->finalizeMsfLayout())
160 if (
auto EC = Dbi->finalizeMsfLayout())
163 SN = allocateNamedStream(
"/names", StringsLen);
168 if (
auto EC = Ipi->finalizeMsfLayout())
175 if (
auto EC =
Info->finalizeMsfLayout())
179 if (!InjectedSources.empty()) {
180 for (
const auto &IS : InjectedSources) {
182 CRC.update(arrayRefFromStringRef(IS.Content->getBuffer()));
187 Entry.
FileSize = IS.Content->getBufferSize();
188 Entry.
FileNI = IS.NameIndex;
194 Entry.
CRC = CRC.getCRC();
197 InjectedSourceHashTraits);
203 SN = allocateNamedStream(
"/src/headerblock", SrcHeaderBlockSize);
206 for (
const auto &IS : InjectedSources) {
207 SN = allocateNamedStream(IS.StreamName, IS.Content->getBufferSize());
216 if (
auto EC =
Info->finalizeMsfLayout())
225 if (!NamedStreams.
get(
Name, SN))
235 auto Stream = WritableMappedBlockStream::createIndexedStream(
240 ::memset(&Header, 0,
sizeof(Header));
242 Header.
Size = Writer.bytesRemaining();
244 cantFail(Writer.writeObject(Header));
247 assert(Writer.bytesRemaining() == 0);
252 if (InjectedSourceTable.
empty())
255 commitSrcHeaderBlock(MsfBuffer, Layout);
257 for (
const auto &IS : InjectedSources) {
260 auto SourceStream = WritableMappedBlockStream::createIndexedStream(
263 assert(SourceWriter.bytesRemaining() == IS.Content->getBufferSize());
265 arrayRefFromStringRef(IS.Content->getBuffer())));
271 if (
auto EC = finalizeMsfLayout())
276 Msf->commit(Filename, Layout);
277 if (!ExpectedMsfBuffer)
283 return ExpectedSN.takeError();
285 auto NS = WritableMappedBlockStream::createIndexedStream(
288 if (
auto EC = Strings.
commit(NSWriter))
291 for (
const auto &NSE : NamedStreamData) {
292 if (NSE.second.empty())
295 auto NS = WritableMappedBlockStream::createIndexedStream(
298 if (
auto EC = NSW.
writeBytes(arrayRefFromStringRef(NSE.second)))
303 if (
auto EC =
Info->commit(Layout, Buffer))
308 if (
auto EC = Dbi->commit(Layout, Buffer))
313 if (
auto EC = Tpi->commit(Layout, Buffer))
318 if (
auto EC = Ipi->commit(Layout, Buffer))
323 if (
auto EC = Gsi->commit(Layout, Buffer))
328 assert(!InfoStreamBlocks.empty());
334 commitInjectedSources(Buffer, Layout);
338 if (
Info->hashPDBContentsToGUID()) {
345 memcpy(
H->Guid.Guid, &Digest, 8);
347 memcpy(
H->Guid.Guid + 8,
"LLD PDB.", 8);
350 H->Signature =
static_cast<uint32_t>(Digest);
353 memcpy(Guid,
H->Guid.Guid, 16);
355 H->Age =
Info->getAge();
356 H->Guid =
Info->getGuid();
358 H->Signature = Sig ? *Sig : time(
nullptr);