[Lldb-commits] [lldb] [LLDB][Minidump]Update MinidumpFileBuilder to read and write in chunks (PR #129307)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 14 13:16:32 PDT 2025
================
@@ -142,6 +142,13 @@ class MinidumpFileBuilder {
lldb_private::Status AddDirectory(llvm::minidump::StreamType type,
uint64_t stream_size);
lldb::offset_t GetCurrentDataEndOffset() const;
+
+ // Read a memory region from the process and write it to the file
+ // in fixed size chunks.
+ lldb_private::Status ReadWriteMemoryInChunks(
+ const std::unique_ptr<lldb_private::DataBufferHeap> &data_up,
+ const lldb_private::CoreFileMemoryRange &range, uint64_t *bytes_read);
+
----------------
clayborg wrote:
Move this into the PostMortemProcess.h/.cpp and have it take a lambda callback:
```
lldb_private::Status ReadMemoryInChunks(
lldb_private::CoreFileMemoryRange &range,
uint64_t chunk_size,
lldb_private::DataBufferHeap &data, // Re-use between calls if needed, might expand to chunk_size
const std::function<Status(const uint8_t *bytes, uint64_t length)> &chunk_callback,
uint64_t &bytes_read);
```
Then `chunk_callback` gets called for each chunk that is read and your ProcessMinidump can pass in a lambda that just calls `AddData(...)`
There is no need to create a `const std::unique_ptr<lldb_private::DataBufferHeap> &data_up`, just create a local `lldb_private::DataBufferHeap heap(...)`. The unique pointer does nothing useful here
https://github.com/llvm/llvm-project/pull/129307
More information about the lldb-commits
mailing list