|
LLVM 24.0.0git
|
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
Public Member Functions | |
| LLVM_ABI Error | setBlockMapAddr (uint32_t Addr) |
| Request the block map to be at a specific block address. | |
| LLVM_ABI Error | setDirectoryBlocksHint (ArrayRef< uint32_t > DirBlocks) |
| LLVM_ABI void | setFreePageMap (uint32_t Fpm) |
| LLVM_ABI void | setUnknown1 (uint32_t Unk1) |
| LLVM_ABI Expected< uint32_t > | 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. | |
| LLVM_ABI Expected< uint32_t > | 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. | |
| LLVM_ABI Error | setStreamSize (uint32_t Idx, uint32_t Size) |
| Update the size of an existing stream. | |
| LLVM_ABI uint32_t | getNumStreams () const |
| Get the total number of streams in the MSF layout. | |
| LLVM_ABI uint32_t | getStreamSize (uint32_t StreamIdx) const |
| Get the size of a stream by index. | |
| LLVM_ABI ArrayRef< uint32_t > | getStreamBlocks (uint32_t StreamIdx) const |
| Get the list of blocks allocated to a particular stream. | |
| LLVM_ABI uint32_t | getNumUsedBlocks () const |
| Get the total number of blocks that will be allocated to actual data in this MSF file. | |
| LLVM_ABI uint32_t | getNumFreeBlocks () const |
| Get the total number of blocks that exist in the MSF file but are not allocated to any valid data. | |
| LLVM_ABI uint32_t | getTotalBlockCount () const |
| Get the total number of blocks in the MSF file. | |
| LLVM_ABI bool | isBlockFree (uint32_t Idx) const |
| Check whether a particular block is allocated or free. | |
| LLVM_ABI Expected< MSFLayout > | generateLayout () |
| Finalize the layout and build the headers and structures that describe the MSF layout and can be written directly to the MSF file. | |
| LLVM_ABI Expected< FileBufferByteStream > | commit (StringRef Path, MSFLayout &Layout) |
| Write the MSF layout to the underlying file. | |
| BumpPtrAllocator & | getAllocator () |
Static Public Member Functions | |
| static LLVM_ABI Expected< MSFBuilder > | create (BumpPtrAllocator &Allocator, uint32_t BlockSize, uint32_t MinBlockCount=0, bool CanGrow=true) |
| Create a new MSFBuilder. | |
Definition at line 28 of file MSFBuilder.h.
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 196 of file MSFBuilder.cpp.
References llvm::msf::bytesToBlocks(), and llvm::Size.
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, outside the preallocated range when CanGrow is false, or insufficient or excessive for the given stream size, this function will return an Error.
Definition at line 167 of file MSFBuilder.cpp.
References llvm::Block, llvm::msf::bytesToBlocks(), llvm::msf::invalid_format, llvm::make_error(), llvm::Size, llvm::ArrayRef< T >::size(), uint64_t, and llvm::msf::unspecified.
| Expected< FileBufferByteStream > MSFBuilder::commit | ( | StringRef | Path, |
| MSFLayout & | Layout ) |
Write the MSF layout to the underlying file.
Definition at line 351 of file MSFBuilder.cpp.
References llvm::msf::SuperBlock::BlockMapAddr, llvm::msf::SuperBlock::BlockSize, llvm::msf::blockToOffset(), llvm::msf::bytesToBlocks(), commitFpm(), llvm::FileOutputBuffer::create(), llvm::msf::WritableMappedBlockStream::createDirectoryStream(), llvm::msf::MSFLayout::DirectoryBlocks, llvm::formatv(), generateLayout(), llvm::msf::getMaxFileSizeFromBlockSize(), llvm::little, llvm::make_error(), llvm::msf::SuperBlock::NumBlocks, llvm::msf::SuperBlock::NumDirectoryBytes, llvm::msf::MSFLayout::SB, llvm::BinaryStreamWriter::setOffset(), llvm::msf::size_overflow_16384, llvm::msf::size_overflow_32768, llvm::msf::size_overflow_4096, llvm::msf::size_overflow_8192, llvm::msf::stream_directory_overflow, llvm::msf::MSFLayout::StreamMap, llvm::msf::MSFLayout::StreamSizes, uint64_t, llvm::BinaryStreamWriter::writeArray(), llvm::BinaryStreamWriter::writeInteger(), and llvm::BinaryStreamWriter::writeObject().
|
static |
Create a new MSFBuilder.
| BlockSize | The internal block size used by the PDB file. See isValidBlockSize() for a list of valid block sizes. |
| MinBlockCount | Causes 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. |
| CanGrow | Whether operations may increase the block count after initial preallocation. When false, requests for blocks beyond the preallocated range or for more free blocks than remain return an error. |
Definition at line 44 of file MSFBuilder.cpp.
References llvm::msf::getMinimumBlockCount(), llvm::msf::invalid_format, llvm::msf::isValidBlockSize(), kSuperBlockBlock, and llvm::make_error().
Referenced by llvm::pdb::PDBFileBuilder::initialize().
Finalize the layout and build the headers and structures that describe the MSF layout and can be written directly to the MSF file.
Definition at line 264 of file MSFBuilder.cpp.
References llvm::append_range(), llvm::ArrayRef(), B(), llvm::msf::SuperBlock::BlockMapAddr, llvm::msf::SuperBlock::BlockSize, llvm::msf::bytesToBlocks(), llvm::msf::SuperBlock::FreeBlockMapBlock, I, llvm::msf::Magic, llvm::msf::SuperBlock::MagicBytes, llvm::msf::SuperBlock::NumBlocks, llvm::msf::SuperBlock::NumDirectoryBytes, llvm::uninitialized_copy(), and llvm::msf::SuperBlock::Unknown1.
Referenced by commit().
|
inline |
Definition at line 117 of file MSFBuilder.h.
| 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 161 of file MSFBuilder.cpp.
Referenced by getNumUsedBlocks().
| 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 238 of file MSFBuilder.cpp.
| 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 157 of file MSFBuilder.cpp.
References getNumFreeBlocks(), and getTotalBlockCount().
Get the list of blocks allocated to a particular stream.
Definition at line 244 of file MSFBuilder.cpp.
Get the size of a stream by index.
Definition at line 240 of file MSFBuilder.cpp.
Referenced by setStreamSize().
| 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 163 of file MSFBuilder.cpp.
Referenced by getNumUsedBlocks().
Check whether a particular block is allocated or free.
Definition at line 165 of file MSFBuilder.cpp.
Referenced by setBlockMapAddr(), and setDirectoryBlocksHint().
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 61 of file MSFBuilder.cpp.
References llvm::msf::block_in_use, isBlockFree(), llvm::make_error(), llvm::Error::success(), and uint64_t.
Definition at line 82 of file MSFBuilder.cpp.
References B(), isBlockFree(), llvm::make_error(), llvm::Error::success(), and llvm::msf::unspecified.
| void MSFBuilder::setFreePageMap | ( | uint32_t | Fpm | ) |
Definition at line 78 of file MSFBuilder.cpp.
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 206 of file MSFBuilder.cpp.
References llvm::append_range(), llvm::msf::bytesToBlocks(), getStreamSize(), P, llvm::Size, and llvm::Error::success().
| void MSFBuilder::setUnknown1 | ( | uint32_t | Unk1 | ) |
Definition at line 80 of file MSFBuilder.cpp.