Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 19 additions & 6 deletions lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,29 @@ Status ProcessDebugger::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
LLDB_LOG(log, "attempting to read {0} bytes from address {1:x}", size,
vm_addr);

HostProcess process = m_session_data->m_debugger->GetProcess();
lldb::process_t handle = m_session_data->m_debugger->GetProcess()
.GetNativeProcess()
.GetSystemHandle();
void *addr = reinterpret_cast<void *>(vm_addr);
SIZE_T num_of_bytes_read = 0;
if (!::ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr,
buf, size, &num_of_bytes_read)) {
error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "reading failed with error: {0}", error);
} else {
if (::ReadProcessMemory(handle, addr, buf, size, &num_of_bytes_read)) {
bytes_read = num_of_bytes_read;
return Status();
}
error = Status(GetLastError(), eErrorTypeWin32);
MemoryRegionInfo info;
if (GetMemoryRegionInfo(vm_addr, info).Fail() ||
info.GetMapped() != MemoryRegionInfo::OptionalBool::eYes)
return error;
size = info.GetRange().GetRangeEnd() - vm_addr;
LLDB_LOG(log, "retrying the read with size {0:x}", size);
if (::ReadProcessMemory(handle, addr, buf, size, &num_of_bytes_read)) {
LLDB_LOG(log, "success: read {0:x} bytes", num_of_bytes_read);
bytes_read = num_of_bytes_read;
return Status();
}
error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "error: {0}", error);
return error;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def _prepare_inferior(self):
]
self.assertEqual(len(self.positions), 5)

@expectedFailureWindows
def test_memory_read(self):
self._prepare_inferior()

Expand Down