felipepiovezan wrote:

I was thinking a bit more about the `Destroy` method, which I was not too too 
happy with, and thought about just changing it to be a "Resume" method. 
Something like the below, what do you think?
```
diff --git a/lldb/include/lldb/Target/ExecutionContext.h 
b/lldb/include/lldb/Target/ExecutionContext.h
index a0b064a51cec..e82be46e89a5 100644
--- a/lldb/include/lldb/Target/ExecutionContext.h
+++ b/lldb/include/lldb/Target/ExecutionContext.h
@@ -13,6 +13,7 @@
 
 #include "lldb/Host/ProcessRunLock.h"
 #include "lldb/Target/StackID.h"
+#include "lldb/Utility/Status.h"
 #include "lldb/lldb-private.h"
 
 namespace lldb_private {
@@ -591,10 +592,9 @@ struct StoppedExecutionContext : ExecutionContext {
     other.Clear();
   }
 
-  /// Clears this context, unlocking the ProcessRunLock and returning the
-  /// locked API lock. Like after a move operation, this object is no longer
-  /// usable.
-  [[nodiscard]] std::unique_lock<std::recursive_mutex> Destroy();
+  /// Resumes the process, unlocking all locks and destroying the context. Like
+  /// after a move operation, this object is no longer usable.
+  [[nodiscard]] Status ResumeProcessAndDestroyContext();
 
 private:
   std::unique_lock<std::recursive_mutex> m_api_lock;
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index b07611d388fb..b19efaacc656 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -524,11 +524,7 @@ static Status ResumeNewPlan(StoppedExecutionContext 
exe_ctx,
   Process *process = exe_ctx.GetProcessPtr();
   process->GetThreadList().SetSelectedThreadByID(thread->GetID());
 
-  // Release the run lock but keep the API lock.
-  std::unique_lock<std::recursive_mutex> api_lock = exe_ctx.Destroy();
-  if (process->GetTarget().GetDebugger().GetAsyncExecution())
-    return process->Resume();
-  return process->ResumeSynchronous(nullptr);
+  return exe_ctx.ResumeProcessAndDestroyContext();
 }
 
 void SBThread::StepOver(lldb::RunMode stop_other_threads) {
diff --git a/lldb/source/Target/ExecutionContext.cpp 
b/lldb/source/Target/ExecutionContext.cpp
index 7dc847e097bf..436c68099b0e 100644
--- a/lldb/source/Target/ExecutionContext.cpp
+++ b/lldb/source/Target/ExecutionContext.cpp
@@ -7,6 +7,7 @@
 
//===----------------------------------------------------------------------===//
 
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/StackFrame.h"
@@ -164,10 +165,14 @@ lldb_private::GetStoppedExecutionContext(
                                  std::move(api_lock), std::move(stop_locker));
 }
 
-std::unique_lock<std::recursive_mutex> StoppedExecutionContext::Destroy() {
+Status StoppedExecutionContext::ResumeProcessAndDestroyContext() {
+  lldb::ProcessSP process = GetProcessSP();
   Clear();
-  m_stop_locker = ProcessRunLock::ProcessRunLocker();
-  return std::move(m_api_lock);
+  std::unique_lock<std::recursive_mutex> unlock_api = std::move(m_api_lock);
+  m_stop_locker = Process::StopLocker();
+  if (process->GetTarget().GetDebugger().GetAsyncExecution())
+    return process->Resume();
+  return process->ResumeSynchronous(nullptr);
 }
 
 ExecutionContext::ExecutionContext(ExecutionContextScope *exe_scope_ptr)
```

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

Reply via email to