LLVM  6.0.0svn
Public Member Functions | Static Public Member Functions | List of all members
llvm::msf::MSFBuilder Class Reference

#include "llvm/DebugInfo/MSF/MSFBuilder.h"

Public Member Functions

Error setBlockMapAddr (uint32_t Addr)
 Request the block map to be at a specific block address. More...
 
Error setDirectoryBlocksHint (ArrayRef< uint32_t > DirBlocks)
 
void setFreePageMap (uint32_t Fpm)
 
void setUnknown1 (uint32_t Unk1)
 
Expected< uint32_taddStream (uint32_t Size, ArrayRef< uint32_t > Blocks)
 Add a stream to the MSF file with the given size, occupying the given list of blocks. More...
 
Expected< uint32_taddStream (uint32_t Size)
 Add a stream to the MSF file with the given size, occupying any available blocks that the builder decides to use. More...
 
Error setStreamSize (uint32_t Idx, uint32_t Size)
 Update the size of an existing stream. More...
 
uint32_t getNumStreams () const
 Get the total number of streams in the MSF layout. More...
 
uint32_t getStreamSize (uint32_t StreamIdx) const
 Get the size of a stream by index. More...
 
ArrayRef< uint32_tgetStreamBlocks (uint32_t StreamIdx) const
 Get the list of blocks allocated to a particular stream. More...
 
uint32_t getNumUsedBlocks () const
 Get the total number of blocks that will be allocated to actual data in this MSF file. More...
 
uint32_t getNumFreeBlocks () const
 Get the total number of blocks that exist in the MSF file but are not allocated to any valid data. More...
 
uint32_t getTotalBlockCount () const
 Get the total number of blocks in the MSF file. More...
 
bool isBlockFree (uint32_t Idx) const
 Check whether a particular block is allocated or free. More...
 
Expected< MSFLayoutbuild ()
 Finalize the layout and build the headers and structures that describe the MSF layout and can be written directly to the MSF file. More...
 
BumpPtrAllocatorgetAllocator ()
 

Static Public Member Functions

static Expected< MSFBuildercreate (BumpPtrAllocator &Allocator, uint32_t BlockSize, uint32_t MinBlockCount=0, bool CanGrow=true)
 Create a new MSFBuilder. More...
 

Detailed Description

Definition at line 25 of file MSFBuilder.h.

Member Function Documentation

◆ addStream() [1/2]

Expected< uint32_t > MSFBuilder::addStream ( uint32_t  Size,
ArrayRef< uint32_t Blocks 
)

Add a stream to the MSF file with the given size, occupying the given list of blocks.

This is useful when reading a MSF file and you want a particular stream to occupy the original set of blocks. If the given blocks are already allocated, or if the number of blocks specified is incorrect for the given stream size, this function will return an Error.

Definition at line 152 of file MSFBuilder.cpp.

References llvm::msf::bytesToBlocks(), llvm::msf::invalid_format, llvm::BitVector::reset(), llvm::BitVector::resize(), llvm::ArrayRef< T >::size(), llvm::BitVector::size(), llvm::BitVector::test(), and llvm::msf::unspecified.

Referenced by llvm::pdb::DbiStreamBuilder::addDbgStream(), llvm::pdb::GSIStreamBuilder::finalizeMsfLayout(), llvm::pdb::TpiStreamBuilder::finalizeMsfLayout(), and llvm::pdb::DbiModuleDescriptorBuilder::finalizeMsfLayout().

◆ addStream() [2/2]

Expected< uint32_t > MSFBuilder::addStream ( uint32_t  Size)

Add a stream to the MSF file with the given size, occupying any available blocks that the builder decides to use.

This is useful when building a new PDB file from scratch and you don't care what blocks a stream occupies but you just want it to work.

Definition at line 179 of file MSFBuilder.cpp.

References llvm::msf::bytesToBlocks().

◆ build()

Expected< MSFLayout > MSFBuilder::build ( )

◆ create()

Expected< MSFBuilder > MSFBuilder::create ( BumpPtrAllocator Allocator,
uint32_t  BlockSize,
uint32_t  MinBlockCount = 0,
bool  CanGrow = true 
)
static

Create a new MSFBuilder.

