[Lldb-commits] [lldb] [lldb] Implement Process::ReadMemoryRanges (PR #163651)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 17 03:06:45 PDT 2025


================
@@ -1971,6 +1971,34 @@ size_t Process::ReadMemory(addr_t addr, void *buf, size_t size, Status &error) {
   }
 }
 
+llvm::SmallVector<llvm::MutableArrayRef<uint8_t>>
+Process::ReadMemoryRanges(llvm::ArrayRef<Range<lldb::addr_t, size_t>> ranges,
+                          llvm::MutableArrayRef<uint8_t> buffer) {
+  llvm::SmallVector<llvm::MutableArrayRef<uint8_t>> results;
+
+  for (auto [addr, len] : ranges) {
+    // This is either a programmer error, or a protocol violation.
+    // In production builds, gracefully fail.
+    assert(buffer.size() >= len);
+    if (buffer.size() < len) {
+      results.push_back(buffer.take_front(0));
----------------
DavidSpickett wrote:

For instance, this is a bit cryptic without a comment.

I suppose it's because there has to be some pointer into the original buffer, but you are returning 0 bytes for this. Perhaps you can use buffer.data instead to make it clear we do not intend to move the start of the buffer at all?

Seeing 0 here makes me wonder if you meant to type another number.

https://github.com/llvm/llvm-project/pull/163651


More information about the lldb-commits mailing list