[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #95007)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 10 10:29:02 PDT 2024


================
@@ -810,6 +809,112 @@ const char *SBProcess::GetBroadcasterClass() {
   return ConstString(Process::GetStaticBroadcasterClass()).AsCString();
 }
 
+lldb::SBAddressRangeList
+SBProcess::FindRangesInMemory(const void *buf, uint64_t size,
+                              SBAddressRangeList &ranges, uint32_t alignment,
+                              uint32_t max_matches) {
+  LLDB_INSTRUMENT_VA(this, buf, size, ranges, alignment, max_matches);
+
+  Log *log = GetLog(LLDBLog::Process);
+  lldb::SBAddressRangeList matches;
+
+  if (alignment == 0) {
+    LLDB_LOGF(log, "SBProcess::%s allignmet is 0, Must be greater than 0.",
+              __FUNCTION__);
+    return matches;
+  }
+
+  if (buf == nullptr) {
+    LLDB_LOGF(log, "SBProcess::%s provided 'buffer' is nullptr.", __FUNCTION__);
+    return matches;
+  }
+
+  if (size == 0) {
+    LLDB_LOGF(log, "SBProcess::%s buffer size is 0.", __FUNCTION__);
+    return matches;
+  }
+
+  if (ranges.GetSize() == 0) {
+    LLDB_LOGF(log, "SBProcess::%s provided 'range' is invalid.", __FUNCTION__);
+    return matches;
+  }
----------------
clayborg wrote:

We should do error checking / logging in one place. Right now we are doing the same checks here and also down the the `lldb_private::Process` methods. We should do them only in `lldb_private::Process` and just let this function call that function and let it do the checking.

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


More information about the lldb-commits mailing list