LLVM  10.0.0svn
Classes | Public Member Functions | Static Protected Member Functions | List of all members
llvm::DataExtractor Class Reference

#include "llvm/Support/DataExtractor.h"

Inheritance diagram for llvm::DataExtractor:
Inheritance graph
[legend]

Classes

class  Cursor
 A class representing a position in a DataExtractor, as well as any error encountered during extraction. More...
 

Public Member Functions

 DataExtractor (StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
 Construct with a buffer that is owned by the caller. More...
 
 DataExtractor (ArrayRef< uint8_t > Data, bool IsLittleEndian, uint8_t AddressSize)
 
StringRef getData () const
 Get the data pointed to by this extractor. More...
 
bool isLittleEndian () const
 Get the endianness for this extractor. More...
 
uint8_t getAddressSize () const
 Get the address size for this extractor. More...
 
void setAddressSize (uint8_t Size)
 Set the address size for this extractor. More...
 
const chargetCStr (uint64_t *offset_ptr) const
 Extract a C string from *offset_ptr. More...
 
StringRef getCStrRef (uint64_t *offset_ptr) const
 Extract a C string from *offset_ptr. More...
 
uint64_t getUnsigned (uint64_t *offset_ptr, uint32_t byte_size, Error *Err=nullptr) const
 Extract an unsigned integer of size byte_size from *offset_ptr. More...
 
uint64_t getUnsigned (Cursor &C, uint32_t Size) const
 Extract an unsigned integer of the given size from the location given by the cursor. More...
 
int64_t getSigned (uint64_t *offset_ptr, uint32_t size) const
 Extract an signed integer of size byte_size from *offset_ptr. More...
 
uint64_t getAddress (uint64_t *offset_ptr) const
 Extract an pointer from *offset_ptr. More...
 
uint64_t getAddress (Cursor &C) const
 Extract a pointer-sized unsigned integer from the location given by the cursor. More...
 
uint8_t getU8 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint8_t value from *offset_ptr. More...
 
uint8_t getU8 (Cursor &C) const
 Extract a single uint8_t value from the location given by the cursor. More...
 
uint8_t * getU8 (uint64_t *offset_ptr, uint8_t *dst, uint32_t count) const
 Extract count uint8_t values from *offset_ptr. More...
 
uint8_t * getU8 (Cursor &C, uint8_t *Dst, uint32_t Count) const
 Extract Count uint8_t values from the location given by the cursor and store them into the destination buffer. More...
 
void getU8 (Cursor &C, SmallVectorImpl< uint8_t > &Dst, uint32_t Count) const
 Extract Count uint8_t values from the location given by the cursor and store them into the destination vector. More...
 
uint16_t getU16 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint16_t value from *offset_ptr. More...
 
uint16_t getU16 (Cursor &C) const
 Extract a single uint16_t value from the location given by the cursor. More...
 
uint16_t * getU16 (uint64_t *offset_ptr, uint16_t *dst, uint32_t count) const
 Extract count uint16_t values from *offset_ptr. More...
 
uint32_t getU24 (uint64_t *offset_ptr) const
 Extract a 24-bit unsigned value from *offset_ptr and return it in a uint32_t. More...
 
uint32_t getU32 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint32_t value from *offset_ptr. More...
 
uint32_t getU32 (Cursor &C) const
 Extract a single uint32_t value from the location given by the cursor. More...
 
uint32_tgetU32 (uint64_t *offset_ptr, uint32_t *dst, uint32_t count) const
 Extract count uint32_t values from *offset_ptr. More...
 
uint64_t getU64 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint64_t value from *offset_ptr. More...
 
uint64_t getU64 (Cursor &C) const
 Extract a single uint64_t value from the location given by the cursor. More...
 
uint64_t * getU64 (uint64_t *offset_ptr, uint64_t *dst, uint32_t count) const
 Extract count uint64_t values from *offset_ptr. More...
 
int64_t getSLEB128 (uint64_t *offset_ptr) const
 Extract a signed LEB128 value from *offset_ptr. More...
 
uint64_t getULEB128 (uint64_t *offset_ptr, llvm::Error *Err=nullptr) const
 Extract a unsigned LEB128 value from *offset_ptr. More...
 
uint64_t getULEB128 (Cursor &C) const
 Extract an unsigned ULEB128 value from the location given by the cursor. More...
 
void skip (Cursor &C, uint64_t Length) const
 Advance the Cursor position by the given number of bytes. More...
 
bool eof (const Cursor &C) const
 Return true iff the cursor is at the end of the buffer, regardless of the error state of the cursor. More...
 
bool isValidOffset (uint64_t offset) const
 Test the validity of offset. More...
 
bool isValidOffsetForDataOfSize (uint64_t offset, uint64_t length) const
 Test the availability of length bytes of data from offset. More...
 
bool isValidOffsetForAddress (uint64_t offset) const
 Test the availability of enough bytes of data for a pointer from offset. More...
 

Static Protected Member Functions

static uint64_t & getOffset (Cursor &C)
 
static ErrorgetError (Cursor &C)
 

Detailed Description

Definition at line 41 of file DataExtractor.h.

Constructor & Destructor Documentation

◆ DataExtractor() [1/2]

llvm::DataExtractor::DataExtractor ( StringRef  Data,
bool  IsLittleEndian,
uint8_t  AddressSize 
)
inline

Construct with a buffer that is owned by the caller.

This constructor allows us to use data that is owned by the caller. The data must stay around as long as this object is valid.

Definition at line 83 of file DataExtractor.h.

◆ DataExtractor() [2/2]

llvm::DataExtractor::DataExtractor ( ArrayRef< uint8_t >  Data,
bool  IsLittleEndian,
uint8_t  AddressSize 
)
inline

Definition at line 85 of file DataExtractor.h.

Member Function Documentation

◆ eof()

bool llvm::DataExtractor::eof ( const Cursor C) const
inline

Return true iff the cursor is at the end of the buffer, regardless of the error state of the cursor.

The only way both eof and error states can be true is if one attempts a read while the cursor is at the very end of the data buffer.

Definition at line 537 of file DataExtractor.h.

References llvm::StringRef::size().

◆ getAddress() [1/2]

uint64_t llvm::DataExtractor::getAddress ( uint64_t *  offset_ptr) const
inline

Extract an pointer from *offset_ptr.

Extract a single pointer from the data and update the offset pointed to by offset_ptr. The size of the extracted pointer is getAddressSize(), so the address size has to be set correctly prior to extracting any pointer values.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
Returns
The extracted pointer value as a 64 integer.

Definition at line 226 of file DataExtractor.h.

Referenced by llvm::symbolize::SymbolizableObjectFile::create(), and llvm::DWARFDebugLoclists::parseOneLocationList().

◆ getAddress() [2/2]

uint64_t llvm::DataExtractor::getAddress ( Cursor C) const
inline

Extract a pointer-sized unsigned integer from the location given by the cursor.

In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Definition at line 233 of file DataExtractor.h.

◆ getAddressSize()

uint8_t llvm::DataExtractor::getAddressSize ( ) const
inline

◆ getCStr()

const char * DataExtractor::getCStr ( uint64_t *  offset_ptr) const

Extract a C string from *offset_ptr.

Returns a pointer to a C String from the data at the offset pointed to by offset_ptr. A variable length NULL terminated C string will be extracted and the offset_ptr will be updated with the offset of the byte that follows the NULL terminator byte.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
Returns
A pointer to the C string value in the data. If the offset pointed to by offset_ptr is out of bounds, or if the offset plus the length of the C string is out of bounds, NULL will be returned.

Definition at line 154 of file DataExtractor.cpp.

References llvm::StringRef::data(), llvm::StringRef::find(), and llvm::StringRef::npos.

Referenced by dumpDWARFv5StringOffsetsSection(), dumpStringOffsetsSection(), llvm::AppleAcceleratorTable::equal_range(), llvm::DWARFFormValue::extractValue(), llvm::DWARFDebugNames::NameTableEntry::getString(), llvm::DWARFVerifier::handleDebugLine(), llvm::DWARFDebugLine::LineTable::parse(), llvm::DWARFDebugFrame::parse(), and llvm::DWARFFormValue::skipValue().

◆ getCStrRef()

StringRef DataExtractor::getCStrRef ( uint64_t *  offset_ptr) const

Extract a C string from *offset_ptr.

Returns a StringRef for the C String from the data at the offset pointed to by offset_ptr. A variable length NULL terminated C string will be extracted and the offset_ptr will be updated with the offset of the byte that follows the NULL terminator byte.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
Returns
A StringRef for the C string value in the data. If the offset pointed to by offset_ptr is out of bounds, or if the offset plus the length of the C string is out of bounds, a default-initialized StringRef will be returned.

Definition at line 164 of file DataExtractor.cpp.

Referenced by llvm::DWARFDebugPubTable::DWARFDebugPubTable(), and parseV2DirFileTables().

◆ getData()

StringRef llvm::DataExtractor::getData ( ) const
inline

◆ getError()

static Error& llvm::DataExtractor::getError ( Cursor C)
inlinestaticprotected

Definition at line 570 of file DataExtractor.h.

Referenced by llvm::DWARFDataExtractor::getRelocatedAddress().

◆ getOffset()

static uint64_t& llvm::DataExtractor::getOffset ( Cursor C)
inlinestaticprotected

Definition at line 569 of file DataExtractor.h.

Referenced by llvm::DWARFDataExtractor::getRelocatedAddress().

◆ getSigned()

int64_t DataExtractor::getSigned ( uint64_t *  offset_ptr,
uint32_t  size 
) const

Extract an signed integer of size byte_size from *offset_ptr.

Extract a single signed integer value (sign extending if required) and update the offset pointed to by offset_ptr. The size of the extracted integer is specified by the byte_size argument. byte_size should have a value greater than or equal to one and less than or equal to eight since the return value is 64 bits wide. Any byte_size values less than 1 or greater than 8 will result in nothing being extracted, and zero being returned.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[in]sizeThe size in bytes of the integer to extract.
Returns
The sign extended signed integer value that was extracted, or zero on failure.

Definition at line 140 of file DataExtractor.cpp.

References getU16(), getU32(), getU64(), getU8(), and llvm_unreachable.

Referenced by llvm::DWARFDataExtractor::getEncodedPointer(), and llvm::xray::RecordInitializer::visit().

◆ getSLEB128()

int64_t DataExtractor::getSLEB128 ( uint64_t *  offset_ptr) const

Extract a signed LEB128 value from *offset_ptr.

Extracts an signed LEB128 number from this object's data starting at the offset pointed to by offset_ptr. The offset pointed to by offset_ptr will be updated with the offset of the byte following the last extracted byte.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
Returns
The extracted signed integer value.

Definition at line 195 of file DataExtractor.cpp.

References assert(), llvm::StringRef::data(), llvm::decodeSLEB128(), error, and llvm::StringRef::size().

Referenced by llvm::DWARFExpression::Operation::extract(), llvm::DWARFAbbreviationDeclaration::extract(), llvm::DWARFFormValue::extractValue(), llvm::DWARFDataExtractor::getEncodedPointer(), parse(), llvm::dwarf::CFIProgram::parse(), llvm::DWARFDebugLine::LineTable::parse(), llvm::DWARFDebugFrame::parse(), and llvm::DWARFFormValue::skipValue().

◆ getU16() [1/3]

uint16_t DataExtractor::getU16 ( uint64_t *  offset_ptr,
llvm::Error Err = nullptr 
) const

Extract a uint16_t value from *offset_ptr.

Extract a single uint16_t from the binary data at the offset pointed to by offset_ptr, and update the offset on success.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[in,out]ErrA pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.
Returns
The extracted uint16_t value.

Definition at line 87 of file DataExtractor.cpp.

Referenced by llvm::gsym::Header::decode(), llvm::DWARFDebugPubTable::DWARFDebugPubTable(), llvm::DWARFDebugArangeSet::extract(), llvm::DWARFExpression::Operation::extract(), llvm::DWARFDebugNames::Header::extract(), llvm::DWARFFormValue::extractValue(), getSigned(), llvm::DWARFVerifier::DieRangeInfo::intersects(), llvm::DWARFDebugLine::Prologue::parse(), parseDWARF32StringOffsetsTableHeader(), parseDWARF64StringOffsetsTableHeader(), llvm::DWARFDebugLoclists::parseOneLocationList(), llvm::xray::readBinaryFormatHeader(), llvm::DWARFFormValue::skipValue(), and llvm::xray::RecordInitializer::visit().

◆ getU16() [2/3]

uint16_t llvm::DataExtractor::getU16 ( Cursor C) const
inline

Extract a single uint16_t value from the location given by the cursor.

In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Definition at line 334 of file DataExtractor.h.

References getU16().

Referenced by getU16().

◆ getU16() [3/3]

uint16_t * DataExtractor::getU16 ( uint64_t *  offset_ptr,
uint16_t *  dst,
uint32_t  count 
) const

Extract count uint16_t values from *offset_ptr.

Extract count uint16_t values from the binary data at the offset pointed to by offset_ptr, and advance the offset on success. The extracted values are copied into dst.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[out]dstA buffer to copy count uint16_t values into. dst must be large enough to hold all requested data.
[in]countThe number of uint16_t values to extract.
Returns
dst if all values were properly extracted and copied, NULL otherise.

Definition at line 91 of file DataExtractor.cpp.

References llvm::count(), and llvm::StringRef::data().

◆ getU24()

uint32_t DataExtractor::getU24 ( uint64_t *  offset_ptr) const

Extract a 24-bit unsigned value from *offset_ptr and return it in a uint32_t.

Extract 3 bytes from the binary data at the offset pointed to by offset_ptr, construct a uint32_t from them and update the offset on success.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the 3 bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
Returns
The extracted 24-bit value represented in a uint32_t.

Definition at line 97 of file DataExtractor.cpp.

References llvm::StringRef::data(), llvm::Uint24::getAsUint32(), and llvm::sys::IsLittleEndianHost.

Referenced by llvm::DWARFFormValue::extractValue().

◆ getU32() [1/3]

uint32_t DataExtractor::getU32 ( uint64_t *  offset_ptr,
llvm::Error Err = nullptr 
) const

Extract a uint32_t value from *offset_ptr.

Extract a single uint32_t from the binary data at the offset pointed to by offset_ptr, and update the offset on success.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[in,out]ErrA pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.
Returns
The extracted uint32_t value.

Definition at line 104 of file DataExtractor.cpp.

Referenced by decode(), llvm::gsym::Header::decode(), llvm::gsym::FunctionInfo::decode(), llvm::DWARFGdbIndex::dump(), dumpStringOffsetsSection(), llvm::DWARFDebugPubTable::DWARFDebugPubTable(), llvm::AppleAcceleratorTable::equal_range(), llvm::DWARFDebugAddrTable::extract(), llvm::DWARFDebugArangeSet::extract(), llvm::DWARFExpression::Operation::extract(), llvm::DWARFDebugNames::Header::extract(), llvm::DWARFFormValue::extractValue(), getSigned(), llvm::DWARFVerifier::DieRangeInfo::intersects(), llvm::DWARFUnitIndex::parse(), parseDWARF32StringOffsetsTableHeader(), parseDWARF64StringOffsetsTableHeader(), llvm::DWARFDebugLoclists::parseOneLocationList(), llvm::xray::readBinaryFormatHeader(), llvm::DWARFFormValue::skipValue(), llvm::AppleAcceleratorTable::ValueIterator::ValueIterator(), and llvm::xray::RecordInitializer::visit().

◆ getU32() [2/3]

uint32_t llvm::DataExtractor::getU32 ( Cursor C) const
inline

Extract a single uint32_t value from the location given by the cursor.

In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Definition at line 403 of file DataExtractor.h.

References getU32().

Referenced by getU32().

◆ getU32() [3/3]

uint32_t * DataExtractor::getU32 ( uint64_t *  offset_ptr,
uint32_t dst,
uint32_t  count 
) const

Extract count uint32_t values from *offset_ptr.

Extract count uint32_t values from the binary data at the offset pointed to by offset_ptr, and advance the offset on success. The extracted values are copied into dst.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[out]dstA buffer to copy count uint32_t values into. dst must be large enough to hold all requested data.
[in]countThe number of uint32_t values to extract.
Returns
dst if all values were properly extracted and copied, NULL otherise.

Definition at line 108 of file DataExtractor.cpp.

References llvm::count(), and llvm::StringRef::data().

◆ getU64() [1/3]

uint64_t DataExtractor::getU64 ( uint64_t *  offset_ptr,
llvm::Error Err = nullptr 
) const

Extract a uint64_t value from *offset_ptr.

Extract a single uint64_t from the binary data at the offset pointed to by offset_ptr, and update the offset on success.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[in,out]ErrA pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.
Returns
The extracted uint64_t value.

Definition at line 114 of file DataExtractor.cpp.

Referenced by llvm::gsym::Header::decode(), llvm::DWARFGdbIndex::dump(), llvm::DWARFExpression::Operation::extract(), llvm::DWARFListTableHeader::extract(), llvm::DWARFFormValue::extractValue(), getSigned(), llvm::DWARFVerifier::DieRangeInfo::intersects(), loadObj(), llvm::DWARFUnitIndex::parse(), llvm::DWARFDebugLine::Prologue::parse(), parseDWARF64StringOffsetsTableHeader(), llvm::xray::readBinaryFormatHeader(), and llvm::xray::RecordInitializer::visit().

◆ getU64() [2/3]

uint64_t llvm::DataExtractor::getU64 ( Cursor C) const
inline

Extract a single uint64_t value from the location given by the cursor.

In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Definition at line 455 of file DataExtractor.h.

References getU64().

Referenced by getU64().

◆ getU64() [3/3]

uint64_t * DataExtractor::getU64 ( uint64_t *  offset_ptr,
uint64_t *  dst,
uint32_t  count 
) const

Extract count uint64_t values from *offset_ptr.

Extract count uint64_t values from the binary data at the offset pointed to by offset_ptr, and advance the offset on success. The extracted values are copied into dst.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[out]dstA buffer to copy count uint64_t values into. dst must be large enough to hold all requested data.
[in]countThe number of uint64_t values to extract.
Returns
dst if all values were properly extracted and copied, NULL otherise.

Definition at line 118 of file DataExtractor.cpp.

References llvm::count(), and llvm::StringRef::data().

◆ getU8() [1/5]

uint8_t DataExtractor::getU8 ( uint64_t *  offset_ptr,
llvm::Error Err = nullptr 
) const

Extract a uint8_t value from *offset_ptr.

Extract a single uint8_t from the binary data at the offset pointed to by offset_ptr, and advance the offset on success.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[in,out]ErrA pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.
Returns
The extracted uint8_t value.

Definition at line 72 of file DataExtractor.cpp.

Referenced by decode(), llvm::gsym::Header::decode(), dumpDataAux(), llvm::DWARFDebugPubTable::DWARFDebugPubTable(), llvm::DWARFDebugArangeSet::extract(), llvm::DWARFExpression::Operation::extract(), llvm::DWARFAbbreviationDeclaration::extract(), llvm::DWARFDebugNames::Header::extract(), llvm::DWARFFormValue::extractValue(), getSigned(), llvm::DWARFVerifier::DieRangeInfo::intersects(), loadObj(), llvm::DWARFDebugLine::Prologue::parse(), llvm::DWARFDebugLine::LineTable::parse(), llvm::DWARFDebugFrame::parse(), llvm::DWARFDebugLoclists::parseOneLocationList(), parseV5DirFileTables(), parseV5EntryFormat(), llvm::DWARFExpression::Operation::print(), llvm::xray::FileBasedRecordProducer::produce(), llvm::DWARFFormValue::skipValue(), and llvm::xray::RecordInitializer::visit().

◆ getU8() [2/5]

uint8_t llvm::DataExtractor::getU8 ( Cursor C) const
inline

Extract a single uint8_t value from the location given by the cursor.

In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Definition at line 260 of file DataExtractor.h.

References C, llvm::count(), and getU8().

Referenced by getU8().

◆ getU8() [3/5]

uint8_t * DataExtractor::getU8 ( uint64_t *  offset_ptr,
uint8_t *  dst,
uint32_t  count 
) const

Extract count uint8_t values from *offset_ptr.

Extract count uint8_t values from the binary data at the offset pointed to by offset_ptr, and advance the offset on success. The extracted values are copied into dst.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[out]dstA buffer to copy count uint8_t values into. dst must be large enough to hold all requested data.
[in]countThe number of uint8_t values to extract.
Returns
dst if all values were properly extracted and copied, NULL otherise.

Definition at line 77 of file DataExtractor.cpp.

References llvm::count(), and llvm::StringRef::data().

◆ getU8() [4/5]

uint8_t * DataExtractor::getU8 ( Cursor C,
uint8_t *  Dst,
uint32_t  Count 
) const

Extract Count uint8_t values from the location given by the cursor and store them into the destination buffer.

In case of an extraction error, or if the cursor is already in an error state, a nullptr is returned and the destination buffer is left unchanged.

Definition at line 82 of file DataExtractor.cpp.

References llvm::StringRef::data().

◆ getU8() [5/5]

void llvm::DataExtractor::getU8 ( Cursor C,
SmallVectorImpl< uint8_t > &  Dst,
uint32_t  Count 
) const
inline

Extract Count uint8_t values from the location given by the cursor and store them into the destination vector.

The vector is resized to fit the extracted data. In case of an extraction error, or if the cursor is already in an error state, the destination vector is left unchanged and cursor is placed into an error state.

Definition at line 298 of file DataExtractor.h.

References llvm::SmallVectorTemplateCommon< T, typename >::data(), and llvm::SmallVectorImpl< T >::resize().

◆ getULEB128() [1/2]

uint64_t DataExtractor::getULEB128 ( uint64_t *  offset_ptr,
llvm::Error Err = nullptr 
) const

Extract a unsigned LEB128 value from *offset_ptr.

Extracts an unsigned LEB128 number from this object's data starting at the offset pointed to by offset_ptr. The offset pointed to by offset_ptr will be updated with the offset of the byte following the last extracted byte.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[in,out]ErrA pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.
Returns
The extracted unsigned integer value.

Definition at line 174 of file DataExtractor.cpp.

Referenced by llvm::gsym::AddressRange::decode(), decode(), llvm::gsym::AddressRanges::decode(), llvm::DWARFDie::dump(), llvm::DWARFExpression::Operation::extract(), llvm::DWARFAbbreviationDeclaration::extract(), llvm::DWARFDebugInfoEntry::extractFast(), llvm::DWARFFormValue::extractValue(), llvm::DWARFDataExtractor::getEncodedPointer(), llvm::DWARFDebugNames::NameIndex::getEntry(), parse(), llvm::dwarf::CFIProgram::parse(), llvm::DWARFDebugLine::LineTable::parse(), llvm::DWARFDebugFrame::parse(), llvm::DWARFDebugLoclists::parseOneLocationList(), parseV2DirFileTables(), parseV5EntryFormat(), llvm::object::MachOObjectFile::ReadULEB128s(), and llvm::DWARFFormValue::skipValue().

◆ getULEB128() [2/2]

uint64_t llvm::DataExtractor::getULEB128 ( Cursor C) const
inline

Extract an unsigned ULEB128 value from the location given by the cursor.

In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Definition at line 527 of file DataExtractor.h.

References getULEB128(), and llvm::yaml::skip().

Referenced by getULEB128().

◆ getUnsigned() [1/2]

uint64_t DataExtractor::getUnsigned ( uint64_t *  offset_ptr,
uint32_t  byte_size,
llvm::Error Err = nullptr 
) const

Extract an unsigned integer of size byte_size from *offset_ptr.

Extract a single unsigned integer value and update the offset pointed to by offset_ptr. The size of the extracted integer is specified by the byte_size argument. byte_size should have a value greater than or equal to one and less than or equal to eight since the return value is 64 bits wide. Any byte_size values less than 1 or greater than 8 will result in nothing being extracted, and zero being returned.

Parameters
[in,out]offset_ptrA pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
[in]byte_sizeThe size in byte of the integer to extract.
[in,out]ErrA pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.
Returns
The unsigned integer value that was extracted, or zero on failure.

Definition at line 124 of file DataExtractor.cpp.

Referenced by llvm::DWARFDebugArangeSet::extract(), llvm::DWARFDataExtractor::getEncodedPointer(), and llvm::DWARFDebugFrame::parse().

◆ getUnsigned() [2/2]

uint64_t llvm::DataExtractor::getUnsigned ( Cursor C,
uint32_t  Size 
) const
inline

Extract an unsigned integer of the given size from the location given by the cursor.

In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Definition at line 180 of file DataExtractor.h.

References llvm::size().

◆ isLittleEndian()

bool llvm::DataExtractor::isLittleEndian ( ) const
inline

◆ isValidOffset()

bool llvm::DataExtractor::isValidOffset ( uint64_t  offset) const
inline

◆ isValidOffsetForAddress()

bool llvm::DataExtractor::isValidOffsetForAddress ( uint64_t  offset) const
inline

Test the availability of enough bytes of data for a pointer from offset.

The size of a pointer is getAddressSize().

Returns
true if offset is a valid offset and there are enough bytes for a pointer available at that offset, false otherwise.

Definition at line 562 of file DataExtractor.h.

Referenced by llvm::symbolize::SymbolizableObjectFile::create().

◆ isValidOffsetForDataOfSize()

bool llvm::DataExtractor::isValidOffsetForDataOfSize ( uint64_t  offset,
uint64_t  length 
) const
inline

◆ setAddressSize()

void llvm::DataExtractor::setAddressSize ( uint8_t  Size)
inline

Set the address size for this extractor.

Definition at line 98 of file DataExtractor.h.

References Size.

Referenced by llvm::DWARFListTableBase< DWARFDebugRnglist >::extract(), llvm::DWARFDebugLine::LineTable::parse(), and llvm::DWARFDebugFrame::parse().

◆ skip()

void DataExtractor::skip ( Cursor C,
uint64_t  Length 
) const

Advance the Cursor position by the given number of bytes.

No-op if the cursor is in an error state.

Definition at line 209 of file DataExtractor.cpp.

References isError(), isValidOffsetForDataOfSize(), and unexpectedEndReached().


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