|
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) | |
| VirtualDataExtractor (const lldb::DataBufferSP &data_sp, LookupTable lookup_table) | |
| lldb::DataExtractorSP | Clone () const override |
| Return a shared pointer to a copy of this object. | |
| 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. | |
| lldb::DataExtractorSP | GetSubsetExtractorSP (lldb::offset_t offset, lldb::offset_t length) override |
| Return a new DataExtractor which represents a subset of an existing data extractor's bytes, copying all other fields from the existing data extractor. | |
| lldb::DataExtractorSP | GetSubsetExtractorSP (lldb::offset_t offset) override |
| Return a new DataExtractor which represents a subset of an existing data extractor's bytes, copying all other fields from the existing data extractor. | |
| llvm::ArrayRef< uint8_t > | GetData () const override |
| uint64_t | GetByteSize () const override |
| GetByteSize is called by external users often, and we want to return the virtual buffer size that the user expects to see. | |
| lldb::offset_t | BytesLeft (lldb::offset_t offset) const override |
| BytesLeft is mostly called by DataExtractor internal methods, to ensure we don't read past the end of the DataBuffer. | |
| lldb::offset_t | SetData (const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order) override |
| Set data with a buffer that is caller owned. | |
| lldb::offset_t | SetData (const DataExtractor &data, lldb::offset_t offset, lldb::offset_t length) override |
| 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) override |
| Adopt a subset of shared data in data_sp. | |
| 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) | |
| Construct with a buffer that is owned by the caller. | |
| DataExtractor (const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order, uint32_t addr_size) | |
| Construct with shared data. | |
| DataExtractor (const lldb::DataBufferSP &data_sp) | |
| Construct with shared data, but byte-order & addr-size are unspecified. | |
| DataExtractor (const DataExtractor &data, lldb::offset_t offset, lldb::offset_t length) | |
| 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. | |
| 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. | |
| 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. | |
| virtual lldb::DataExtractorSP | GetContiguousDataExtractorSP () |
| Return a new DataExtractor which represents a subset of an existing data extractor's bytes, copying all other fields from the existing data extractor. | |
| lldb::DataBufferSP | GetSharedDataBuffer () const |
| bool | HasData () |
| 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. | |
| 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) |
| void | Checksum (llvm::SmallVectorImpl< uint8_t > &dest, uint64_t max_data=0) |
| llvm::DWARFDataExtractor | GetAsLLVMDWARF () 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. | |
| uint64_t | GetVirtualByteSize () const |
| uint64_t | GetPhysicalByteSize () const |
| lldb::offset_t | VirtualBytesLeft (lldb::offset_t virtual_offset) const |
| lldb::offset_t | PhysicalBytesLeft (lldb::offset_t physical_offset) const |
| void | ResetLookupTableToMatchPhysical () |
| 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. | |
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.
| VirtualDataExtractor::VirtualDataExtractor | ( | const lldb::DataBufferSP & | data_sp, |
| LookupTable | lookup_table ) |
Definition at line 34 of file VirtualDataExtractor.cpp.
References lldb_private::DataExtractor::DataExtractor(), and m_lookup_table.
|
inlineoverridevirtual |
BytesLeft is mostly called by DataExtractor internal methods, to ensure we don't read past the end of the DataBuffer.
Use the physical buffer size.
Reimplemented from lldb_private::DataExtractor.
Definition at line 73 of file VirtualDataExtractor.h.
References PhysicalBytesLeft().
|
inlineoverridevirtual |
Return a shared pointer to a copy of this object.
May be overridden by a subclass, so the object is copied correctly.
Reimplemented from lldb_private::DataExtractor.
Definition at line 49 of file VirtualDataExtractor.h.
|
protected |
Find the lookup entry that contains the given virtual address.
Definition at line 41 of file VirtualDataExtractor.cpp.
References m_lookup_table.
Referenced by GetData(), GetData(), GetSubsetExtractorSP(), GetSubsetExtractorSP(), GetU16_unchecked(), GetU32_unchecked(), GetU64_unchecked(), GetU8_unchecked(), PeekData(), and ValidateVirtualRead().
|
inlineoverridevirtual |
GetByteSize is called by external users often, and we want to return the virtual buffer size that the user expects to see.
Reimplemented from lldb_private::DataExtractor.
Definition at line 68 of file VirtualDataExtractor.h.
References GetVirtualByteSize().
|
overridevirtual |
Reimplemented from lldb_private::DataExtractor.
Definition at line 307 of file VirtualDataExtractor.cpp.
References lldb_private::RangeData< B, S, T >::data, FindEntry(), lldb_private::DataExtractor::m_start, and lldb_private::Range< B, S >::size.
|
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 63 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 |
Definition at line 172 of file VirtualDataExtractor.cpp.
References lldb_private::DataExtractor::m_end, and lldb_private::DataExtractor::m_start.
Referenced by ResetLookupTableToMatchPhysical().
|
overridevirtual |
Return a new DataExtractor which represents a subset of an existing data extractor's bytes, copying all other fields from the existing data extractor.
The length will be the largest contiguous region that can be provided starting at offset; it is safe to read any bytes within the returned subset Extractor.
| [in] | offset | The starting byte offset into the shared data buffer. |
Reimplemented from lldb_private::DataExtractor.
Definition at line 284 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), lldb_private::DataExtractor::GetAddressByteSize(), lldb_private::DataExtractor::GetByteOrder(), lldb_private::DataExtractor::GetSharedDataBuffer(), and lldb_private::Range< B, S >::size.
|
overridevirtual |
Return a new DataExtractor which represents a subset of an existing data extractor's bytes, copying all other fields from the existing data extractor.
| [in] | offset | The starting byte offset into the shared data buffer. |
| [in] | length | The length of bytes that the new extractor can operate on. |
Reimplemented from lldb_private::DataExtractor.
Definition at line 250 of file VirtualDataExtractor.cpp.
References lldb_private::Range< B, S >::base, lldb_private::RangeData< B, S, T >::data, FindEntry(), lldb_private::DataExtractor::GetAddressByteSize(), lldb_private::DataExtractor::GetByteOrder(), lldb_private::DataExtractor::GetSharedDataBuffer(), and lldb_private::Range< B, S >::size.
|
overridevirtual |
Reimplemented from lldb_private::DataExtractor.
Definition at line 216 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 227 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 238 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 205 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().
|
protected |
Definition at line 162 of file VirtualDataExtractor.cpp.
References m_lookup_table.
Referenced by GetByteSize(), SetData(), SetData(), SetData(), and VirtualBytesLeft().
|
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 191 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 |
Definition at line 184 of file VirtualDataExtractor.cpp.
References lldb_private::DataExtractor::m_end, and lldb_private::DataExtractor::m_start.
Referenced by BytesLeft().
|
protected |
Definition at line 149 of file VirtualDataExtractor.cpp.
References GetPhysicalByteSize(), and m_lookup_table.
|
overridevirtual |
Adopt a subset of data.
Set this object's data to be a subset of the data bytes in data. If data contains shared data, then a reference to the shared data will be added to ensure the shared data stays around as long as any objects have references to the shared data. The byte order and the address size settings are copied from data. If offset is not a valid offset in data, then no reference to the shared data will be added. If there are not length bytes available in data starting at offset, the length will be truncated to contains as many bytes as possible.
| [in] | data | Another DataExtractor object that contains data. |
| [in] | offset | The offset into data at which the subset starts. |
| [in] | length | The length in bytes of the subset of data. |
Reimplemented from lldb_private::DataExtractor.
Definition at line 108 of file VirtualDataExtractor.cpp.
References lldb_private::DataExtractor::DataExtractor(), lldb_private::DataExtractor::GetSharedDataBuffer(), GetVirtualByteSize(), lldb_private::DataExtractor::m_data_sp, lldb_private::DataExtractor::m_start, ResetLookupTableToMatchPhysical(), and lldb_private::DataExtractor::SetData().
|
overridevirtual |
Adopt a subset of shared data in data_sp.
Copies the data shared pointer which adds a reference to the contained in data_sp. The shared data reference is reference counted to ensure the data lives as long as anyone still has a valid shared pointer to the data in data_sp. The byte order and address byte size settings remain the same. If offset is not a valid offset in data_sp, then no reference to the shared data will be added. If there are not length bytes available in data starting at offset, the length will be truncated to contains as many bytes as possible.
| [in] | data_sp | A shared pointer to data. |
| [in] | offset | The offset into data_sp at which the subset starts. |
| [in] | length | The length in bytes of the subset of data_sp. |
Reimplemented from lldb_private::DataExtractor.
Definition at line 128 of file VirtualDataExtractor.cpp.
References GetVirtualByteSize(), lldb_private::DataExtractor::m_data_sp, lldb_private::DataExtractor::m_start, ResetLookupTableToMatchPhysical(), and lldb_private::DataExtractor::SetData().
|
overridevirtual |
Set data with a buffer that is caller owned.
Use data that is owned by the caller when extracting values. The data must stay around as long as this object, or any object that copies a subset of this object's data, is valid. If bytes is nullptr, or length is zero, this object will contain no data.
| [in] | bytes | A pointer to caller owned data. |
| [in] | length | The length in bytes of bytes. |
| [in] | byte_order | A byte order of the data that we are extracting from. |
Reimplemented from lldb_private::DataExtractor.
Definition at line 89 of file VirtualDataExtractor.cpp.
References GetVirtualByteSize(), lldb_private::DataExtractor::m_data_sp, lldb_private::DataExtractor::m_start, ResetLookupTableToMatchPhysical(), and lldb_private::DataExtractor::SetData().
|
protected |
Validate that a read at a virtual address is within bounds and does not cross entry boundaries.
Definition at line 46 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().
|
protected |
Definition at line 176 of file VirtualDataExtractor.cpp.
References GetVirtualByteSize().
|
private |
Definition at line 112 of file VirtualDataExtractor.h.
Referenced by FindEntry(), GetVirtualByteSize(), ResetLookupTableToMatchPhysical(), VirtualDataExtractor(), VirtualDataExtractor(), and VirtualDataExtractor().