Parameters
BlockSizeThe internal block size used by the PDB file. See isValidBlockSize() for a list of valid block sizes.
MinBlockCountCauses the builder to reserve up front space for at least MinBlockCount blocks. This is useful when using MSFBuilder to read an existing MSF that you want to write back out later. The original MSF file's SuperBlock contains the exact number of blocks used by the file, so is a good hint as to how many blocks the new MSF file will contain. Furthermore, it is actually necessary in this case. To preserve stability of the file's layout, it is helpful to try to keep all streams mapped to their original block numbers. To ensure that this is possible, space for all blocks must be allocated beforehand so that streams can be assigned to them.
CanGrowIf true, any operation which results in an attempt to locate a free block when all available blocks have been exhausted will allocate a new block, thereby growing the size of the final MSF file. When false, any such attempt will result in an error. This is especially useful in testing scenarios when you know your test isn't going to do anything to increase the size of the file, so having an Error returned if it were to happen would catch a programming error
Returns
an llvm::Error representing whether the operation succeeded or failed. Currently the only way this can fail is if an invalid block size is specified, or MinBlockCount does not leave enough room for the mandatory reserved blocks required by an MSF file.

Definition at line 47 of file MSFBuilder.cpp.

References llvm::msf::getMinimumBlockCount(), llvm::msf::invalid_format, llvm::msf::isValidBlockSize(), and llvm::max().

◆ getAllocator()

BumpPtrAllocator& llvm::msf::MSFBuilder::getAllocator ( )
inline

◆ getNumFreeBlocks()

uint32_t MSFBuilder::getNumFreeBlocks ( ) const

Get the total number of blocks that exist in the MSF file but are not allocated to any valid data.

Definition at line 146 of file MSFBuilder.cpp.

References llvm::BitVector::count().

Referenced by getNumUsedBlocks().

◆ getNumStreams()

uint32_t MSFBuilder::getNumStreams ( ) const

Get the total number of streams in the MSF layout.

This should return 1 for every call to addStream.

Definition at line 222 of file MSFBuilder.cpp.

◆ getNumUsedBlocks()

uint32_t MSFBuilder::getNumUsedBlocks ( ) const

Get the total number of blocks that will be allocated to actual data in this MSF file.

Definition at line 142 of file MSFBuilder.cpp.

References getNumFreeBlocks(), and getTotalBlockCount().

◆ getStreamBlocks()

ArrayRef< uint32_t > MSFBuilder::getStreamBlocks ( uint32_t  StreamIdx) const

Get the list of blocks allocated to a particular stream.

Definition at line 228 of file MSFBuilder.cpp.

References assert(), llvm::msf::bytesToBlocks(), D, and llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size.

◆ getStreamSize()

uint32_t MSFBuilder::getStreamSize ( uint32_t  StreamIdx) const

Get the size of a stream by index.

Definition at line 224 of file MSFBuilder.cpp.

Referenced by setStreamSize().

◆ getTotalBlockCount()

uint32_t MSFBuilder::getTotalBlockCount ( ) const

Get the total number of blocks in the MSF file.

In practice this is equal to getNumUsedBlocks() + getNumFreeBlocks().

Definition at line 148 of file MSFBuilder.cpp.

References llvm::BitVector::size().

Referenced by getNumUsedBlocks().

◆ isBlockFree()

bool MSFBuilder::isBlockFree ( uint32_t  Idx) const

Check whether a particular block is allocated or free.

Definition at line 150 of file MSFBuilder.cpp.

Referenced by setBlockMapAddr(), and setDirectoryBlocksHint().

◆ setBlockMapAddr()

Error MSFBuilder::setBlockMapAddr ( uint32_t  Addr)

Request the block map to be at a specific block address.

This is useful when editing a MSF and you want the layout to be as stable as possible.

Definition at line 59 of file MSFBuilder.cpp.

References llvm::msf::block_in_use, llvm::msf::insufficient_buffer, isBlockFree(), llvm::BitVector::resize(), llvm::BitVector::size(), and llvm::Error::success().

◆ setDirectoryBlocksHint()

Error MSFBuilder::setDirectoryBlocksHint ( ArrayRef< uint32_t DirBlocks)

◆ setFreePageMap()

void MSFBuilder::setFreePageMap ( uint32_t  Fpm)

Definition at line 80 of file MSFBuilder.cpp.

◆ setStreamSize()

Error MSFBuilder::setStreamSize ( uint32_t  Idx,
uint32_t  Size 
)

Update the size of an existing stream.

This will allocate or deallocate blocks as needed to match the requested size. This can fail if CanGrow was set to false when initializing the MSFBuilder.

Definition at line 189 of file MSFBuilder.cpp.

References llvm::msf::bytesToBlocks(), llvm::ArrayRef< T >::drop_front(), getStreamSize(), P, llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size, and llvm::Error::success().

Referenced by llvm::pdb::InfoStreamBuilder::finalizeMsfLayout(), llvm::pdb::TpiStreamBuilder::finalizeMsfLayout(), and llvm::pdb::DbiStreamBuilder::finalizeMsfLayout().

◆ setUnknown1()

void MSFBuilder::setUnknown1 ( uint32_t  Unk1)

Definition at line 82 of file MSFBuilder.cpp.


The documentation for this class was generated from the following files: