LLDB mainline
|
Encapsulates memory that may exist in the process but must also be available in the host process. More...
#include "lldb/Expression/IRMemoryMap.h"
Classes | |
struct | Allocation |
Public Types | |
enum | AllocationPolicy : uint8_t { eAllocationPolicyInvalid , eAllocationPolicyHostOnly , eAllocationPolicyMirror , eAllocationPolicyProcessOnly } |
Public Member Functions | |
IRMemoryMap (lldb::TargetSP target_sp) | |
~IRMemoryMap () | |
lldb::addr_t | Malloc (size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, bool zero_memory, Status &error) |
void | Leak (lldb::addr_t process_address, Status &error) |
void | Free (lldb::addr_t process_address, Status &error) |
void | WriteMemory (lldb::addr_t process_address, const uint8_t *bytes, size_t size, Status &error) |
void | WriteScalarToMemory (lldb::addr_t process_address, Scalar &scalar, size_t size, Status &error) |
void | WritePointerToMemory (lldb::addr_t process_address, lldb::addr_t address, Status &error) |
void | ReadMemory (uint8_t *bytes, lldb::addr_t process_address, size_t size, Status &error) |
void | ReadScalarFromMemory (Scalar &scalar, lldb::addr_t process_address, size_t size, Status &error) |
void | ReadPointerFromMemory (lldb::addr_t *address, lldb::addr_t process_address, Status &error) |
bool | GetAllocSize (lldb::addr_t address, size_t &size) |
void | GetMemoryData (DataExtractor &extractor, lldb::addr_t process_address, size_t size, Status &error) |
lldb::ByteOrder | GetByteOrder () |
uint32_t | GetAddressByteSize () |
ExecutionContextScope * | GetBestExecutionContextScope () const |
lldb::TargetSP | GetTarget () |
Protected Member Functions | |
lldb::ProcessWP & | GetProcessWP () |
Private Types | |
typedef std::map< lldb::addr_t, Allocation > | AllocationMap |
Private Member Functions | |
lldb::addr_t | FindSpace (size_t size) |
bool | ContainsHostOnlyAllocations () |
AllocationMap::iterator | FindAllocation (lldb::addr_t addr, size_t size) |
bool | IntersectsAllocation (lldb::addr_t addr, size_t size) const |
Static Private Member Functions | |
static bool | AllocationsIntersect (lldb::addr_t addr1, size_t size1, lldb::addr_t addr2, size_t size2) |
Private Attributes | |
lldb::ProcessWP | m_process_wp |
lldb::TargetWP | m_target_wp |
AllocationMap | m_allocations |
Encapsulates memory that may exist in the process but must also be available in the host process.
This class encapsulates a group of memory objects that must be readable or writable from the host process regardless of whether the process exists. This allows the IR interpreter as well as JITted code to access the same memory. All allocations made by this class are represented as disjoint intervals.
Point queries against this group of memory objects can be made by the address in the tar at which they reside. If the inferior does not exist, allocations still get made-up addresses. If an inferior appears at some point, then those addresses need to be re-mapped.
Definition at line 34 of file IRMemoryMap.h.
|
private |
Definition at line 120 of file IRMemoryMap.h.
enum lldb_private::IRMemoryMap::AllocationPolicy : uint8_t |
Definition at line 39 of file IRMemoryMap.h.
IRMemoryMap::IRMemoryMap | ( | lldb::TargetSP | target_sp | ) |
Definition at line 23 of file IRMemoryMap.cpp.
References m_process_wp.
IRMemoryMap::~IRMemoryMap | ( | ) |
Definition at line 28 of file IRMemoryMap.cpp.
References lldb_private::Status::Clear(), Free(), m_allocations, and m_process_wp.
|
staticprivate |
Definition at line 246 of file IRMemoryMap.cpp.
Referenced by IntersectsAllocation().
|
private |
|
private |
Definition at line 199 of file IRMemoryMap.cpp.
References LLDB_INVALID_ADDRESS, and m_allocations.
Referenced by GetAllocSize(), GetMemoryData(), ReadMemory(), and WriteMemory().
|
private |
Definition at line 46 of file IRMemoryMap.cpp.
References lldb_private::MemoryRegionInfo::eNo, lldb_private::Status::Fail(), GetAddressByteSize(), lldb_private::MemoryRegionInfo::GetExecutable(), lldb_private::MemoryRegionInfo::GetRange(), lldb_private::Range< B, S >::GetRangeBase(), lldb_private::Range< B, S >::GetRangeEnd(), lldb_private::MemoryRegionInfo::GetReadable(), lldb_private::MemoryRegionInfo::GetWritable(), LLDB_INVALID_ADDRESS, lldbassert, m_allocations, m_process_wp, m_target_wp, lldb_private::Status::Success(), and UINT32_MAX.
Referenced by Malloc().
void IRMemoryMap::Free | ( | lldb::addr_t | process_address, |
Status & | error | ||
) |
Definition at line 479 of file IRMemoryMap.cpp.
References eAllocationPolicyHostOnly, eAllocationPolicyMirror, eAllocationPolicyProcessOnly, error(), lldb_private::Expressions, lldb_private::GetLog(), LLDB_LOGF, m_allocations, lldb_private::IRMemoryMap::Allocation::m_policy, lldb_private::IRMemoryMap::Allocation::m_process_alloc, and m_process_wp.
Referenced by lldb_private::IRExecutionUnit::CommitAllocations(), EntityVariableBase::Dematerialize(), EntityResultVariable::Dematerialize(), EntityPersistentVariable::DestroyAllocation(), lldb_private::IRExecutionUnit::FreeNow(), IRInterpreter::Interpret(), InterpreterStackFrame::MakeArgument(), InterpreterStackFrame::ResolveValue(), EntityVariableBase::Wipe(), EntityResultVariable::Wipe(), lldb_private::IRExecutionUnit::WriteNow(), and ~IRMemoryMap().
uint32_t IRMemoryMap::GetAddressByteSize | ( | ) |
Definition at line 275 of file IRMemoryMap.cpp.
References m_process_wp, m_target_wp, and UINT32_MAX.
Referenced by EntityResultVariable::Dematerialize(), EntityVariableBase::DumpToLog(), EntityResultVariable::DumpToLog(), FindSpace(), GetMemoryData(), EntityPersistentVariable::MakeAllocation(), EntityPersistentVariable::Materialize(), ReadPointerFromMemory(), ReadScalarFromMemory(), and WritePointerToMemory().
bool IRMemoryMap::GetAllocSize | ( | lldb::addr_t | address, |
size_t & | size | ||
) |
Definition at line 523 of file IRMemoryMap.cpp.
References FindAllocation(), m_allocations, lldb_private::IRMemoryMap::Allocation::m_process_start, and lldb_private::IRMemoryMap::Allocation::m_size.
Referenced by IRInterpreter::Interpret().
ExecutionContextScope * IRMemoryMap::GetBestExecutionContextScope | ( | ) | const |
Definition at line 289 of file IRMemoryMap.cpp.
References m_process_wp, and m_target_wp.
Referenced by EntityPersistentVariable::Dematerialize(), EntityVariableBase::Dematerialize(), EntityResultVariable::Dematerialize(), lldb_private::Materializer::Dematerializer::Dematerialize(), lldb_private::IRExecutionUnit::GetAddressByteSize(), lldb_private::IRExecutionUnit::GetArchitecture(), lldb_private::IRExecutionUnit::GetByteOrder(), lldb_private::IRExecutionUnit::GetJITModule(), EntityPersistentVariable::MakeAllocation(), lldb_private::Materializer::Materialize(), EntityVariableBase::Materialize(), EntityResultVariable::Materialize(), and EntitySymbol::Materialize().
lldb::ByteOrder IRMemoryMap::GetByteOrder | ( | ) |
Definition at line 261 of file IRMemoryMap.cpp.
References lldb::eByteOrderInvalid, m_process_wp, and m_target_wp.
Referenced by EntityResultVariable::Dematerialize(), EntityVariableBase::DumpToLog(), EntityResultVariable::DumpToLog(), GetMemoryData(), ReadScalarFromMemory(), and WriteScalarToMemory().
void IRMemoryMap::GetMemoryData | ( | DataExtractor & | extractor, |
lldb::addr_t | process_address, | ||
size_t | size, | ||
Status & | error | ||
) |
Definition at line 806 of file IRMemoryMap.cpp.
References eAllocationPolicyHostOnly, eAllocationPolicyMirror, eAllocationPolicyProcessOnly, error(), FindAllocation(), GetAddressByteSize(), GetByteOrder(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), m_allocations, lldb_private::IRMemoryMap::Allocation::m_data, lldb_private::IRMemoryMap::Allocation::m_policy, lldb_private::IRMemoryMap::Allocation::m_process_start, and m_process_wp.
Referenced by EntityVariableBase::Dematerialize(), EntityRegister::Dematerialize(), and InterpreterStackFrame::EvaluateValue().
|
inlineprotected |
Definition at line 86 of file IRMemoryMap.h.
References m_process_wp.
Referenced by lldb_private::IRExecutionUnit::GetRunnableInfo().
|
inline |
Definition at line 80 of file IRMemoryMap.h.
References m_target_wp.
Referenced by IRForTarget::CreateResultVariable(), and IRForTarget::MaybeHandleVariable().
|
private |
Definition at line 217 of file IRMemoryMap.cpp.
References AllocationsIntersect(), LLDB_INVALID_ADDRESS, and m_allocations.
void IRMemoryMap::Leak | ( | lldb::addr_t | process_address, |
Status & | error | ||
) |
Definition at line 463 of file IRMemoryMap.cpp.
References error(), m_allocations, and lldb_private::IRMemoryMap::Allocation::m_leak.
Referenced by EntityPersistentVariable::MakeAllocation().
lldb::addr_t IRMemoryMap::Malloc | ( | size_t | size, |
uint8_t | alignment, | ||
uint32_t | permissions, | ||
AllocationPolicy | policy, | ||
bool | zero_memory, | ||
Status & | error | ||
) |
Definition at line 322 of file IRMemoryMap.cpp.
References eAllocationPolicyHostOnly, eAllocationPolicyMirror, eAllocationPolicyProcessOnly, error(), lldb_private::Expressions, FindSpace(), lldb_private::GetLog(), LLDB_INVALID_ADDRESS, LLDB_LOGF, m_allocations, m_process_wp, and WriteMemory().
Referenced by lldb_private::IRExecutionUnit::CommitOneAllocation(), EntityPersistentVariable::MakeAllocation(), EntityVariableBase::Materialize(), EntityResultVariable::Materialize(), and lldb_private::IRExecutionUnit::WriteNow().
void IRMemoryMap::ReadMemory | ( | uint8_t * | bytes, |
lldb::addr_t | process_address, | ||
size_t | size, | ||
Status & | error | ||
) |
Definition at line 654 of file IRMemoryMap.cpp.
References eAllocationPolicyHostOnly, eAllocationPolicyMirror, eAllocationPolicyProcessOnly, error(), lldb_private::Expressions, FindAllocation(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), lldb_private::GetLog(), LLDB_LOGF, m_allocations, lldb_private::IRMemoryMap::Allocation::m_data, lldb_private::IRMemoryMap::Allocation::m_policy, lldb_private::IRMemoryMap::Allocation::m_process_start, m_process_wp, lldb_private::IRMemoryMap::Allocation::m_size, and m_target_wp.
Referenced by EntityPersistentVariable::Dematerialize(), EntityResultVariable::Dematerialize(), EntityPersistentVariable::DumpToLog(), EntityVariableBase::DumpToLog(), EntityResultVariable::DumpToLog(), EntitySymbol::DumpToLog(), EntityRegister::DumpToLog(), lldb_private::IRExecutionUnit::GetRunnableInfo(), IRInterpreter::Interpret(), InterpreterStackFrame::PrintData(), ReadScalarFromMemory(), and lldb_private::IRExecutionUnit::WriteNow().
void IRMemoryMap::ReadPointerFromMemory | ( | lldb::addr_t * | address, |
lldb::addr_t | process_address, | ||
Status & | error | ||
) |
Definition at line 791 of file IRMemoryMap.cpp.
References error(), GetAddressByteSize(), ReadScalarFromMemory(), and lldb_private::Scalar::ULongLong().
Referenced by EntityPersistentVariable::Dematerialize(), EntityResultVariable::Dematerialize(), EntityPersistentVariable::DumpToLog(), and IRInterpreter::Interpret().
void IRMemoryMap::ReadScalarFromMemory | ( | Scalar & | scalar, |
lldb::addr_t | process_address, | ||
size_t | size, | ||
Status & | error | ||
) |
Definition at line 749 of file IRMemoryMap.cpp.
References error(), GetAddressByteSize(), GetByteOrder(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), lldb_private::DataExtractor::GetU16(), lldb_private::DataExtractor::GetU32(), lldb_private::DataExtractor::GetU64(), lldb_private::DataExtractor::GetU8(), and ReadMemory().
Referenced by ReadPointerFromMemory().
void IRMemoryMap::WriteMemory | ( | lldb::addr_t | process_address, |
const uint8_t * | bytes, | ||
size_t | size, | ||
Status & | error | ||
) |
Definition at line 545 of file IRMemoryMap.cpp.
References eAllocationPolicyHostOnly, eAllocationPolicyMirror, eAllocationPolicyProcessOnly, error(), lldb_private::Expressions, FindAllocation(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), lldb_private::GetLog(), LLDB_LOGF, m_allocations, lldb_private::IRMemoryMap::Allocation::m_data, lldb_private::IRMemoryMap::Allocation::m_policy, lldb_private::IRMemoryMap::Allocation::m_process_start, m_process_wp, and lldb_private::IRMemoryMap::Allocation::m_size.
Referenced by InterpreterStackFrame::AssignValue(), IRInterpreter::Interpret(), EntityPersistentVariable::MakeAllocation(), Malloc(), EntityVariableBase::Materialize(), EntityRegister::Materialize(), InterpreterStackFrame::ResolveConstant(), lldb_private::IRExecutionUnit::WriteData(), lldb_private::IRExecutionUnit::WriteNow(), and WriteScalarToMemory().
void IRMemoryMap::WritePointerToMemory | ( | lldb::addr_t | process_address, |
lldb::addr_t | address, | ||
Status & | error | ||
) |
Definition at line 645 of file IRMemoryMap.cpp.
References error(), GetAddressByteSize(), and WriteScalarToMemory().
Referenced by IRInterpreter::Interpret(), InterpreterStackFrame::MakeArgument(), EntityVariableBase::Materialize(), EntityResultVariable::Materialize(), and EntitySymbol::Materialize().
void IRMemoryMap::WriteScalarToMemory | ( | lldb::addr_t | process_address, |
Scalar & | scalar, | ||
size_t | size, | ||
Status & | error | ||
) |
Definition at line 620 of file IRMemoryMap.cpp.
References error(), lldb_private::Scalar::GetAsMemoryData(), GetByteOrder(), lldb_private::Scalar::GetByteSize(), UINT32_MAX, and WriteMemory().
Referenced by EntityPersistentVariable::Materialize(), and WritePointerToMemory().
|
private |
Definition at line 121 of file IRMemoryMap.h.
Referenced by FindAllocation(), FindSpace(), Free(), GetAllocSize(), GetMemoryData(), IntersectsAllocation(), Leak(), Malloc(), ReadMemory(), WriteMemory(), and ~IRMemoryMap().
|
private |
Definition at line 118 of file IRMemoryMap.h.
Referenced by FindSpace(), Free(), GetAddressByteSize(), GetBestExecutionContextScope(), GetByteOrder(), GetMemoryData(), GetProcessWP(), IRMemoryMap(), Malloc(), ReadMemory(), WriteMemory(), and ~IRMemoryMap().
|
private |
Definition at line 119 of file IRMemoryMap.h.
Referenced by FindSpace(), GetAddressByteSize(), GetBestExecutionContextScope(), GetByteOrder(), GetTarget(), and ReadMemory().