From 8eb3281731de833d41016c97dc2c002b9580f824 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 21 May 2014 23:44:02 +0000 Subject: [PATCH] Change ProcessKDP::DoReadMemory() to break up large memory read requests into smaller chunks; some remote kdp stubs cannot handle memory reads larger than a KB or two & will error out. llvm-svn: 209341 --- .../Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 6be373c..c2ae2b9 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -647,8 +647,32 @@ ProcessKDP::IsAlive () size_t ProcessKDP::DoReadMemory (addr_t addr, void *buf, size_t size, Error &error) { + uint8_t *data_buffer = (uint8_t *) buf; if (m_comm.IsConnected()) - return m_comm.SendRequestReadMemory (addr, buf, size, error); + { + const size_t max_read_size = 512; + size_t total_bytes_read = 0; + + // Read the requested amount of memory in 512 byte chunks + while (total_bytes_read < size) + { + size_t bytes_to_read_this_request = size - total_bytes_read; + if (bytes_to_read_this_request > max_read_size) + { + bytes_to_read_this_request = max_read_size; + } + size_t bytes_read = m_comm.SendRequestReadMemory (addr + total_bytes_read, + data_buffer + total_bytes_read, + bytes_to_read_this_request, error); + total_bytes_read += bytes_read; + if (error.Fail() || bytes_read == 0) + { + return total_bytes_read; + } + } + + return total_bytes_read; + } error.SetErrorString ("not connected"); return 0; } -- 2.7.4