================
@@ -2007,6 +2007,123 @@ size_t Process::ReadMemory(addr_t addr, void *buf, 
size_t size, Status &error) {
   }
 }
 
+void Process::DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr,
+                             const uint8_t *buf, size_t size,
+                             AddressRanges &matches, size_t alignment,
+                             size_t max_count) {
+  // Inputs are already validated in FindInMemory() functions.
+  assert(buf != nullptr);
+  assert(size > 0);
+  assert(alignment > 0);
+  assert(max_count > 0);
+  assert(start_addr != LLDB_INVALID_ADDRESS);
+  assert(end_addr != LLDB_INVALID_ADDRESS);
+  assert(start_addr < end_addr);
+
+  lldb::addr_t start = start_addr;
+  while (matches.size() < max_count && (start + size) < end_addr) {
+    const lldb::addr_t found_addr = FindInMemory(start, end_addr, buf, size);
+    if (found_addr == LLDB_INVALID_ADDRESS)
+      break;
+    matches.emplace_back(found_addr, size);
+    start = found_addr + alignment;
+  }
+}
+
+Status Process::FindInMemory(AddressRanges &matches, const uint8_t *buf,
+                             size_t size, const AddressRanges &ranges,
+                             size_t alignment, size_t max_count) {
----------------
clayborg wrote:

Lets mirror the public API here by returning the AddressRanges and taking a 
Status as a reference:
```
AddressRanges Process::FindInMemory(
  const uint8_t *buf, 
  size_t size, 
  const AddressRanges &ranges, 
  size_t alignment, 
 size_t max_count, 
  Status &error)
```

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

Reply via email to