================
@@ -905,6 +907,62 @@ size_t SBProcess::ReadMemory(addr_t addr, void *dst, 
size_t dst_len,
   return bytes_read;
 }
 
+size_t SBProcess::ReadMemory(SBProcessAddress process_addr, void *dst,
+                             size_t dst_len, SBError &sb_error) {
+  LLDB_INSTRUMENT_VA(this, process_addr, dst, dst_len, sb_error);
+
+  if (!dst) {
+    sb_error = Status::FromErrorStringWithFormat(
+        "no buffer provided to read %zu bytes into", dst_len);
+    return 0;
+  }
+
+  size_t bytes_read = 0;
+  ProcessSP process_sp(GetSP());
+
+  if (process_sp) {
+    Process::StopLocker stop_locker;
+    if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+      TargetAPIMutex api_lock = process_sp->GetTarget().GetAPIMutex();
+      std::lock_guard<TargetAPIMutex> guard(api_lock);
+      bytes_read = process_sp->ReadMemory(process_addr.ref(), dst, dst_len,
+                                          sb_error.ref());
+    } else {
+      sb_error = Status::FromErrorString("process is running");
+    }
+  } else {
+    sb_error = Status::FromErrorString("SBProcess is invalid");
+  }
----------------
satyajanga wrote:

this is a copy/paste of above `SBProcess::ReadMemory(addr_t addr,` so was 
trying to keep it similar for better  easy to review.

https://github.com/llvm/llvm-project/pull/214089
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to