diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp --- a/lldb/source/Target/Memory.cpp +++ b/lldb/source/Target/Memory.cpp @@ -232,8 +232,17 @@ if (process_bytes_read == 0) return dst_len - bytes_left; - if (process_bytes_read != cache_line_byte_size) - data_buffer_heap_up->SetByteSize(process_bytes_read); + if (process_bytes_read != cache_line_byte_size) { + // If the data available to read is less than an entire page, we don't + // resize the buffer because we still want to return at least + // 'dst_len' bytes. In that case fill the rest of the buffer with a + // fail-fill value (0xdd). + if (process_bytes_read >= data_buffer_heap_up->GetByteSize()) + data_buffer_heap_up->SetByteSize(process_bytes_read); + else + memset(data_buffer_heap_up->GetBytes() + process_bytes_read, 0xdd, + data_buffer_heap_up->GetByteSize() - process_bytes_read); + } m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_up.release()); // We have read data and put it into the cache, continue through the // loop again to get the data out of the cache...