45 InjectedSourceTable(2) {}
52 return ExpectedMsf.takeError();
53 Msf = std::make_unique<MSFBuilder>(std::move(*ExpectedMsf));
61 Info = std::make_unique<InfoStreamBuilder>(*Msf, NamedStreams);
67 Dbi = std::make_unique<DbiStreamBuilder>(*Msf);
73 Tpi = std::make_unique<TpiStreamBuilder>(*Msf,
StreamTPI);
79 Ipi = std::make_unique<TpiStreamBuilder>(*Msf,
StreamIPI);
89 Gsi = std::make_unique<GSIStreamBuilder>(*Msf);
95 auto ExpectedStream = Msf->addStream(
Size);
97 NamedStreams.
set(
Name, *ExpectedStream);
98 return ExpectedStream;
105 assert(NamedStreamData.
count(*ExpectedIndex) == 0);
106 NamedStreamData[*ExpectedIndex] = std::string(
Data);
111 std::unique_ptr<MemoryBuffer> Buffer) {
121 InjectedSourceDescriptor
Desc;
122 Desc.Content = std::move(Buffer);
124 Desc.VNameIndex = VNI;
125 Desc.StreamName =
"/src/files/";
127 Desc.StreamName += VName;
132Error PDBFileBuilder::finalizeMsfLayout() {
135 if (Ipi && Ipi->getRecordCount() > 0) {
151 if (
auto EC = Gsi->finalizeMsfLayout())
154 Dbi->setPublicsStreamIndex(Gsi->getPublicsStreamIndex());
155 Dbi->setGlobalsStreamIndex(Gsi->getGlobalsStreamIndex());
156 Dbi->setSymbolRecordStreamIndex(Gsi->getRecordStreamIndex());
160 if (
auto EC = Tpi->finalizeMsfLayout())
164 if (
auto EC = Dbi->finalizeMsfLayout())
167 SN = allocateNamedStream(
"/names", StringsLen);
172 if (
auto EC = Ipi->finalizeMsfLayout())
179 if (
auto EC =
Info->finalizeMsfLayout())
186 CRC.update(arrayRefFromStringRef(IS.Content->getBuffer()));
191 Entry.FileSize = IS.Content->getBufferSize();
192 Entry.FileNI = IS.NameIndex;
193 Entry.VFileNI = IS.VNameIndex;
198 Entry.CRC = CRC.getCRC();
200 InjectedSourceTable.
set_as(VName, std::move(Entry),
201 InjectedSourceHashTraits);
207 SN = allocateNamedStream(
"/src/headerblock", SrcHeaderBlockSize);
211 SN = allocateNamedStream(IS.StreamName, IS.Content->getBufferSize());
220 if (
auto EC =
Info->finalizeMsfLayout())
229 if (!NamedStreams.
get(
Name, SN))
244 ::memset(&Header, 0,
sizeof(Header));
246 Header.Size = Writer.bytesRemaining();
248 cantFail(Writer.writeObject(Header));
251 assert(Writer.bytesRemaining() == 0);
256 if (InjectedSourceTable.
empty())
260 commitSrcHeaderBlock(MsfBuffer, Layout);
268 assert(SourceWriter.bytesRemaining() == IS.Content->getBufferSize());
270 arrayRefFromStringRef(IS.Content->getBuffer())));
275 assert(!Filename.empty());
276 if (
auto EC = finalizeMsfLayout())
281 Msf->commit(Filename, Layout);
282 if (!ExpectedMsfBuffer)
288 return ExpectedSN.takeError();
293 if (
auto EC = Strings.
commit(NSWriter))
298 for (
const auto &NSE : NamedStreamData) {
299 if (NSE.second.empty())
305 if (
auto EC = NSW.
writeBytes(arrayRefFromStringRef(NSE.second)))
311 if (
auto EC =
Info->commit(Layout, Buffer))
316 if (
auto EC = Dbi->commit(Layout, Buffer))
321 if (
auto EC = Tpi->commit(Layout, Buffer))
326 if (
auto EC = Ipi->commit(Layout, Buffer))
331 if (
auto EC = Gsi->commit(Layout, Buffer))
336 assert(!InfoStreamBlocks.empty());
342 commitInjectedSources(Buffer, Layout);
346 if (
Info->hashPDBContentsToGUID()) {
355 memcpy(
H->Guid.Guid, &Digest, 8);
357 memcpy(
H->Guid.Guid + 8,
"LLD PDB.", 8);
360 H->Signature =
static_cast<uint32_t>(Digest);
363 memcpy(
Guid,
H->Guid.Guid, 16);
365 H->Age =
Info->getAge();
366 H->Guid =
Info->getGuid();
367 std::optional<uint32_t> Sig =
Info->getSignature();
368 H->Signature = Sig ? *Sig : time(
nullptr);
Analysis containing CSE Info
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
static const int BlockSize
Provides write only access to a subclass of WritableBinaryStream.
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
Allocate memory in an ever growing pool, as if by bump-pointer.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
An implementation of WritableBinaryStream backed by an llvm FileOutputBuffer.
Error commit() override
For buffered streams, commits changes to the backing store.
uint8_t * getBufferEnd() const
Returns a pointer to the end of the buffer.
uint8_t * getBufferStart() const
Returns a pointer to the start of the buffer.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
A BinaryStream which can be read from as well as written to.
static Expected< MSFBuilder > create(BumpPtrAllocator &Allocator, uint32_t BlockSize, uint32_t MinBlockCount=0, bool CanGrow=true)
Create a new MSFBuilder.
static std::unique_ptr< WritableMappedBlockStream > createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
bool set_as(const Key &K, ValueT V, TraitsT &Traits)
Set the entry using a key type that the specified Traits can convert from a real key to an internal k...
Error commit(BinaryStreamWriter &Writer) const
uint32_t calculateSerializedLength() const
void set(StringRef Stream, uint32_t StreamNo)
bool get(StringRef Stream, uint32_t &StreamNo) const
TpiStreamBuilder & getTpiBuilder()
msf::MSFBuilder & getMsfBuilder()
PDBStringTableBuilder & getStringTableBuilder()
Error addNamedStream(StringRef Name, StringRef Data)
DbiStreamBuilder & getDbiBuilder()
TpiStreamBuilder & getIpiBuilder()
GSIStreamBuilder & getGsiBuilder()
InfoStreamBuilder & getInfoBuilder()
Error initialize(uint32_t BlockSize)
PDBFileBuilder(BumpPtrAllocator &Allocator)
Error commit(StringRef Filename, codeview::GUID *Guid)
void addInjectedSource(StringRef Name, std::unique_ptr< MemoryBuffer > Buffer)
Expected< uint32_t > getNamedStreamIndex(StringRef Name) const
uint32_t insert(StringRef S)
uint32_t calculateSerializedSize() const
Error commit(BinaryStreamWriter &Writer) const
StringRef getStringForId(uint32_t Id) const
uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize)
This is an optimization pass for GlobalISel generic memory operations.
uint64_t xxh3_64bits(ArrayRef< uint8_t > data)
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Description of the encoding of one expression Op.
This represents the 'GUID' type from windows.h.
std::vector< ArrayRef< support::ulittle32_t > > StreamMap
support::ulittle32_t BlockSize