Skip to content

Commit eacd55c

Browse files
committed
Run GCF
1 parent 6742dc1 commit eacd55c

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

lldb/include/lldb/Target/Process.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,17 +1592,15 @@ class Process : public std::enable_shared_from_this<Process>,
15921592
// Callback definition for read Memory in chunks
15931593
//
15941594
// Status, the status returned from ReadMemoryFromInferior
1595-
// DataBufferHeap, buffer with bytes potentially written to it
1595+
// uint8_t*, pointer to the bytes read
15961596
// addr_t, the current_addr, start + bytes read so far.
1597-
// uint64_t bytes_to_read, the expected bytes read, this
1597+
// uint64_t bytes_to_read, the expected bytes read, this
15981598
// is important if it's a partial read
1599-
// uint64_t bytes_read_for_chunk, the actual count of bytes read for this
1599+
// uint64_t bytes_read_for_chunk, the actual count of bytes read for this
16001600
// chunk
1601-
typedef std::function<IterationAction(lldb_private::Status&,
1602-
lldb_private::DataBufferHeap&,
1603-
lldb::addr_t,
1604-
uint64_t,
1605-
uint64_t)> ReadMemoryChunkCallback;
1601+
typedef std::function<IterationAction(lldb_private::Status &, const void *,
1602+
lldb::addr_t, uint64_t, uint64_t)>
1603+
ReadMemoryChunkCallback;
16061604

16071605
/// Read of memory from a process in discrete chunks, terminating
16081606
/// either when all bytes are read, or the supplied callback returns

lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
976976
Log *log = GetLog(LLDBLog::Object);
977977
Status addDataError;
978978
Process::ReadMemoryChunkCallback callback =
979-
[&](Status &error, DataBufferHeap &data, lldb::addr_t current_addr,
979+
[&](Status &error, const void *buf, lldb::addr_t current_addr,
980980
uint64_t bytes_to_read,
981981
uint64_t bytes_read_for_chunk) -> lldb_private::IterationAction {
982982
if (error.Fail() || bytes_read_for_chunk == 0) {
@@ -1000,7 +1000,7 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
10001000
// This error will be captured by the outer scope and is considered fatal.
10011001
// If we get an error writing to disk we can't easily guarauntee that we
10021002
// won't corrupt the minidump.
1003-
addDataError = AddData(data_buffer.GetBytes(), bytes_read_for_chunk);
1003+
addDataError = AddData(buf, bytes_read_for_chunk);
10041004
if (addDataError.Fail())
10051005
return lldb_private::IterationAction::Stop;
10061006

@@ -1022,8 +1022,8 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
10221022

10231023
const lldb::addr_t addr = range.range.start();
10241024
const lldb::addr_t size = range.range.size();
1025-
bytes_read =
1026-
m_process_sp->ReadMemoryInChunks(addr, data_buffer, size, callback);
1025+
bytes_read = m_process_sp->ReadMemoryInChunks(
1026+
addr, data_buffer.GetBytes(), data_buffer.GetByteSize(), size, callback);
10271027
return addDataError;
10281028
}
10291029

lldb/source/Target/Process.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,27 +2233,28 @@ size_t Process::ReadMemoryFromInferior(addr_t addr, void *buf, size_t size,
22332233
return bytes_read;
22342234
}
22352235

2236-
size_t Process::ReadMemoryInChunks(lldb::addr_t vm_addr, DataBufferHeap &data,
2237-
size_t size, ReadMemoryChunkCallback callback) {
2238-
// Safety check to prevent an infinite loop.
2239-
if (data.GetByteSize() == 0)
2240-
return 0;
2241-
2242-
uint64_t bytes_remaining = size;
2243-
uint64_t bytes_read = 0;
2244-
Status error;
2245-
while (bytes_remaining > 0) {
2246-
// Get the next read chunk size as the minimum of the remaining bytes and
2247-
// the write chunk max size.
2248-
const size_t bytes_to_read =
2249-
std::min(bytes_remaining, data.GetByteSize());
2250-
const lldb::addr_t current_addr = vm_addr + bytes_read;
2251-
const size_t bytes_read_for_chunk =
2252-
ReadMemoryFromInferior(current_addr,
2253-
data.GetBytes(), bytes_to_read, error);
2254-
2255-
if (callback(error, data, current_addr, bytes_to_read, bytes_read_for_chunk) == IterationAction::Stop)
2256-
break;
2236+
size_t Process::ReadMemoryInChunks(lldb::addr_t vm_addr, void *buf,
2237+
lldb::addr_t chunk_size, size_t size,
2238+
ReadMemoryChunkCallback callback) {
2239+
// Safety check to prevent an infinite loop.
2240+
if (chunk_size == 0)
2241+
return 0;
2242+
2243+
// Create a data buffer heap of the specified size, initialized to 0.
2244+
uint64_t bytes_remaining = size;
2245+
uint64_t bytes_read = 0;
2246+
Status error;
2247+
while (bytes_remaining > 0) {
2248+
// Get the next read chunk size as the minimum of the remaining bytes and
2249+
// the write chunk max size.
2250+
const size_t bytes_to_read = std::min(bytes_remaining, chunk_size);
2251+
const lldb::addr_t current_addr = vm_addr + bytes_read;
2252+
const size_t bytes_read_for_chunk =
2253+
ReadMemoryFromInferior(current_addr, buf, bytes_to_read, error);
2254+
2255+
if (callback(error, buf, current_addr, bytes_to_read,
2256+
bytes_read_for_chunk) == IterationAction::Stop)
2257+
break;
22572258

22582259
bytes_read += bytes_read_for_chunk;
22592260
// If the bytes read in this chunk would cause us to overflow, something

0 commit comments

Comments
 (0)