LLVM 20.0.0git
Public Member Functions | List of all members
llvm::gsym::FileWriter Class Reference

A simplified binary data writer class that doesn't require targets, target definitions, architectures, or require any other optional compile time libraries to be enabled via the build process. More...

#include "llvm/DebugInfo/GSYM/FileWriter.h"

Public Member Functions

 FileWriter (llvm::raw_pwrite_stream &S, llvm::endianness B)
 
 ~FileWriter ()
 
void writeU8 (uint8_t Value)
 Write a single uint8_t value into the stream at the current file position.
 
void writeU16 (uint16_t Value)
 Write a single uint16_t value into the stream at the current file position.
 
void writeU32 (uint32_t Value)
 Write a single uint32_t value into the stream at the current file position.
 
void writeU64 (uint64_t Value)
 Write a single uint64_t value into the stream at the current file position.
 
void writeSLEB (int64_t Value)
 Write the value into the stream encoded using signed LEB128 at the current file position.
 
void writeULEB (uint64_t Value)
 Write the value into the stream encoded using unsigned LEB128 at the current file position.
 
void writeData (llvm::ArrayRef< uint8_t > Data)
 Write an array of uint8_t values into the stream at the current file position.
 
void writeNullTerminated (llvm::StringRef Str)
 Write a NULL terminated C string into the stream at the current file position.
 
void fixup32 (uint32_t Value, uint64_t Offset)
 Fixup a uint32_t value at the specified offset in the stream.
 
void alignTo (size_t Align)
 Pad with zeroes at the current file position until the current file position matches the specified alignment.
 
uint64_t tell ()
 Return the current offset within the file.
 
llvm::raw_pwrite_streamget_stream ()
 
llvm::endianness getByteOrder () const
 

Detailed Description

A simplified binary data writer class that doesn't require targets, target definitions, architectures, or require any other optional compile time libraries to be enabled via the build process.

This class needs the ability to seek to different spots in the binary stream that is produces to fixup offsets and sizes.

Definition at line 29 of file FileWriter.h.

Constructor & Destructor Documentation

◆ FileWriter()

llvm::gsym::FileWriter::FileWriter ( llvm::raw_pwrite_stream S,
llvm::endianness  B 
)
inline

Definition at line 34 of file FileWriter.h.

References OS.

◆ ~FileWriter()

FileWriter::~FileWriter ( )

Definition at line 17 of file FileWriter.cpp.

References llvm::raw_ostream::flush().

Member Function Documentation

◆ alignTo()

void FileWriter::alignTo ( size_t  Align)

Pad with zeroes at the current file position until the current file position matches the specified alignment.

Parameters
AlignAn integer speciying the desired alignment. This does not need to be a power of two.

Definition at line 70 of file FileWriter.cpp.

References llvm::Offset, llvm::raw_ostream::tell(), and llvm::raw_ostream::write_zeros().

Referenced by llvm::gsym::FunctionInfo::encode().

◆ fixup32()

void FileWriter::fixup32 ( uint32_t  Value,
uint64_t  Offset 
)

Fixup a uint32_t value at the specified offset in the stream.

This function will save the current file position, seek to the specified offset, overwrite the data using Value, and then restore the file position to the previous file position.

Parameters
ValueThe value to write into the stream.
OffsetThe offset at which to write the Value within the stream.

Definition at line 52 of file FileWriter.cpp.

References llvm::support::endian::byte_swap(), llvm::Offset, and llvm::raw_pwrite_stream::pwrite().

Referenced by llvm::gsym::MergedFunctionsInfo::encode(), and llvm::gsym::FunctionInfo::encode().

◆ get_stream()

llvm::raw_pwrite_stream & llvm::gsym::FileWriter::get_stream ( )
inline

Definition at line 113 of file FileWriter.h.

References OS.

◆ getByteOrder()

llvm::endianness llvm::gsym::FileWriter::getByteOrder ( ) const
inline

Definition at line 117 of file FileWriter.h.

Referenced by llvm::gsym::FunctionInfo::encode().

◆ tell()

uint64_t FileWriter::tell ( )

Return the current offset within the file.

Returns
The unsigned offset from the start of the file of the current file position.

Definition at line 66 of file FileWriter.cpp.

References llvm::raw_ostream::tell().

Referenced by llvm::gsym::MergedFunctionsInfo::encode(), and llvm::gsym::FunctionInfo::encode().

◆ writeData()

void FileWriter::writeData ( llvm::ArrayRef< uint8_t Data)

Write an array of uint8_t values into the stream at the current file position.

Parameters
DataAn array of values to write into the stream.

Definition at line 58 of file FileWriter.cpp.

References llvm::Data, and llvm::raw_ostream::write().

Referenced by llvm::gsym::FunctionInfo::encode().

◆ writeNullTerminated()

void FileWriter::writeNullTerminated ( llvm::StringRef  Str)

Write a NULL terminated C string into the stream at the current file position.

The entire contents of Str will be written into the steam at the current file position and then an extra NULL termation byte will be written. It is up to the user to ensure that Str doesn't contain any NULL characters unless the additional NULL characters are desired.

Parameters
StrThe value to write into the stream.

Definition at line 62 of file FileWriter.cpp.

◆ writeSLEB()

void FileWriter::writeSLEB ( int64_t  Value)

Write the value into the stream encoded using signed LEB128 at the current file position.

Parameters
ValueThe value to write into the stream.

Definition at line 19 of file FileWriter.cpp.

References assert(), llvm::encodeSLEB128(), llvm::Length, and llvm::raw_ostream::write().

Referenced by llvm::gsym::LineTable::encode().

◆ writeU16()

void FileWriter::writeU16 ( uint16_t  Value)

Write a single uint16_t value into the stream at the current file position.

The value will be byte swapped if needed to match the byte order specified during construction.

Parameters
ValueThe value to write into the stream.

Definition at line 37 of file FileWriter.cpp.

References llvm::support::endian::byte_swap(), and llvm::raw_ostream::write().

◆ writeU32()

void FileWriter::writeU32 ( uint32_t  Value)

Write a single uint32_t value into the stream at the current file position.

The value will be byte swapped if needed to match the byte order specified during construction.

Parameters
ValueThe value to write into the stream.

Definition at line 42 of file FileWriter.cpp.

References llvm::support::endian::byte_swap(), and llvm::raw_ostream::write().

Referenced by llvm::gsym::MergedFunctionsInfo::encode(), and llvm::gsym::FunctionInfo::encode().

◆ writeU64()

void FileWriter::writeU64 ( uint64_t  Value)

Write a single uint64_t value into the stream at the current file position.

The value will be byte swapped if needed to match the byte order specified during construction.

Parameters
ValueThe value to write into the stream.

Definition at line 47 of file FileWriter.cpp.

References llvm::support::endian::byte_swap(), and llvm::raw_ostream::write().

◆ writeU8()

void FileWriter::writeU8 ( uint8_t  Value)

Write a single uint8_t value into the stream at the current file position.

Parameters
ValueThe value to write into the stream.

Definition at line 33 of file FileWriter.cpp.

References llvm::raw_ostream::write().

Referenced by llvm::gsym::LineTable::encode().

◆ writeULEB()

void FileWriter::writeULEB ( uint64_t  Value)

Write the value into the stream encoded using unsigned LEB128 at the current file position.

Parameters
ValueThe value to write into the stream.

Definition at line 26 of file FileWriter.cpp.

References assert(), llvm::encodeULEB128(), llvm::Length, and llvm::raw_ostream::write().

Referenced by llvm::gsym::LineTable::encode().


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