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

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::support::endianness  B 
)
inline

◆ ~FileWriter()

FileWriter::~FileWriter ( )

Definition at line 18 of file FileWriter.cpp.

References llvm::raw_ostream::flush().

Referenced by FileWriter().

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 71 of file FileWriter.cpp.

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

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

◆ 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 53 of file FileWriter.cpp.

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

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

◆ get_stream()

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

Definition at line 112 of file FileWriter.h.

References FileWriter().

◆ 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 67 of file FileWriter.cpp.

References llvm::raw_ostream::tell().

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

◆ 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 59 of file FileWriter.cpp.

References llvm::ArrayRef< T >::data(), llvm::ArrayRef< T >::size(), and llvm::raw_ostream::write().

Referenced by FileWriter().

◆ 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 63 of file FileWriter.cpp.

Referenced by FileWriter().

◆ 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 20 of file FileWriter.cpp.

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

Referenced by FileWriter().

◆ 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 38 of file FileWriter.cpp.

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

Referenced by FileWriter().

◆ 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 43 of file FileWriter.cpp.

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

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

◆ 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 48 of file FileWriter.cpp.

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

Referenced by FileWriter().

◆ 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 34 of file FileWriter.cpp.

References llvm::raw_ostream::write().

Referenced by llvm::gsym::InlineInfo::encode(), and FileWriter().

◆ 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 27 of file FileWriter.cpp.

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

Referenced by llvm::gsym::AddressRanges::encode(), llvm::gsym::InlineInfo::encode(), and FileWriter().


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