Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lldb/source/Expression/IRMemoryMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,15 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t process_address,
lldb::addr_t address, Status &error) {
error.Clear();

/// Only ask the Process to fix the address if this address belongs to the
/// process. An address belongs to the process if the Allocation contains a
/// non-empty m_data member.
if (auto it = FindAllocation(process_address, 1);
it != m_allocations.end() && it->second.m_data.GetByteSize() == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at IRMemoryMap::WriteMemory() (I haven't read these methods in years, needed to refresh my memory), it has different behavior based on the Allocation m_policy which can be one of eAllocationPolicyHostOnly, eAllocationPolicyMirror, or eAllocationPolicyProcessOnly. The goal is to run any pointer that is written into actual process memory through Fix, because it will be used by a jitted expression running in native code, and cannot refer to the host-side-only fake addresses that IRMemoryMap may hand out. Maybe the m_data.GetByteSize() test is sufficient, but I think it's maybe clearer to test for m_policy != eAllocationPolicyHostOnly? I'm not sure what Mirror is used for, possibly expression results where we might want to take the address of them in inferior-memory, but for efficiency of display/use in lldb, also stored in lldb.

if (auto process_sp = GetProcessWP().lock())
address = process_sp->FixAnyAddress(address);
}

Scalar scalar(address);

WriteScalarToMemory(process_address, scalar, GetAddressByteSize(), error);
Expand Down
Loading