44 Buffer(
std::
move(PdbFileBuffer)) {}
98 return ContainerLayout.
StreamMap[StreamIndex];
108 if (
auto EC = Buffer->readBytes(StreamBlockOffset, NumBytes, Result))
109 return std::move(
EC);
116 "PDBFile is immutable");
127 "MSF superblock is missing");
133 if (Buffer->getLength() % SB->
BlockSize != 0)
135 "File size is not a multiple of block size");
136 ContainerLayout.
SB = SB;
161 for (
auto Byte : FpmBytes) {
162 uint32_t BlocksThisByte = std::min(BlocksRemaining, 8U);
203 StreamSize == UINT32_MAX
221 "Stream block map is corrupt.");
228 DirectoryStream = std::move(DS);
236std::unique_ptr<MappedBlockStream>
260 return DbiS.takeError();
265 return GlobalS.takeError();
266 auto TempGlobals = std::make_unique<GlobalsStream>(std::move(*GlobalS));
267 if (
auto EC = TempGlobals->reload())
268 return std::move(
EC);
269 Globals = std::move(TempGlobals);
278 return InfoS.takeError();
279 auto TempInfo = std::make_unique<InfoStream>(std::move(*InfoS));
280 if (
auto EC = TempInfo->reload())
281 return std::move(
EC);
282 Info = std::move(TempInfo);
291 return DbiS.takeError();
292 auto TempDbi = std::make_unique<DbiStream>(std::move(*DbiS));
293 if (
auto EC = TempDbi->reload(
this))
294 return std::move(
EC);
295 Dbi = std::move(TempDbi);
304 return TpiS.takeError();
305 auto TempTpi = std::make_unique<TpiStream>(*
this, std::move(*TpiS));
306 if (
auto EC = TempTpi->reload())
307 return std::move(
EC);
308 Tpi = std::move(TempTpi);
320 return IpiS.takeError();
321 auto TempIpi = std::make_unique<TpiStream>(*
this, std::move(*IpiS));
322 if (
auto EC = TempIpi->reload())
323 return std::move(
EC);
324 Ipi = std::move(TempIpi);
333 return DbiS.takeError();
338 return PublicS.takeError();
339 auto TempPublics = std::make_unique<PublicsStream>(std::move(*PublicS));
340 if (
auto EC = TempPublics->reload())
341 return std::move(
EC);
342 Publics = std::move(TempPublics);
351 return DbiS.takeError();
353 uint32_t SymbolStreamNum = DbiS->getSymRecordStreamIndex();
356 return SymbolS.takeError();
358 auto TempSymbols = std::make_unique<SymbolStream>(std::move(*SymbolS));
359 if (
auto EC = TempSymbols->reload())
360 return std::move(
EC);
361 Symbols = std::move(TempSymbols);
370 return NS.takeError();
372 auto N = std::make_unique<PDBStringTable>();
374 if (
auto EC =
N->reload(Reader))
375 return std::move(
EC);
377 StringTableStream = std::move(*NS);
378 Strings = std::move(
N);
384 if (!InjectedSources) {
387 return IJS.takeError();
391 return Strings.takeError();
393 auto IJ = std::make_unique<InjectedSourceStream>(std::move(*IJS));
394 if (
auto EC = IJ->reload(*Strings))
395 return std::move(
EC);
396 InjectedSources = std::move(IJ);
398 return *InjectedSources;
498 return IS.takeError();
503 uint32_t NameStreamIndex = *ExpectedNSI;
Lightweight arrays that are backed by an arbitrary BinaryStream.
COFF::MachineTypes Machine
DenseMap< Block *, BlockRelaxAux > Blocks
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Provides read only access to a subclass of BinaryStream.
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
Error readBytes(ArrayRef< uint8_t > &Buffer, uint32_t Size)
Read Size bytes from the underlying stream at the current offset and and set Buffer to the resulting ...
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
uint64_t bytesRemaining() const
void setOffset(uint64_t Off)
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
Allocate memory in an ever growing pool, as if by bump-pointer.
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.
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
StringRef - Represent a constant reference to a string, i.e.
Describes the layout of a stream in an MSF layout.
static std::unique_ptr< MappedBlockStream > createIndexedStream(const MSFLayout &Layout, BinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
static std::unique_ptr< MappedBlockStream > createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
static std::unique_ptr< MappedBlockStream > createFpmStream(const MSFLayout &Layout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
bool containsIdStream() const
uint32_t getNumDirectoryBlocks() const
bool hasPDBInjectedSourceStream()
Expected< InjectedSourceStream & > getInjectedSourceStream()
Expected< GlobalsStream & > getPDBGlobalsStream()
uint32_t getPointerSize()
Expected< TpiStream & > getPDBIpiStream()
uint32_t getBlockSize() const override
Expected< std::unique_ptr< msf::MappedBlockStream > > safelyCreateIndexedStream(uint32_t StreamIndex) const
Wrapper around MappedBlockStream::createIndexedStream() that checks if a stream with that index actua...
uint32_t getUnknown1() const
uint32_t getBlockMapIndex() const
Expected< DbiStream & > getPDBDbiStream()
Expected< InfoStream & > getPDBInfoStream()
bool hasPDBTpiStream() const
PDBFile(StringRef Path, std::unique_ptr< BinaryStream > PdbFileBuffer, BumpPtrAllocator &Allocator)
bool hasPDBSymbolStream()
bool hasPDBPublicsStream()
uint32_t getBlockCount() const override
bool hasPDBGlobalsStream()
StringRef getFileDirectory() const
uint32_t getMaxStreamSize() const
msf::MSFStreamLayout getFpmStreamLayout() const
Expected< PublicsStream & > getPDBPublicsStream()
Error setBlockData(uint32_t BlockIndex, uint32_t Offset, ArrayRef< uint8_t > Data) const override
Expected< TpiStream & > getPDBTpiStream()
msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const
bool hasPDBIpiStream() const
Expected< SymbolStream & > getPDBSymbolStream()
uint64_t getBlockMapOffset() const
uint64_t getFileSize() const
Expected< ArrayRef< uint8_t > > getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override
uint32_t getFreeBlockMapBlock() const
uint32_t getStreamByteSize(uint32_t StreamIndex) const override
uint32_t getNumStreams() const override
bool hasPDBInfoStream() const
StringRef getFilePath() const
ArrayRef< support::ulittle32_t > getStreamBlockList(uint32_t StreamIndex) const override
uint32_t getNumDirectoryBytes() const
bool hasPDBDbiStream() const
Expected< std::unique_ptr< msf::MappedBlockStream > > safelyCreateNamedStream(StringRef Name)
ArrayRef< support::ulittle32_t > getDirectoryBlockArray() const
Expected< PDBStringTable & > getStringTable()
std::unique_ptr< msf::MappedBlockStream > createIndexedStream(uint16_t SN) const
Error validateSuperBlock(const SuperBlock &SB)
uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize)
MSFStreamLayout getFpmStreamLayout(const MSFLayout &Msf, bool IncludeUnusedFpmData=false, bool AltFpm=false)
Determine the layout of the FPM stream, given the MSF layout.
uint64_t bytesToBlocks(uint64_t NumBytes, uint64_t BlockSize)
const uint16_t kInvalidStreamIndex
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
This is an optimization pass for GlobalISel generic memory operations.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
auto max_element(R &&Range)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.
ArrayRef< support::ulittle32_t > StreamSizes
ArrayRef< support::ulittle32_t > DirectoryBlocks
std::vector< ArrayRef< support::ulittle32_t > > StreamMap
support::ulittle32_t NumBlocks
support::ulittle32_t BlockSize
support::ulittle32_t Unknown1
support::ulittle32_t NumDirectoryBytes
support::ulittle32_t BlockMapAddr
support::ulittle32_t FreeBlockMapBlock