LLDB mainline
lldb_private::IRMemoryMap Class Reference

Encapsulates memory that may exist in the process but must also be available in the host process. More...

#include "lldb/Expression/IRMemoryMap.h"

Inheritance diagram for lldb_private::IRMemoryMap:
[legend]

Classes

struct  Allocation

Public Types

enum  AllocationPolicy : uint8_t { eAllocationPolicyInvalid , eAllocationPolicyHostOnly , eAllocationPolicyMirror , eAllocationPolicyProcessOnly }

Public Member Functions

 IRMemoryMap (lldb::TargetSP target_sp)
 ~IRMemoryMap ()
llvm::Expected< lldb::addr_tMalloc (size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, bool zero_memory, AllocationPolicy *used_policy=nullptr)
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 pointer, 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 ()
ExecutionContextScopeGetBestExecutionContextScope () const
lldb::TargetSP GetTarget ()

Protected Member Functions

lldb::ProcessWPGetProcessWP ()

Private Types

typedef std::map< lldb::addr_t, AllocationAllocationMap

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

Detailed Description

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 35 of file IRMemoryMap.h.

Member Typedef Documentation

◆ AllocationMap

Definition at line 126 of file IRMemoryMap.h.

Member Enumeration Documentation

◆ AllocationPolicy

Enumerator
eAllocationPolicyInvalid 

It is an error for an allocation to have this policy.

eAllocationPolicyHostOnly 

This allocation was created in the host and will never make it into the process.

It is an error to create other types of allocations while such allocations exist.

eAllocationPolicyMirror 

The intent is that this allocation exist both in the host and the process and have the same content in both.

eAllocationPolicyProcessOnly 

The intent is that this allocation exist only in the process.

Definition at line 40 of file IRMemoryMap.h.

Constructor & Destructor Documentation

◆ IRMemoryMap()

IRMemoryMap::IRMemoryMap ( lldb::TargetSP target_sp)

Definition at line 23 of file IRMemoryMap.cpp.

References m_process_wp, and m_target_wp.

Referenced by lldb_private::IRExecutionUnit::IRExecutionUnit().

◆ ~IRMemoryMap()

IRMemoryMap::~IRMemoryMap ( )

Definition at line 28 of file IRMemoryMap.cpp.

References lldb_private::Status::Clear(), Free(), m_allocations, and m_process_wp.

Member Function Documentation

◆ AllocationsIntersect()

bool IRMemoryMap::AllocationsIntersect ( lldb::addr_t addr1,
size_t size1,
lldb::addr_t addr2,
size_t size2 )
staticprivate

Definition at line 246 of file IRMemoryMap.cpp.

Referenced by IntersectsAllocation().

◆ ContainsHostOnlyAllocations()

bool lldb_private::IRMemoryMap::ContainsHostOnlyAllocations ( )
private

◆ FindAllocation()

IRMemoryMap::AllocationMap::iterator IRMemoryMap::FindAllocation ( lldb::addr_t addr,
size_t size )
private

◆ FindSpace()

◆ Free()

◆ GetAddressByteSize()

◆ GetAllocSize()

bool IRMemoryMap::GetAllocSize ( lldb::addr_t address,
size_t & size )

◆ GetBestExecutionContextScope()

◆ GetByteOrder()

◆ GetMemoryData()

◆ GetProcessWP()

lldb::ProcessWP & lldb_private::IRMemoryMap::GetProcessWP ( )
inlineprotected

Definition at line 92 of file IRMemoryMap.h.

References m_process_wp.

Referenced by lldb_private::IRExecutionUnit::GetRunnableInfo(), and WritePointerToMemory().

◆ GetTarget()

lldb::TargetSP lldb_private::IRMemoryMap::GetTarget ( )
inline

Definition at line 86 of file IRMemoryMap.h.

References m_target_wp.

◆ IntersectsAllocation()

bool IRMemoryMap::IntersectsAllocation ( lldb::addr_t addr,
size_t size ) const
private

Definition at line 217 of file IRMemoryMap.cpp.

References AllocationsIntersect(), LLDB_INVALID_ADDRESS, and m_allocations.

◆ Leak()

void IRMemoryMap::Leak ( lldb::addr_t process_address,
Status & error )

◆ Malloc()

◆ ReadMemory()

◆ ReadPointerFromMemory()

◆ ReadScalarFromMemory()

◆ WriteMemory()

◆ WritePointerToMemory()

void IRMemoryMap::WritePointerToMemory ( lldb::addr_t process_address,
lldb::addr_t pointer,
Status & error )

Only ask the Process to fix pointer if the address belongs to the process. An address belongs to the process if the Allocation policy is not eAllocationPolicyHostOnly.

Definition at line 639 of file IRMemoryMap.cpp.

References eAllocationPolicyHostOnly, error(), FindAllocation(), GetAddressByteSize(), GetProcessWP(), m_allocations, and WriteScalarToMemory().

Referenced by IRInterpreter::Interpret(), EntityResultVariable::Materialize(), EntitySymbol::Materialize(), and EntityVariableBase::Materialize().

◆ WriteScalarToMemory()

void IRMemoryMap::WriteScalarToMemory ( lldb::addr_t process_address,
Scalar & scalar,
size_t size,
Status & error )

Member Data Documentation

◆ m_allocations

◆ m_process_wp

◆ m_target_wp

lldb::TargetWP lldb_private::IRMemoryMap::m_target_wp
private

The documentation for this class was generated from the following files: