================
@@ -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));
+ continue;
+ }
+
+ Status status;
+ size_t num_bytes_read =
+ ReadMemoryFromInferior(addr, buffer.data(), len, status);
+ // FIXME: ReadMemoryFromInferior promises to return 0 in case of errors,
but
+ // it doesn't; it never checks for errors.
+ if (status.Fail())
+ num_bytes_read = 0;
+ results.push_back(buffer.take_front(num_bytes_read));
+ buffer = buffer.drop_front(num_bytes_read);
----------------
DavidSpickett wrote:
By the time I reach here it starts to dawn on me that you're "consuming" buffer
as you go. Which is a neat way to do it but earlier it wasn't clear yet. So a
few comments back then would make that clearer.
https://github.com/llvm/llvm-project/pull/163651
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits