diff options
author | Sean Callanan <scallanan@apple.com> | 2013-04-15 21:35:52 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2013-04-15 21:35:52 +0000 |
commit | c8c5b8dcd79c5ca14a21fcc2476e52862dd0bf18 (patch) | |
tree | edfad1c8a02976cf782eb57270c9cc5d32e723b6 | |
parent | b0270899b5a4f76dfe342d8e516d9d5eb68088dd (diff) | |
download | bcm5719-llvm-c8c5b8dcd79c5ca14a21fcc2476e52862dd0bf18.tar.gz bcm5719-llvm-c8c5b8dcd79c5ca14a21fcc2476e52862dd0bf18.zip |
Fixed a few bugs in IRMemoryMap:
- If an allocation is mirrored between the host
and the process, update the host's version
before returning a DataExtractor pointing to
it.
- If anyone attempts to access memory in a
process/target that does not have a corresponding
allocation, try accessing the memory directly
before erroring out.
llvm-svn: 179561
-rw-r--r-- | lldb/source/Expression/IRMemoryMap.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/lldb/source/Expression/IRMemoryMap.cpp b/lldb/source/Expression/IRMemoryMap.cpp index 300aaa5ed4a..7aecc9e1514 100644 --- a/lldb/source/Expression/IRMemoryMap.cpp +++ b/lldb/source/Expression/IRMemoryMap.cpp @@ -325,8 +325,16 @@ IRMemoryMap::WriteMemory (lldb::addr_t process_address, const uint8_t *bytes, si if (iter == m_allocations.end()) { + lldb::ProcessSP process_sp = m_process_wp.lock(); + + if (process_sp) + { + process_sp->WriteMemory(process_address, bytes, size, error); + return; + } + error.SetErrorToGenericError(); - error.SetErrorString("Couldn't write: no allocation contains the target range"); + error.SetErrorString("Couldn't write: no allocation contains the target range and the process doesn't exist"); return; } @@ -433,8 +441,25 @@ IRMemoryMap::ReadMemory (uint8_t *bytes, lldb::addr_t process_address, size_t si if (iter == m_allocations.end()) { + lldb::ProcessSP process_sp = m_process_wp.lock(); + + if (process_sp) + { + process_sp->ReadMemory(process_address, bytes, size, error); + return; + } + + lldb::TargetSP target_sp = m_target_wp.lock(); + + if (target_sp) + { + Address absolute_address(process_address); + target_sp->ReadMemory(absolute_address, false, bytes, size, error); + return; + } + error.SetErrorToGenericError(); - error.SetErrorString("Couldn't read: no allocation contains the target range"); + error.SetErrorString("Couldn't read: no allocation contains the target range, and neither the process nor the target exist"); return; } @@ -561,8 +586,27 @@ IRMemoryMap::GetMemoryData (DataExtractor &extractor, lldb::addr_t process_addre error.SetErrorToGenericError(); error.SetErrorString("Couldn't get memory data: memory is only in the target"); return; - case eAllocationPolicyHostOnly: case eAllocationPolicyMirror: + { + lldb::ProcessSP process_sp = m_process_wp.lock(); + + if (!allocation.m_data.get()) + { + error.SetErrorToGenericError(); + error.SetErrorString("Couldn't get memory data: data buffer is empty"); + return; + } + if (process_sp) + { + process_sp->ReadMemory(allocation.m_process_start, allocation.m_data->GetBytes(), allocation.m_data->GetByteSize(), error); + if (!error.Success()) + return; + uint64_t offset = process_address - allocation.m_process_start; + extractor = DataExtractor(allocation.m_data->GetBytes() + offset, size, GetByteOrder(), GetAddressByteSize()); + return; + } + } + case eAllocationPolicyHostOnly: if (!allocation.m_data.get()) { error.SetErrorToGenericError(); |