|
LLVM 23.0.0git
|
A DataExtractor suitable use for parsing dwarf from memory. More...
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h"
Public Member Functions | |
| DWARFDataExtractorBase (StringRef Data, bool IsLittleEndian, unsigned AddressSize) | |
| DWARFDataExtractorBase (ArrayRef< uint8_t > Data, bool IsLittleEndian, unsigned AddressSize) | |
| DWARFDataExtractorBase (const DWARFDataExtractorBase &Other, size_t Length) | |
| Truncating constructor. | |
| unsigned | getAddressSize () const |
| Get the address size for this extractor. | |
| void | setAddressSize (unsigned Size) |
| Set the address size for this extractor. | |
| uint64_t | getAddress (uint64_t *OffsetPtr) const |
| Extract an address from *OffsetPtr. | |
| uint64_t | getAddress (Cursor &C) const |
| Extract an address-sized unsigned integer from the location given by the cursor. | |
| bool | isValidOffsetForAddress (uint64_t Offset) const |
| Test the availability of enough bytes of data for an address from Offset. | |
| uint64_t | getRelocatedValue (uint32_t Size, uint64_t *Off, uint64_t *SectionIndex=nullptr, Error *Err=nullptr) const |
| Extracts a value and returns it as adjusted by the Relocator. | |
| uint64_t | getRelocatedValue (Cursor &C, uint32_t Size, uint64_t *SectionIndex=nullptr) const |
| uint64_t | getRelocatedAddress (uint64_t *Off, uint64_t *SecIx=nullptr) const |
| Extracts an address-sized value. | |
| uint64_t | getRelocatedAddress (Cursor &C, uint64_t *SecIx=nullptr) const |
| std::pair< uint64_t, dwarf::DwarfFormat > | getInitialLength (uint64_t *Off, Error *Err=nullptr) const |
| Extracts the DWARF "initial length" field, which can either be a 32-bit value smaller than 0xfffffff0, or the value 0xffffffff followed by a 64-bit length. | |
| std::pair< uint64_t, dwarf::DwarfFormat > | getInitialLength (Cursor &C) const |
| std::optional< uint64_t > | getEncodedPointer (uint64_t *Offset, uint8_t Encoding, uint64_t PCRelOffset) const |
Extracts a DWARF-encoded pointer in Offset using Encoding. | |
| Public Member Functions inherited from llvm::DataExtractor | |
| DataExtractor (StringRef Data, bool IsLittleEndian) | |
| Construct with a buffer that is owned by the caller. | |
| DataExtractor (ArrayRef< uint8_t > Data, bool IsLittleEndian) | |
| DataExtractor (StringRef Data, bool IsLittleEndian, uint8_t) | |
| DataExtractor (ArrayRef< uint8_t > Data, bool IsLittleEndian, uint8_t) | |
| StringRef | getData () const |
| Get the data pointed to by this extractor. | |
| bool | isLittleEndian () const |
| Get the endianness 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI StringRef | getFixedLengthString (uint64_t *OffsetPtr, uint64_t Length, StringRef TrimChars={"\0", 1}) const |
| Extract a fixed length string from *OffsetPtr and consume Length bytes. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI int64_t | getSigned (uint64_t *offset_ptr, uint32_t size) const |
| Extract an signed integer of size byte_size from *offset_ptr. | |
| LLVM_ABI 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. | |
| LLVM_ABI uint8_t * | getU8 (uint64_t *offset_ptr, uint8_t *dst, uint32_t count) const |
| Extract count uint8_t values from *offset_ptr. | |
| LLVM_ABI 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. | |
| int8_t | getS8 (uint64_t *OffsetPtr, Error *Err=nullptr) const |
| Extract a int8_t value from *OffsetPtr. | |
| int8_t | getS8 (Cursor &C) const |
| Extract a int8_t value from *OffsetPtr. | |
| LLVM_ABI 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. | |
| LLVM_ABI uint16_t * | getU16 (uint64_t *offset_ptr, uint16_t *dst, uint32_t count) const |
| Extract count uint16_t values from *offset_ptr. | |
| int16_t | getS16 (uint64_t *OffsetPtr, Error *Err=nullptr) const |
| Extract a int16_t value from *OffsetPtr. | |
| int16_t | getS16 (Cursor &C) const |
| Extract a int16_t value from *OffsetPtr. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI uint32_t * | getU32 (uint64_t *offset_ptr, uint32_t *dst, uint32_t count) const |
| Extract count uint32_t values from *offset_ptr. | |
| int32_t | getS32 (uint64_t *OffsetPtr, Error *Err=nullptr) const |
| Extract a int32_t value from *OffsetPtr. | |
| int32_t | getS32 (Cursor &C) const |
| Extract a int32_t value from *OffsetPtr. | |
| LLVM_ABI 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. | |
| LLVM_ABI uint64_t * | getU64 (uint64_t *offset_ptr, uint64_t *dst, uint32_t count) const |
| Extract count uint64_t values from *offset_ptr. | |
| int64_t | getS64 (uint64_t *OffsetPtr, Error *Err=nullptr) const |
| Extract a int64_t value from *OffsetPtr. | |
| int64_t | getS64 (Cursor &C) const |
| Extract a int64_t value from *OffsetPtr. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| size_t | size () const |
| Return the number of bytes in the underlying buffer. | |
Additional Inherited Members | |
| Static Protected Member Functions inherited from llvm::DataExtractor | |
| static uint64_t & | getOffset (Cursor &C) |
| static Error & | getError (Cursor &C) |
A DataExtractor suitable use for parsing dwarf from memory.
Clients use Relocator::getRelocatedValueImpl to relocate values as appropriate.
Definition at line 24 of file DWARFDataExtractorSimple.h.
|
inline |
Definition at line 28 of file DWARFDataExtractorSimple.h.
References llvm::DataExtractor::DataExtractor().
Referenced by DWARFDataExtractorBase().
|
inline |
Definition at line 32 of file DWARFDataExtractorSimple.h.
References const, data, llvm::DataExtractor::DataExtractor(), and llvm::DataExtractor::size().
|
inline |
Truncating constructor.
Definition at line 40 of file DWARFDataExtractorSimple.h.
References llvm::DataExtractor::DataExtractor(), DWARFDataExtractorBase(), getAddressSize(), llvm::DataExtractor::getData(), llvm::DataExtractor::isLittleEndian(), llvm::Length, llvm::Other, and substr().
|
inline |
Extract an address-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 74 of file DWARFDataExtractorSimple.h.
References llvm::CallingConv::C, and llvm::DataExtractor::getUnsigned().
|
inline |
Extract an address from *OffsetPtr.
Extract a single address from the data and update the offset pointed to by OffsetPtr. The size of the extracted address is getAddressSize(), so the address size has to be set correctly prior to extracting any address values.
| [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. |
Definition at line 67 of file DWARFDataExtractorSimple.h.
References llvm::DataExtractor::getUnsigned().
|
inline |
Get the address size for this extractor.
Definition at line 45 of file DWARFDataExtractorSimple.h.
Referenced by DWARFDataExtractorBase(), getEncodedPointer(), getRelocatedAddress(), getRelocatedAddress(), llvm::DWARFDebugLine::LineTable::parse(), and llvm::DWARFDebugLine::Prologue::parse().
|
inline |
Extracts a DWARF-encoded pointer in Offset using Encoding.
There is a DWARF encoding that uses a PC-relative adjustment. For these values, AbsPosOffset is used to fix them, which should reflect the absolute address of this pointer.
Definition at line 155 of file DWARFDataExtractorSimple.h.
References llvm::dwarf::DW_EH_PE_absptr, llvm::dwarf::DW_EH_PE_aligned, llvm::dwarf::DW_EH_PE_datarel, llvm::dwarf::DW_EH_PE_funcrel, llvm::dwarf::DW_EH_PE_omit, llvm::dwarf::DW_EH_PE_pcrel, llvm::dwarf::DW_EH_PE_sdata2, llvm::dwarf::DW_EH_PE_sdata4, llvm::dwarf::DW_EH_PE_sdata8, llvm::dwarf::DW_EH_PE_sleb128, llvm::dwarf::DW_EH_PE_textrel, llvm::dwarf::DW_EH_PE_udata2, llvm::dwarf::DW_EH_PE_udata4, llvm::dwarf::DW_EH_PE_udata8, llvm::dwarf::DW_EH_PE_uleb128, getAddressSize(), getRelocatedValue(), llvm::DataExtractor::getSigned(), llvm::DataExtractor::getSLEB128(), llvm::DataExtractor::getULEB128(), llvm::DataExtractor::getUnsigned(), llvm::Offset, and llvm::SignExtend64().
|
inline |
Definition at line 147 of file DWARFDataExtractorSimple.h.
References llvm::CallingConv::C, llvm::DataExtractor::getError(), getInitialLength(), and llvm::DataExtractor::getOffset().
|
inline |
Extracts the DWARF "initial length" field, which can either be a 32-bit value smaller than 0xfffffff0, or the value 0xffffffff followed by a 64-bit length.
Returns the actual length, and the DWARF format which is encoded in the field. In case of errors, it returns {0, DWARF32} and leaves the offset unchanged.
Definition at line 116 of file DWARFDataExtractorSimple.h.
References llvm::CallingConv::C, llvm::cantFail(), llvm::consumeError(), llvm::createStringError(), llvm::dwarf::DW_LENGTH_DWARF64, llvm::dwarf::DW_LENGTH_lo_reserved, llvm::dwarf::DWARF32, llvm::dwarf::DWARF64, llvm::Format, getRelocatedValue(), and llvm::Length.
Referenced by llvm::DWARFDebugNames::Header::extract(), llvm::DWARFUnitHeader::extract(), getInitialLength(), llvm::DWARFVerifier::handleDebugStrOffsets(), llvm::DWARFDebugLine::Prologue::parse(), and llvm::parseInfoSectionUnitHeader().
|
inline |
Definition at line 105 of file DWARFDataExtractorSimple.h.
References llvm::CallingConv::C, getAddressSize(), llvm::DataExtractor::getError(), llvm::DataExtractor::getOffset(), and getRelocatedValue().
|
inline |
Extracts an address-sized value.
Definition at line 101 of file DWARFDataExtractorSimple.h.
References getAddressSize(), and getRelocatedValue().
Referenced by llvm::DWARFDebugLine::LineTable::parse().
|
inline |
Definition at line 95 of file DWARFDataExtractorSimple.h.
References llvm::CallingConv::C, llvm::DataExtractor::getError(), llvm::DataExtractor::getOffset(), getRelocatedValue(), and Size.
|
inline |
Extracts a value and returns it as adjusted by the Relocator.
Definition at line 88 of file DWARFDataExtractorSimple.h.
References Size.
Referenced by dumpStringOffsetsSection(), llvm::DWARFDebugPubTable::extract(), llvm::DWARFUnitHeader::extract(), getEncodedPointer(), getInitialLength(), getRelocatedAddress(), getRelocatedAddress(), getRelocatedValue(), llvm::DWARFDebugLine::LineTable::parse(), and llvm::DWARFDebugLine::Prologue::parse().
|
inline |
Test the availability of enough bytes of data for an address from Offset.
The size of an address is getAddressSize().
Definition at line 83 of file DWARFDataExtractorSimple.h.
References llvm::DataExtractor::isValidOffsetForDataOfSize(), and llvm::Offset.
|
inline |
Set the address size for this extractor.
Definition at line 48 of file DWARFDataExtractorSimple.h.
References Size.
Referenced by llvm::DWARFDebugLine::LineTable::parse().