Skip to content

Commit ce9c2cc

Browse files
[lldb] Call FixUpPointer in WritePointerToMemory (try 2)
In architectures where pointers may contain metadata, such as arm64e, the metadata may need to be cleaned prior to sending this pointer to be used in expression evaluation generated code. This patch is a step towards allowing consumers of pointers to decide whether they want to keep or remove metadata, as opposed to discarding metadata at the moment pointers are created. See #150537. This was tested running the LLDB test suite on arm64e. (The first attempt at this patch caused a failure in TestScriptedProcessEmptyMemoryRegion.py. This test exercises a case where IRMemoryMap uses host memory in its allocations; pointers to such allocations should not be fixed, which is what the original patch failed to account for).
1 parent b671979 commit ce9c2cc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lldb/source/Expression/IRMemoryMap.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,13 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t process_address,
640640
lldb::addr_t address, Status &error) {
641641
error.Clear();
642642

643+
/// Only ask the Process to fix the address if this address belongs to the
644+
/// process (host allocations are stored in m_data).
645+
if (auto it = FindAllocation(process_address, 1);
646+
it != m_allocations.end() && it->second.m_data.GetByteSize() == 0)
647+
if (auto process_sp = GetProcessWP().lock())
648+
address = process_sp->FixAnyAddress(address);
649+
643650
Scalar scalar(address);
644651

645652
WriteScalarToMemory(process_address, scalar, GetAddressByteSize(), error);

0 commit comments

Comments
 (0)