Go to the documentation of this file.
41 PDBFile::PDBFile(
StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
44 Buffer(
std::
move(PdbFileBuffer)) {}
89 return *std::max_element(ContainerLayout.
StreamSizes.begin(),
99 return ContainerLayout.
StreamMap[StreamIndex];
109 if (
auto EC = Buffer->readBytes(StreamBlockOffset, NumBytes, Result))
117 "PDBFile is immutable");
128 "MSF superblock is missing");
134 if (Buffer->getLength() % SB->
BlockSize != 0)
136 "File size is not a multiple of block size");
137 ContainerLayout.
SB = SB;
155 MappedBlockStream::createFpmStream(ContainerLayout, *Buffer, Allocator);
162 for (
auto Byte : FpmBytes) {
192 auto DS = MappedBlockStream::createDirectoryStream(ContainerLayout, *Buffer,
204 StreamSize == UINT32_MAX
215 if (
auto EC = Reader.
readArray(Blocks, NumExpectedStreamBlocks))
222 "Stream block map is corrupt.");
224 ContainerLayout.
StreamMap.push_back(Blocks);
237 std::unique_ptr<MappedBlockStream>
241 return MappedBlockStream::createIndexedStream(ContainerLayout, *Buffer, SN,
248 Result.Blocks.assign(Blocks.begin(), Blocks.end());
261 return DbiS.takeError();
266 return GlobalS.takeError();
267 auto TempGlobals = std::make_unique<GlobalsStream>(
std::move(*GlobalS));
268 if (
auto EC = TempGlobals->reload())
279 return InfoS.takeError();
280 auto TempInfo = std::make_unique<InfoStream>(
std::move(*InfoS));
281 if (
auto EC = TempInfo->reload())
292 return DbiS.takeError();
293 auto TempDbi = std::make_unique<DbiStream>(
std::move(*DbiS));
294 if (
auto EC = TempDbi->reload(
this))
305 return TpiS.takeError();
306 auto TempTpi = std::make_unique<TpiStream>(*
this,
std::move(*TpiS));
307 if (
auto EC = TempTpi->reload())
321 return IpiS.takeError();
322 auto TempIpi = std::make_unique<TpiStream>(*
this,
std::move(*IpiS));
323 if (
auto EC = TempIpi->reload())
334 return DbiS.takeError();
339 return PublicS.takeError();
340 auto TempPublics = std::make_unique<PublicsStream>(
std::move(*PublicS));
341 if (
auto EC = TempPublics->reload())
352 return DbiS.takeError();
354 uint32_t SymbolStreamNum = DbiS->getSymRecordStreamIndex();
357 return SymbolS.takeError();
359 auto TempSymbols = std::make_unique<SymbolStream>(
std::move(*SymbolS));
360 if (
auto EC = TempSymbols->reload())
371 return NS.takeError();
373 auto N = std::make_unique<PDBStringTable>();
375 if (
auto EC =
N->reload(Reader))
385 if (!InjectedSources) {
388 return IJS.takeError();
392 return Strings.takeError();
394 auto IJ = std::make_unique<InjectedSourceStream>(
std::move(*IJS));
395 if (
auto EC = IJ->reload(*Strings))
399 return *InjectedSources;
499 return IS.takeError();
504 uint32_t NameStreamIndex = *ExpectedNSI;
bool hasPDBIpiStream() const
void setOffset(uint64_t Off)
This is an optimization pass for GlobalISel generic memory operations.
ArrayRef< support::ulittle32_t > DirectoryBlocks
uint64_t bytesToBlocks(uint64_t NumBytes, uint64_t BlockSize)
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 ...
uint32_t getFreeBlockMapBlock() const
uint32_t getNumDirectoryBytes() const
StringRef getFilePath() const
static ErrorSuccess success()
Create a success value.
support::ulittle32_t NumDirectoryBytes
uint32_t getBlockMapIndex() const
uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize)
const uint16_t kInvalidStreamIndex
bool hasPDBSymbolStream()
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
bool hasPDBGlobalsStream()
uint64_t bytesRemaining() const
uint32_t getStreamByteSize(uint32_t StreamIndex) const override
Tagged union holding either a T or a Error.
Expected< SymbolStream & > getPDBSymbolStream()
MSFStreamLayout getFpmStreamLayout(const MSFLayout &Msf, bool IncludeUnusedFpmData=false, bool AltFpm=false)
Determine the layout of the FPM stream, given the MSF layout.
void consumeError(Error Err)
Consume a Error without doing anything.
uint32_t getBlockCount() const override
StringRef getFileDirectory() const
Expected< TpiStream & > getPDBIpiStream()
ArrayRef< support::ulittle32_t > getDirectoryBlockArray() const
bool hasPDBTpiStream() const
msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const
Error validateSuperBlock(const SuperBlock &SB)
Expected< std::unique_ptr< msf::MappedBlockStream > > safelyCreateIndexedStream(uint32_t StreamIndex) const
Wrapper around MappedBlockStream::createIndexedStream() that checks if a stream with that index actua...
Expected< DbiStream & > getPDBDbiStream()
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
support::ulittle32_t NumBlocks
Provides read only access to a subclass of BinaryStream.
ArrayRef< support::ulittle32_t > StreamSizes
uint32_t getNumStreams() const override
Expected< std::unique_ptr< msf::MappedBlockStream > > safelyCreateNamedStream(StringRef Name)
msf::MSFStreamLayout getFpmStreamLayout() const
Allocate memory in an ever growing pool, as if by bump-pointer.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
support::ulittle32_t FreeBlockMapBlock
uint64_t getFileSize() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
uint32_t getBlockSize() const override
Error setBlockData(uint32_t BlockIndex, uint32_t Offset, ArrayRef< uint8_t > Data) const override
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...
Expected< InjectedSourceStream & > getInjectedSourceStream()
Expected< InfoStream & > getPDBInfoStream()
bool hasPDBDbiStream() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
bool containsIdStream() const
StringRef - Represent a constant reference to a string, i.e.
bool hasPDBInjectedSourceStream()
Expected< PDBStringTable & > getStringTable()
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
uint32_t getUnknown1() const
ArrayRef< support::ulittle32_t > getStreamBlockList(uint32_t StreamIndex) const override
Expected< TpiStream & > getPDBTpiStream()
support::ulittle32_t BlockSize
support::ulittle32_t Unknown1
Lightweight error class with error context and mandatory checking.
std::vector< ArrayRef< support::ulittle32_t > > StreamMap
Expected< ArrayRef< uint8_t > > getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override
uint32_t getMaxStreamSize() const
Error takeError()
Take ownership of the stored error.
bool hasPDBPublicsStream()
COFF::MachineTypes Machine
Expected< PublicsStream & > getPDBPublicsStream()
uint32_t getPointerSize()
bool hasPDBInfoStream() const
std::unique_ptr< msf::MappedBlockStream > createIndexedStream(uint16_t SN) const
uint32_t getNumDirectoryBlocks() const
support::ulittle32_t BlockMapAddr
Expected< GlobalsStream & > getPDBGlobalsStream()
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 ...
uint64_t getBlockMapOffset() const
Describes the layout of a stream in an MSF layout.