LLVM 20.0.0git
|
#include "llvm/Support/DataExtractor.h"
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. | |
DataExtractor (ArrayRef< uint8_t > Data, bool IsLittleEndian, uint8_t AddressSize) | |
StringRef | getData () const |
Get the data pointed to by this extractor. | |
bool | isLittleEndian () const |
Get the endianness for this extractor. | |
uint8_t | getAddressSize () const |
Get the address size for this extractor. | |
void | setAddressSize (uint8_t Size) |
Set the address size for this extractor. | |
const char * | getCStr (uint64_t *OffsetPtr, Error *Err=nullptr) const |
Extract a C string from *offset_ptr. | |
const char * | getCStr (Cursor &C) const |
Extract a C string from the location given by the cursor. | |
StringRef | getCStrRef (uint64_t *OffsetPtr, Error *Err=nullptr) const |
Extract a C string from *offset_ptr. | |
StringRef | getCStrRef (Cursor &C) const |
Extract a C string (as a StringRef) from the location given by the cursor. | |
StringRef | getFixedLengthString (uint64_t *OffsetPtr, uint64_t Length, StringRef TrimChars={"\0", 1}) const |
Extract a fixed length string from *OffsetPtr and consume Length bytes. | |
StringRef | getBytes (uint64_t *OffsetPtr, uint64_t Length, Error *Err=nullptr) const |
Extract a fixed number of bytes from the specified offset. | |
StringRef | getBytes (Cursor &C, uint64_t Length) |
Extract a fixed number of bytes from the location given by the cursor. | |
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. | |
uint64_t | getUnsigned (Cursor &C, uint32_t Size) const |
Extract an unsigned integer of the given size from the location given by the cursor. | |
int64_t | getSigned (uint64_t *offset_ptr, uint32_t size) const |
Extract an signed integer of size byte_size from *offset_ptr. | |
uint64_t | getAddress (uint64_t *offset_ptr) const |
Extract an pointer from *offset_ptr. | |
uint64_t | getAddress (Cursor &C) const |
Extract a pointer-sized unsigned integer from the location given by the cursor. | |
uint8_t | getU8 (uint64_t *offset_ptr, Error *Err=nullptr) const |
Extract a uint8_t value from *offset_ptr. | |
uint8_t | getU8 (Cursor &C) const |
Extract a single uint8_t value from the location given by the cursor. | |
uint8_t * | getU8 (uint64_t *offset_ptr, uint8_t *dst, uint32_t count) const |
Extract count uint8_t values from *offset_ptr. | |
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. | |
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. | |
uint16_t | getU16 (uint64_t *offset_ptr, Error *Err=nullptr) const |
Extract a uint16_t value from *offset_ptr. | |
uint16_t | getU16 (Cursor &C) const |
Extract a single uint16_t value from the location given by the cursor. | |
uint16_t * | getU16 (uint64_t *offset_ptr, uint16_t *dst, uint32_t count) const |
Extract count uint16_t values from *offset_ptr. | |
uint32_t | getU24 (uint64_t *OffsetPtr, Error *Err=nullptr) const |
Extract a 24-bit unsigned value from *offset_ptr and return it in a uint32_t. | |
uint32_t | getU24 (Cursor &C) const |
Extract a single 24-bit unsigned value from the location given by the cursor. | |
uint32_t | getU32 (uint64_t *offset_ptr, Error *Err=nullptr) const |
Extract a uint32_t value from *offset_ptr. | |
uint32_t | getU32 (Cursor &C) const |
Extract a single uint32_t value from the location given by the cursor. | |
uint32_t * | getU32 (uint64_t *offset_ptr, uint32_t *dst, uint32_t count) const |
Extract count uint32_t values from *offset_ptr. | |
uint64_t | getU64 (uint64_t *offset_ptr, Error *Err=nullptr) const |
Extract a uint64_t value from *offset_ptr. | |
uint64_t | getU64 (Cursor &C) const |
Extract a single uint64_t value from the location given by the cursor. | |
uint64_t * | getU64 (uint64_t *offset_ptr, uint64_t *dst, uint32_t count) const |
Extract count uint64_t values from *offset_ptr. | |
int64_t | getSLEB128 (uint64_t *OffsetPtr, Error *Err=nullptr) const |
Extract a signed LEB128 value from *offset_ptr. | |
int64_t | getSLEB128 (Cursor &C) const |
Extract an signed LEB128 value from the location given by the cursor. | |
uint64_t | getULEB128 (uint64_t *offset_ptr, llvm::Error *Err=nullptr) const |
Extract a unsigned LEB128 value from *offset_ptr. | |
uint64_t | getULEB128 (Cursor &C) const |
Extract an unsigned LEB128 value from the location given by the cursor. | |
void | skip (Cursor &C, uint64_t Length) const |
Advance the Cursor position by the given number of bytes. | |
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. | |
bool | isValidOffset (uint64_t offset) const |
Test the validity of offset. | |
bool | isValidOffsetForDataOfSize (uint64_t offset, uint64_t length) const |
Test the availability of length bytes of data from offset. | |
bool | isValidOffsetForAddress (uint64_t offset) const |
Test the availability of enough bytes of data for a pointer from offset. | |
size_t | size () const |
Return the number of bytes in the underlying buffer. | |
Static Protected Member Functions | |
static uint64_t & | getOffset (Cursor &C) |
static Error & | getError (Cursor &C) |
Definition at line 41 of file DataExtractor.h.
|
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 86 of file DataExtractor.h.
|
inline |
Definition at line 88 of file DataExtractor.h.
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 658 of file DataExtractor.h.
References llvm::CallingConv::C, and size().
Referenced by llvm::ELFAttributeParser::parse().
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 332 of file DataExtractor.h.
References llvm::CallingConv::C, and getUnsigned().
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.
[in,out] | offset_ptr | A 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. |
Definition at line 325 of file DataExtractor.h.
References getUnsigned().
|
inline |
Get the address size for this extractor.
Definition at line 99 of file DataExtractor.h.
Referenced by llvm::DWARFLocationTable::dumpLocationList(), llvm::DWARFDebugLoc::dumpRawEntry(), llvm::DWARFDebugLoclists::dumpRawEntry(), llvm::DWARFDebugRangeList::extract(), llvm::DWARFDataExtractor::getEncodedPointer(), llvm::DWARFDataExtractor::getRelocatedAddress(), llvm::DWARFDebugLine::LineTable::parse(), llvm::DWARFDebugLine::Prologue::parse(), and llvm::DWARFDebugLoc::visitLocationList().
Extract a fixed number of bytes from the location given by the cursor.
In case of an extraction error, or if the cursor is already in an error state, a default-initialized StringRef is returned.
Definition at line 239 of file DataExtractor.h.
References llvm::CallingConv::C, getBytes(), and llvm::Length.
StringRef DataExtractor::getBytes | ( | uint64_t * | OffsetPtr, |
uint64_t | Length, | ||
Error * | Err = nullptr |
||
) | const |
Extract a fixed number of bytes from the specified offset.
Returns a StringRef for the bytes from the data at the offset pointed to by OffsetPtr. A fixed length C string will be extracted and the OffsetPtr will be advanced by Length bytes.
[in,out] | OffsetPtr | A 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] | Length | The number of bytes to extract. If there are not enough bytes in the data to extract all of the bytes, the offset will be left unmodified. |
[in,out] | Err | A 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. |
Definition at line 181 of file DataExtractor.cpp.
References isError(), llvm::Length, and llvm::StringRef::substr().
Referenced by llvm::AMDGPUDisassembler::decodeKernelDescriptorDirective(), getBytes(), getFixedLengthString(), llvm::GCOVBuffer::getString(), getUUID(), llvm::GCOVBuffer::readGCOVVersion(), and llvm::GCOVBuffer::readString().
Extract a C string from the location given by the cursor.
In case of an extraction error, or if the cursor is already in an error state, a nullptr is returned.
Definition at line 136 of file DataExtractor.h.
References llvm::CallingConv::C, llvm::StringRef::data(), and getCStrRef().
|
inline |
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.
[in,out] | OffsetPtr | A 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] | Err | A 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. |
Definition at line 129 of file DataExtractor.h.
References llvm::StringRef::data(), and getCStrRef().
Referenced by llvm::DWARFContext::dump(), dumpStringOffsetsSection(), llvm::DWARFFormValue::getAsCString(), getIndexedString(), llvm::DWARFDebugNames::NameTableEntry::getString(), llvm::DWARFDebugLine::LineTable::parse(), and llvm::DWARFFormValue::skipValue().
Extract a C string (as a StringRef) from the location given by the cursor.
In case of an extraction error, or if the cursor is already in an error state, a default-initialized StringRef is returned.
Definition at line 169 of file DataExtractor.h.
References llvm::CallingConv::C, and getCStrRef().
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.
[in,out] | OffsetPtr | A 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] | Err | A 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. |
Definition at line 156 of file DataExtractor.cpp.
References llvm::createStringError(), llvm::StringRef::data(), llvm::StringRef::find(), llvm::illegal_byte_sequence, isError(), and llvm::StringRef::npos.
Referenced by llvm::DWARFDebugPubTable::extract(), getCStr(), getCStrRef(), llvm::ELFAttributeParser::parseSubsection(), parseV2DirFileTables(), and llvm::ELFAttributeParser::stringAttribute().
|
inline |
Get the data pointed to by this extractor.
Definition at line 95 of file DataExtractor.h.
Referenced by llvm::DWARFExpression::end(), llvm::DWARFExpression::getData(), llvm::xray::loadTrace(), llvm::DWARFExpression::iterator::operator++(), llvm::xray::readBinaryFormatHeader(), and llvm::DWARFDebugNames::NameTableEntry::sameNameAs().
Definition at line 694 of file DataExtractor.h.
References llvm::CallingConv::C.
Referenced by llvm::DWARFDataExtractor::getInitialLength(), llvm::DWARFDataExtractor::getRelocatedAddress(), and llvm::DWARFDataExtractor::getRelocatedValue().
StringRef DataExtractor::getFixedLengthString | ( | uint64_t * | OffsetPtr, |
uint64_t | Length, | ||
StringRef | TrimChars = {"\0", 1} |
||
) | const |
Extract a fixed length string from *OffsetPtr and consume Length bytes.
Returns a StringRef for the string from the data at the offset pointed to by OffsetPtr. A fixed length C string will be extracted and the OffsetPtr will be advanced by Length bytes.
[in,out] | OffsetPtr | A 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] | Length | The length of the fixed length string to extract. If there are not enough bytes in the data to extract the full string, the offset will be left unmodified. |
[in] | TrimChars | A set of characters to trim from the end of the string. Fixed length strings are commonly either NULL terminated by one or more zero bytes. Some clients have one or more spaces at the end of the string, but a good default is to trim the NULL characters. |
Definition at line 174 of file DataExtractor.cpp.
References getBytes(), llvm::Length, and llvm::StringRef::trim().
Referenced by getUUID().
Definition at line 693 of file DataExtractor.h.
References llvm::CallingConv::C.
Referenced by llvm::DWARFDataExtractor::getInitialLength(), llvm::DWARFDataExtractor::getRelocatedAddress(), and llvm::DWARFDataExtractor::getRelocatedValue().
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.
[in,out] | offset_ptr | A 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] | size | The size in bytes of the integer to extract. |
Definition at line 142 of file DataExtractor.cpp.
References getU16(), getU32(), getU64(), getU8(), and llvm_unreachable.
Referenced by llvm::DWARFDataExtractor::getEncodedPointer(), and llvm::xray::RecordInitializer::visit().
|
inline |
Extract an signed LEB128 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 619 of file DataExtractor.h.
References llvm::CallingConv::C, and getSLEB128().
Referenced by getSLEB128().
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.
[in,out] | OffsetPtr | A 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] | Err | A 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. |
Definition at line 225 of file DataExtractor.cpp.
References llvm::decodeSLEB128(), and getLEB128().
Referenced by llvm::DWARFDataExtractor::getEncodedPointer(), llvm::DWARFDebugLine::LineTable::parse(), and llvm::DWARFFormValue::skipValue().
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 433 of file DataExtractor.h.
References llvm::CallingConv::C, and getU16().
Referenced by getU16().
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.
[in,out] | offset_ptr | A 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] | Err | A 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. |
Definition at line 93 of file DataExtractor.cpp.
Referenced by llvm::AMDGPUDisassembler::decodeKernelDescriptorDirective(), llvm::AppleAcceleratorTable::extract(), llvm::DWARFDebugNames::Header::extract(), llvm::DWARFUnitHeader::extract(), llvm::DWARFDebugPubTable::extract(), llvm::DWARFDebugArangeSet::extract(), getIndexedString(), getSigned(), getUnsigned(), llvm::DWARFVerifier::handleDebugStrOffsets(), llvm::xray::loadTrace(), llvm::DWARFDebugLine::Prologue::parse(), llvm::parseInfoSectionUnitHeader(), processConstantStringArg(), llvm::xray::readBinaryFormatHeader(), llvm::DWARFFormValue::skipValue(), llvm::xray::RecordInitializer::visit(), llvm::DWARFDebugLoc::visitLocationList(), and llvm::DWARFDebugLoclists::visitLocationList().
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.
[in,out] | offset_ptr | A 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] | dst | A buffer to copy count uint16_t values into. dst must be large enough to hold all requested data. |
[in] | count | The number of uint16_t values to extract. |
Definition at line 97 of file DataExtractor.cpp.
References llvm::count().
Extract a single 24-bit unsigned 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 486 of file DataExtractor.h.
References llvm::CallingConv::C, and getU24().
Referenced by getU24().
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.
[in,out] | OffsetPtr | A 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. |
[in,out] | Err | A 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. |
Definition at line 102 of file DataExtractor.cpp.
References llvm::Uint24::getAsUint32(), and llvm::sys::IsLittleEndianHost.
Referenced by getIndexedString(), and processConstantStringArg().
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 513 of file DataExtractor.h.
References llvm::CallingConv::C, and getU32().
Referenced by getU32().
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.
[in,out] | offset_ptr | A 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] | Err | A 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. |
Definition at line 108 of file DataExtractor.cpp.
Referenced by debugStrOffsetsHeaderSize(), llvm::AMDGPUDisassembler::decodeKernelDescriptorDirective(), llvm::AppleAcceleratorTable::dump(), llvm::AppleAcceleratorTable::extract(), llvm::DWARFDebugNames::Header::extract(), getIndexedString(), getSigned(), getUnsigned(), getUUID(), llvm::GCOVBuffer::getWord(), loadObj(), llvm::ELFAttributeParser::parse(), llvm::parseInfoSectionUnitHeader(), llvm::ELFAttributeParser::parseSubsection(), processConstantStringArg(), llvm::xray::readBinaryFormatHeader(), llvm::GCOVBuffer::readInt(), llvm::DWARFFormValue::skipValue(), llvm::xray::RecordInitializer::visit(), and llvm::DWARFDebugLoclists::visitLocationList().
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.
[in,out] | offset_ptr | A 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] | dst | A buffer to copy count uint32_t values into. dst must be large enough to hold all requested data. |
[in] | count | The number of uint32_t values to extract. |
Definition at line 112 of file DataExtractor.cpp.
References llvm::count().
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 565 of file DataExtractor.h.
References llvm::CallingConv::C, and getU64().
Referenced by getU64().
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.
[in,out] | offset_ptr | A 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] | Err | A 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. |
Definition at line 117 of file DataExtractor.cpp.
Referenced by llvm::DWARFUnitHeader::extract(), getCUIdentifiers(), getSigned(), getUnsigned(), loadObj(), llvm::parseInfoSectionUnitHeader(), llvm::xray::readBinaryFormatHeader(), and llvm::xray::RecordInitializer::visit().
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.
[in,out] | offset_ptr | A 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] | dst | A buffer to copy count uint64_t values into. dst must be large enough to hold all requested data. |
[in] | count | The number of uint64_t values to extract. |
Definition at line 121 of file DataExtractor.cpp.
References llvm::count().
|
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 359 of file DataExtractor.h.
References llvm::CallingConv::C, and getU8().
Referenced by getU8().
|
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 397 of file DataExtractor.h.
References llvm::CallingConv::C, getU8(), and isValidOffsetForDataOfSize().
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 89 of file DataExtractor.cpp.
References llvm::CallingConv::C.
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.
[in,out] | offset_ptr | A 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] | Err | A 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. |
Definition at line 80 of file DataExtractor.cpp.
Referenced by llvm::DWARFDebugNames::Header::extract(), llvm::DWARFUnitHeader::extract(), llvm::DWARFDebugPubTable::extract(), llvm::DWARFDebugArangeSet::extract(), getCUAbbrev(), getCUIdentifiers(), getIndexedString(), getSigned(), getU8(), getUnsigned(), loadObj(), llvm::ELFAttributeParser::parse(), llvm::DWARFDebugLine::LineTable::parse(), llvm::DWARFDebugLine::Prologue::parse(), llvm::parseInfoSectionUnitHeader(), llvm::ELFAttributeParser::parseSubsection(), parseV5EntryFormat(), llvm::DWARFExpression::Operation::print(), processConstantStringArg(), llvm::xray::FileBasedRecordProducer::produce(), llvm::DWARFFormValue::skipValue(), llvm::xray::RecordInitializer::visit(), llvm::DWARFDebugLoc::visitLocationList(), and llvm::DWARFDebugLoclists::visitLocationList().
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.
[in,out] | offset_ptr | A 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] | dst | A buffer to copy count uint8_t values into. dst must be large enough to hold all requested data. |
[in] | count | The number of uint8_t values to extract. |
Definition at line 84 of file DataExtractor.cpp.
References llvm::count().
Extract an unsigned LEB128 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 648 of file DataExtractor.h.
References llvm::CallingConv::C, and getULEB128().
Referenced by getULEB128().
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.
[in,out] | offset_ptr | A 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] | Err | A 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. |
Definition at line 221 of file DataExtractor.cpp.
References llvm::decodeULEB128(), and getLEB128().
Referenced by llvm::DWARFDie::dump(), llvm::DWARFDebugInfoEntry::extractFast(), getCUAbbrev(), getCUIdentifiers(), llvm::DWARFDataExtractor::getEncodedPointer(), llvm::DWARFDebugNames::NameIndex::getEntry(), getIndexedString(), llvm::ELFAttributeParser::integerAttribute(), llvm::DWARFDebugLine::LineTable::parse(), llvm::ELFAttributeParser::parseAttributeList(), llvm::ELFAttributeParser::parseIndexList(), llvm::ELFAttributeParser::parseStringAttribute(), parseV2DirFileTables(), parseV5DirFileTables(), parseV5EntryFormat(), llvm::object::MachOObjectFile::ReadULEB128s(), llvm::DWARFFormValue::skipValue(), and llvm::DWARFDebugLoclists::visitLocationList().
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 279 of file DataExtractor.h.
References llvm::CallingConv::C, getUnsigned(), and Size.
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.
[in,out] | offset_ptr | A 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_size | The size in byte of the integer to extract. |
[in,out] | Err | A 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. |
Definition at line 126 of file DataExtractor.cpp.
References getU16(), getU32(), getU64(), getU8(), and llvm_unreachable.
Referenced by llvm::DWARFUnitHeader::extract(), llvm::DWARFDebugPubTable::extract(), llvm::DWARFDebugArangeSet::extract(), getAddress(), llvm::DWARFDataExtractor::getEncodedPointer(), llvm::DWARFDataExtractor::getRelocatedValue(), and getUnsigned().
|
inline |
Get the endianness for this extractor.
Definition at line 97 of file DataExtractor.h.
Referenced by llvm::xray::loadTrace(), and llvm::GCOVBuffer::readGCOVVersion().
Test the validity of offset.
Definition at line 665 of file DataExtractor.h.
References size().
Referenced by llvm::AppleAcceleratorTable::dump(), llvm::DWARFDebugLoc::dump(), llvm::DWARFContext::dump(), llvm::DWARFDie::dump(), dumpAddrSection(), dumpRnglistsSection(), llvm::AppleAcceleratorTable::extract(), llvm::DWARFDebugNames::extract(), llvm::DWARFDebugRangeList::extract(), llvm::DWARFUnitHeader::extract(), llvm::DWARFDebugArangeSet::extract(), llvm::DWARFDebugInfoEntry::extractFast(), llvm::DWARFDebugNames::NameIndex::getEntry(), llvm::DWARFDebugLine::getOrParseLineTable(), isValidOffsetForDataOfSize(), llvm::parseInfoSectionUnitHeader(), llvm::DWARFDebugLine::SectionParser::parseNext(), llvm::DWARFDebugLine::SectionParser::SectionParser(), and llvm::DWARFDebugLine::SectionParser::skip().
Test the availability of enough bytes of data for a pointer from offset.
The size of a pointer is getAddressSize().
Definition at line 683 of file DataExtractor.h.
References isValidOffsetForDataOfSize().
|
inline |
Test the availability of length bytes of data from offset.
Definition at line 672 of file DataExtractor.h.
References isValidOffset().
Referenced by llvm::DWARFDebugLoclists::dumpRange(), llvm::DWARFDebugNames::NameIndex::extract(), llvm::DWARFDebugNames::Header::extract(), llvm::DWARFDebugArangeSet::extract(), getU8(), isValidOffsetForAddress(), llvm::DWARFDebugLine::LineTable::parse(), and llvm::xray::RecordInitializer::visit().
|
inline |
Set the address size for this extractor.
Definition at line 101 of file DataExtractor.h.
References Size.
Referenced by llvm::DWARFDebugLine::LineTable::parse().
|
inline |
Return the number of bytes in the underlying buffer.
Definition at line 688 of file DataExtractor.h.
Referenced by eof(), llvm::AppleAcceleratorTable::equal_range(), llvm::DWARFUnitHeader::extract(), isValidOffset(), llvm::DWARFDebugLine::LineTable::parse(), llvm::parseInfoSectionUnitHeader(), and llvm::GCOVBuffer::readInt().
Advance the Cursor position by the given number of bytes.
No-op if the cursor is in an error state.
Definition at line 229 of file DataExtractor.cpp.
References llvm::CallingConv::C, isError(), and llvm::Length.
Referenced by llvm::AMDGPUDisassembler::decodeKernelDescriptorDirective(), llvm::DWARFDebugNames::Header::extract(), llvm::DWARFDebugLine::LineTable::parse(), llvm::GCOVFile::readGCDA(), and llvm::GCOVFile::readGCNO().