================
@@ -1589,6 +1589,48 @@ class Process : public 
std::enable_shared_from_this<Process>,
   size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size,
                                 Status &error);
 
+  // Callback definition for read Memory in chunks
+  //
+  // Status, the status returned from ReadMemoryFromInferior
+  // DataBufferHeap, buffer with bytes potentially written to it
+  // addr_t, the current_addr, start + bytes read so far.
+  // uint64_t bytes_to_read, the expected bytes read, this
+  // is important if it's a partial read
+  // uint64_t bytes_read_for_chunk, the actual count of bytes read for this
+  // chunk
+  typedef std::function<IterationAction(lldb_private::Status &,
+                                        lldb_private::DataBufferHeap &,
+                                        lldb::addr_t, uint64_t, uint64_t)>
+      ReadMemoryChunkCallback;
+
+  /// Read of memory from a process in discrete chunks, terminating
+  /// either when all bytes are read, or the supplied callback returns
+  /// IterationAction::Stop
+  ///
+  /// \param[in] vm_addr
+  ///     A virtual load address that indicates where to start reading
+  ///     memory from.
+  ///
+  /// \param[in] data
+  ///     The data buffer heap to use to read the chunk. The chunk size
+  ///     depends upon the byte size of the buffer.
+  ///
+  /// \param[in] size
+  ///     The number of bytes to read.
+  ///
+  /// \param[in] callback
+  ///     The callback to invoke when a chunk is read from memory.
+  ///
+  /// \return
+  ///     The number of bytes that were actually read into \a buf and
+  ///     written to the provided callback.
+  ///     If the returned number is greater than zero, yet less than \a
+  ///     size, then this function will get called again with \a
+  ///     vm_addr, \a buf, and \a size updated appropriately. Zero is
+  ///     returned in the case of an error.
+  size_t ReadMemoryInChunks(lldb::addr_t vm_addr, DataBufferHeap &data,
+                            size_t size, ReadMemoryChunkCallback callback);
----------------
clayborg wrote:

No need to have people give is a DataBufferHeap, just need the chunk size:
```
size_t ReadMemoryInChunks(lldb::addr_t vm_addr, lldb::offset_t vm_size, 
lldb::offset_t chunk_size, ReadMemoryChunkCallback callback);
```
The `ReadMemoryInChunks` function can create a local DataBufferHeap outside of 
the loop.

https://github.com/llvm/llvm-project/pull/129307
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to