34 using namespace llvm::codeview;
35 using namespace llvm::msf;
36 using namespace llvm::pdb;
42 PDBFile::PDBFile(
StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
44 : FilePath(Path), Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {}
94 return ContainerLayout.
StreamMap[StreamIndex];
104 if (
auto EC = Buffer->readBytes(StreamBlockOffset, NumBytes, Result))
105 return std::move(
EC);
112 "PDBFile is immutable");
123 "Does not contain superblock");
129 if (Buffer->getLength() % SB->
BlockSize != 0)
131 "File size is not a multiple of block size");
132 ContainerLayout.
SB =
SB;
150 MappedBlockStream::createFpmStream(ContainerLayout, *Buffer, Allocator);
158 for (
auto Byte : FpmBytes) {
188 auto DS = MappedBlockStream::createDirectoryStream(ContainerLayout, *Buffer,
199 uint64_t NumExpectedStreamBlocks =
200 StreamSize == UINT32_MAX
211 if (
auto EC = Reader.
readArray(Blocks, NumExpectedStreamBlocks))
214 uint64_t BlockEndOffset =
218 "Stream block map is corrupt.");
220 ContainerLayout.
StreamMap.push_back(Blocks);
225 DirectoryStream = std::move(DS);
236 Result.
Blocks.assign(Blocks.begin(), Blocks.end());
245 return DbiS.takeError();
247 auto GlobalS = safelyCreateIndexedStream(
248 ContainerLayout, *Buffer, DbiS->getGlobalSymbolStreamIndex());
250 return GlobalS.takeError();
251 auto TempGlobals = llvm::make_unique<GlobalsStream>(std::move(*GlobalS));
252 if (
auto EC = TempGlobals->reload())
253 return std::move(
EC);
254 Globals = std::move(TempGlobals);
261 auto InfoS = safelyCreateIndexedStream(ContainerLayout, *Buffer,
StreamPDB);
263 return InfoS.takeError();
264 auto TempInfo = llvm::make_unique<InfoStream>(std::move(*InfoS));
265 if (
auto EC = TempInfo->reload())
266 return std::move(
EC);
267 Info = std::move(TempInfo);
274 auto DbiS = safelyCreateIndexedStream(ContainerLayout, *Buffer,
StreamDBI);
276 return DbiS.takeError();
277 auto TempDbi = llvm::make_unique<DbiStream>(*
this, std::move(*DbiS));
278 if (
auto EC = TempDbi->reload())
279 return std::move(
EC);
280 Dbi = std::move(TempDbi);
287 auto TpiS = safelyCreateIndexedStream(ContainerLayout, *Buffer,
StreamTPI);
289 return TpiS.takeError();
290 auto TempTpi = llvm::make_unique<TpiStream>(*
this, std::move(*TpiS));
291 if (
auto EC = TempTpi->reload())
292 return std::move(
EC);
293 Tpi = std::move(TempTpi);
300 auto IpiS = safelyCreateIndexedStream(ContainerLayout, *Buffer,
StreamIPI);
302 return IpiS.takeError();
303 auto TempIpi = llvm::make_unique<TpiStream>(*
this, std::move(*IpiS));
304 if (
auto EC = TempIpi->reload())
305 return std::move(
EC);
306 Ipi = std::move(TempIpi);
315 return DbiS.takeError();
317 auto PublicS = safelyCreateIndexedStream(
318 ContainerLayout, *Buffer, DbiS->getPublicSymbolStreamIndex());
320 return PublicS.takeError();
322 llvm::make_unique<PublicsStream>(*
this, std::move(*PublicS));
323 if (
auto EC = TempPublics->reload())
324 return std::move(
EC);
325 Publics = std::move(TempPublics);
334 return DbiS.takeError();
336 uint32_t SymbolStreamNum = DbiS->getSymRecordStreamIndex();
338 safelyCreateIndexedStream(ContainerLayout, *Buffer, SymbolStreamNum);
340 return SymbolS.takeError();
342 auto TempSymbols = llvm::make_unique<SymbolStream>(std::move(*SymbolS));
343 if (
auto EC = TempSymbols->reload())
344 return std::move(
EC);
345 Symbols = std::move(TempSymbols);
354 return IS.takeError();
356 uint32_t NameStreamIndex = IS->getNamedStreamIndex(
"/names");
359 safelyCreateIndexedStream(ContainerLayout, *Buffer, NameStreamIndex);
361 return NS.takeError();
363 auto N = llvm::make_unique<PDBStringTable>();
365 if (
auto EC =
N->reload(Reader))
366 return std::move(
EC);
367 assert(Reader.bytesRemaining() == 0);
368 StringTableStream = std::move(*NS);
369 Strings = std::move(
N);
430 PDBFile::safelyCreateIndexedStream(
const MSFLayout &Layout,
435 return MappedBlockStream::createIndexedStream(Layout, MsfData, StreamIndex,
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
Expected< PDBStringTable & > getStringTable()
uint32_t getNumDirectoryBytes() const
bool hasPDBSymbolStream()
Error validateSuperBlock(const SuperBlock &SB)
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize)
ArrayRef< support::ulittle32_t > getDirectoryBlockArray() const
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< GlobalsStream & > getPDBGlobalsStream()
bool hasPDBPublicsStream()
uint32_t getBlockMapIndex() const
Expected< TpiStream & > getPDBTpiStream()
uint32_t getFileSize() const
uint32_t getNumStreams() const override
Error setBlockData(uint32_t BlockIndex, uint32_t Offset, ArrayRef< uint8_t > Data) const override
Describes the layout of a stream in an MSF layout.
uint64_t getBlockMapOffset() const
StringRef getFilePath() const
uint32_t getStreamByteSize(uint32_t StreamIndex) const override
uint32_t getBlockSize() const override
Tagged union holding either a T or a Error.
bool hasPDBDbiStream() const
uint32_t getPointerSize()
std::vector< support::ulittle32_t > Blocks
support::ulittle32_t BlockSize
bool hasPDBIpiStream() const
size_t size() const
size - Get the array size.
support::ulittle32_t BlockMapAddr
INITIALIZE_PASS(HexagonEarlyIfConversion,"hexagon-eif","Hexagon early if conversion", false, false) bool HexagonEarlyIfConversion MachineBasicBlock * SB
uint32_t bytesRemaining() const
Allocate memory in an ever growing pool, as if by bump-pointer.
Expected< SymbolStream & > getPDBSymbolStream()
Expected< TpiStream & > getPDBIpiStream()
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
void consumeError(Error Err)
Consume a Error without doing anything.
Expected< DbiStream & > getPDBDbiStream()
support::ulittle32_t Unknown1
uint32_t getNumDirectoryBlocks() const
void setOffset(uint32_t Off)
static ErrorSuccess success()
Create a success value.
ArrayRef< support::ulittle32_t > DirectoryBlocks
uint32_t getUnknown1() const
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
uint32_t getFreeBlockMapBlock() const
Expected< PublicsStream & > getPDBPublicsStream()
StringRef getFileDirectory() const
bool hasPDBTpiStream() const
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 ...
std::vector< ArrayRef< support::ulittle32_t > > StreamMap
bool hasPDBGlobalsStream()
Expected< ArrayRef< uint8_t > > getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override
uint32_t getFullFpmByteSize(const MSFLayout &L)
ArrayRef< support::ulittle32_t > StreamSizes
Expected< InfoStream & > getPDBInfoStream()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
support::ulittle32_t FreeBlockMapBlock
Lightweight error class with error context and mandatory checking.
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
ArrayRef< support::ulittle32_t > getStreamBlockList(uint32_t StreamIndex) const override
uint32_t getBlockCount() const override
support::ulittle32_t NumDirectoryBytes
support::ulittle32_t NumBlocks
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 ...
msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const