|
LLDB mainline
|
A DataExtractor subclass that allows reading data at virtual addresses using a lookup table that maps virtual address ranges to physical offsets. More...
#include <VirtualDataExtractor.h>
Public Types | |
| using | LookupTable |
| Type alias for the range map used internally. | |
| Public Types inherited from lldb_private::DataExtractor | |
| enum | Type { TypeUInt8 , TypeChar , TypeUInt16 , TypeUInt32 , TypeUInt64 , TypePointer , TypeULEB128 , TypeSLEB128 } |
| Type enumerations used in the dump routines. More... | |
Public Member Functions | |
| VirtualDataExtractor ()=default | |
| VirtualDataExtractor (const void *data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size, LookupTable lookup_table) | |
| VirtualDataExtractor (const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, LookupTable lookup_table) | |
| const void * | GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const override |
| Extract length bytes from *offset_ptr. | |
| const uint8_t * | PeekData (lldb::offset_t offset, lldb::offset_t length) const override |
| Peek at a bytes at offset. | |
| uint8_t | GetU8_unchecked (lldb::offset_t *offset_ptr) const override |
| Unchecked overrides. | |
| uint16_t | GetU16_unchecked (lldb::offset_t *offset_ptr) const override |
| uint32_t | GetU32_unchecked (lldb::offset_t *offset_ptr) const override |
| uint64_t | GetU64_unchecked (lldb::offset_t *offset_ptr) const override |
| Public Member Functions inherited from lldb_private::DataExtractor | |
| DataExtractor () | |
| Default constructor. | |
| DataExtractor (const void *data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size=1) | |
| Construct with a buffer that is owned by the caller. | |
| DataExtractor (const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size=1) | |
| Construct with shared data. | |
| DataExtractor (const DataExtractor &data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size=1) | |
| Construct with a subset of data. | |
| DataExtractor (const DataExtractor &rhs) | |
| Copy constructor. | |
| const DataExtractor & | operator= (const DataExtractor &rhs) |
| Assignment operator. | |
| DataExtractor (DataExtractor &&rhs)=default | |
| Move constructor and move assignment operators to complete the rule of 5. | |
| DataExtractor & | operator= (DataExtractor &&rhs)=default |
| virtual | ~DataExtractor () |
| Destructor. | |
| uint32_t | getTargetByteSize () const |
| void | Clear () |
| Clears the object state. | |
| lldb::offset_t | PutToLog (Log *log, lldb::offset_t offset, lldb::offset_t length, uint64_t base_addr, uint32_t num_per_line, Type type) const |
| Dumps the binary data as type objects to stream s (or to Log() if s is nullptr) starting offset bytes into the data and stopping after dumping length bytes. | |
| size_t | ExtractBytes (lldb::offset_t offset, lldb::offset_t length, lldb::ByteOrder dst_byte_order, void *dst) const |
| Extract an arbitrary number of bytes in the specified byte order. | |
| uint64_t | GetAddress (lldb::offset_t *offset_ptr) const |
| Extract an address from *offset_ptr. | |
| uint64_t | GetAddress_unchecked (lldb::offset_t *offset_ptr) const |
| uint32_t | GetAddressByteSize () const |
| Get the current address size. | |
| uint64_t | GetByteSize () const |
| Get the number of bytes contained in this object. | |
| const char * | GetCStr (lldb::offset_t *offset_ptr) const |
| Extract a C string from *offset_ptr. | |
| const char * | GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const |
| Extract a C string from *offset_ptr with field size len. | |
| lldb::offset_t | CopyData (lldb::offset_t offset, lldb::offset_t length, void *dst) const |
| Copy length bytes from *offset, without swapping bytes. | |
| lldb::offset_t | CopyByteOrderedData (lldb::offset_t src_offset, lldb::offset_t src_len, void *dst, lldb::offset_t dst_len, lldb::ByteOrder dst_byte_order) const |
| Copy dst_len bytes from *offset_ptr and ensure the copied data is treated as a value that can be swapped to match the specified byte order. | |
| const uint8_t * | GetDataEnd () const |
| Get the data end pointer. | |
| size_t | GetSharedDataOffset () const |
| Get the shared data offset. | |
| const uint8_t * | GetDataStart () const |
| Get the data start pointer. | |
| float | GetFloat (lldb::offset_t *offset_ptr) const |
| Extract a float from *offset_ptr. | |
| double | GetDouble (lldb::offset_t *offset_ptr) const |
| long double | GetLongDouble (lldb::offset_t *offset_ptr) const |
| uint32_t | GetMaxU32 (lldb::offset_t *offset_ptr, size_t byte_size) const |
| Extract an integer of size byte_size from *offset_ptr. | |
| uint64_t | GetMaxU64 (lldb::offset_t *offset_ptr, size_t byte_size) const |
| Extract an unsigned integer of size byte_size from *offset_ptr. | |
| uint64_t | GetMaxU64_unchecked (lldb::offset_t *offset_ptr, size_t byte_size) const |
| int64_t | GetMaxS64 (lldb::offset_t *offset_ptr, size_t byte_size) const |
| Extract an signed integer of size byte_size from *offset_ptr. | |
| uint64_t | GetMaxU64Bitfield (lldb::offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const |
| Extract an unsigned integer of size byte_size from *offset_ptr, then extract the bitfield from this value if bitfield_bit_size is non-zero. | |
| int64_t | GetMaxS64Bitfield (lldb::offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const |
| Extract an signed integer of size size from *offset_ptr, then extract and sign-extend the bitfield from this value if bitfield_bit_size is non-zero. | |
| lldb::ByteOrder | GetByteOrder () const |
| Get the current byte order value. | |
| uint8_t | GetU8 (lldb::offset_t *offset_ptr) const |
| Extract a uint8_t value from *offset_ptr. | |
| void * | GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const |
| Extract count uint8_t values from *offset_ptr. | |
| uint16_t | GetU16 (lldb::offset_t *offset_ptr) const |
| Extract a uint16_t value from *offset_ptr. | |
| void * | GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const |
| Extract count uint16_t values from *offset_ptr. | |
| uint32_t | GetU32 (lldb::offset_t *offset_ptr) const |
| Extract a uint32_t value from *offset_ptr. | |
| void * | GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const |
| Extract count uint32_t values from *offset_ptr. | |
| uint64_t | GetU64 (lldb::offset_t *offset_ptr) const |
| Extract a uint64_t value from *offset_ptr. | |
| void * | GetU64 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const |
| Extract count uint64_t values from *offset_ptr. | |
| int64_t | GetSLEB128 (lldb::offset_t *offset_ptr) const |
| Extract a signed LEB128 value from *offset_ptr. | |
| uint64_t | GetULEB128 (lldb::offset_t *offset_ptr) const |
| Extract a unsigned LEB128 value from *offset_ptr. | |
| lldb::DataBufferSP & | GetSharedDataBuffer () |
| const char * | PeekCStr (lldb::offset_t offset) const |
| Peek at a C string at offset. | |
| void | SetAddressByteSize (uint32_t addr_size) |
| Set the address byte size. | |
| lldb::offset_t | SetData (const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order) |
| Set data with a buffer that is caller owned. | |
| lldb::offset_t | SetData (const DataExtractor &data, lldb::offset_t offset, lldb::offset_t length) |
| Adopt a subset of data. | |
| lldb::offset_t | SetData (const lldb::DataBufferSP &data_sp, lldb::offset_t offset=0, lldb::offset_t length=LLDB_INVALID_OFFSET) |
| Adopt a subset of shared data in data_sp. | |
| void | SetByteOrder (lldb::ByteOrder byte_order) |
| Set the byte_order value. | |
| uint32_t | Skip_LEB128 (lldb::offset_t *offset_ptr) const |
| Skip an LEB128 number at *offset_ptr. | |
| bool | ValidOffset (lldb::offset_t offset) const |
| Test the validity of offset. | |
| bool | ValidOffsetForDataOfSize (lldb::offset_t offset, lldb::offset_t length) const |
| Test the availability of length bytes of data from offset. | |
| size_t | Copy (DataExtractor &dest_data) const |
| bool | Append (DataExtractor &rhs) |
| bool | Append (void *bytes, lldb::offset_t length) |
| lldb::offset_t | BytesLeft (lldb::offset_t offset) const |
| void | Checksum (llvm::SmallVectorImpl< uint8_t > &dest, uint64_t max_data=0) |
| llvm::ArrayRef< uint8_t > | GetData () const |
| llvm::DataExtractor | GetAsLLVM () const |
Protected Member Functions | |
| const LookupTable::Entry * | FindEntry (lldb::offset_t virtual_addr) const |
| Find the lookup entry that contains the given virtual address. | |
| bool | ValidateVirtualRead (lldb::offset_t virtual_addr, lldb::offset_t length) const |
| Validate that a read at a virtual address is within bounds and does not cross entry boundaries. | |
| Protected Member Functions inherited from lldb_private::DataExtractor | |
| template<typename T> | |
| T | Get (lldb::offset_t *offset_ptr, T fail_value) const |
Private Attributes | |
| LookupTable | m_lookup_table |
Additional Inherited Members | |
| Protected Attributes inherited from lldb_private::DataExtractor | |
| const uint8_t * | m_start = nullptr |
| A pointer to the first byte of data. | |
| const uint8_t * | m_end |
| A pointer to the byte that is past the end of the data. | |
| lldb::ByteOrder | m_byte_order |
| The byte order of the data we are extracting from. | |
| uint32_t | m_addr_size |
| The address size to use when extracting addresses. | |
| lldb::DataBufferSP | m_data_sp |
| The shared pointer to data that can be shared among multiple instances. | |
| uint32_t | m_target_byte_size = 1 |
| Making it const would require implementation of move assignment operator. | |
A DataExtractor subclass that allows reading data at virtual addresses using a lookup table that maps virtual address ranges to physical offsets.
This class maintains a lookup table where each entry contains:
Reads are translated from virtual addresses to physical offsets using this lookup table. Reads cannot cross entry boundaries and this is enforced with assertions.
Definition at line 29 of file VirtualDataExtractor.h.
Type alias for the range map used internally.
Maps virtual addresses (base) to physical offsets (data).
Definition at line 33 of file VirtualDataExtractor.h.
|
default |
| VirtualDataExtractor::VirtualDataExtractor | ( | const void * | data, |
| lldb::offset_t | data_length, | ||
| lldb::ByteOrder | byte_order, | ||
| uint32_t | addr_size, | ||
| LookupTable | lookup_table ) |
Definition at line 15 of file VirtualDataExtractor.cpp.
References lldb_private::DataExtractor::DataExtractor(), and m_lookup_table.
| VirtualDataExtractor::VirtualDataExtractor | ( | const lldb::DataBufferSP & | data_sp, |
| lldb::ByteOrder | byte_order, | ||
| uint32_t | addr_size, | ||
| LookupTable | lookup_table ) |
Definition at line 25 of file VirtualDataExtractor.cpp.
References lldb_private::DataExtractor::DataExtractor(), and m_lookup_table.
|
protected |
Find the lookup entry that contains the given virtual address.
Definition at line 35 of file VirtualDataExtractor.cpp.
References m_lookup_table.
Referenced by GetData(), GetU16_unchecked(), GetU32_unchecked(), GetU64_unchecked(), GetU8_unchecked(), PeekData(), and ValidateVirtualRead().
|
overridevirtual |
Extract length bytes from *offset_ptr.
Returns a pointer to a bytes in this object's data at the offset pointed to by offset_ptr. If length is zero or too large, then the offset pointed to by offset_ptr will not be updated and nullptr will be 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] | length | The optional length of a string to extract. If the value is zero, a NULL terminated C string will be extracted. |
Reimplemented from lldb_private::DataExtractor.
Definition at line 57 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), lldb_private::DataExtractor::PeekData(), and ValidateVirtualRead().
|
overridevirtual |
Reimplemented from lldb_private::DataExtractor.
Definition at line 108 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), and lldb_private::DataExtractor::GetU16_unchecked().
|
overridevirtual |
Reimplemented from lldb_private::DataExtractor.
Definition at line 119 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), and lldb_private::DataExtractor::GetU32_unchecked().
|
overridevirtual |
Reimplemented from lldb_private::DataExtractor.
Definition at line 130 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), and lldb_private::DataExtractor::GetU64_unchecked().
|
overridevirtual |
Unchecked overrides.
Reimplemented from lldb_private::DataExtractor.
Definition at line 97 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), and lldb_private::DataExtractor::GetU8_unchecked().
|
overridevirtual |
Peek at a bytes at offset.
Returns a pointer to length bytes at offset as long as there are length bytes available starting at offset.
Reimplemented from lldb_private::DataExtractor.
Definition at line 83 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), lldb_private::DataExtractor::PeekData(), and ValidateVirtualRead().
|
protected |
Validate that a read at a virtual address is within bounds and does not cross entry boundaries.
Definition at line 40 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::Range< B, S >::Contains(), lldb_private::RangeData< B, S, T >::data, FindEntry(), and lldb_private::DataExtractor::ValidOffsetForDataOfSize().
Referenced by GetData(), and PeekData().
|
private |
Definition at line 70 of file VirtualDataExtractor.h.
Referenced by FindEntry(), VirtualDataExtractor(), and VirtualDataExtractor().