Skip to content

[lldb][NFC] Address follow up comments in ExecutionContext #153110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

felipepiovezan
Copy link
Contributor

The PR #152020 got merged by accident. This commit addresses some follow up review comments.

The PR llvm#152020 got merged by
accident. This commit addresses some follow up review comments.
@felipepiovezan felipepiovezan requested review from jimingham and removed request for JDevlieghere August 12, 2025 00:09
@llvmbot llvmbot added the lldb label Aug 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 12, 2025

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

Changes

The PR #152020 got merged by accident. This commit addresses some follow up review comments.


Full diff: https://github.com/llvm/llvm-project/pull/153110.diff

3 Files Affected:

  • (modified) lldb/include/lldb/Target/ExecutionContext.h (+3-3)
  • (modified) lldb/source/API/SBThread.cpp (+1-1)
  • (modified) lldb/source/Target/ExecutionContext.cpp (+5-5)
diff --git a/lldb/include/lldb/Target/ExecutionContext.h b/lldb/include/lldb/Target/ExecutionContext.h
index a0b064a51cec4..f105e38fa69aa 100644
--- a/lldb/include/lldb/Target/ExecutionContext.h
+++ b/lldb/include/lldb/Target/ExecutionContext.h
@@ -592,9 +592,9 @@ struct StoppedExecutionContext : ExecutionContext {
   }
 
   /// 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();
+  /// locked API lock, allowing callers to resume the process. Similar to
+  /// a move operation, this object is no longer usable.
+  [[nodiscard]] std::unique_lock<std::recursive_mutex> AllowResume();
 
 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 b07611d388fb6..ec68b2a4b6f31 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -525,7 +525,7 @@ static Status ResumeNewPlan(StoppedExecutionContext exe_ctx,
   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();
+  std::unique_lock<std::recursive_mutex> api_lock = exe_ctx.AllowResume();
   if (process->GetTarget().GetDebugger().GetAsyncExecution())
     return process->Resume();
   return process->ResumeSynchronous(nullptr);
diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp
index 7dc847e097bf8..9d232e420f71c 100644
--- a/lldb/source/Target/ExecutionContext.cpp
+++ b/lldb/source/Target/ExecutionContext.cpp
@@ -138,12 +138,12 @@ lldb_private::GetStoppedExecutionContext(
     const ExecutionContextRef *exe_ctx_ref_ptr) {
   if (!exe_ctx_ref_ptr)
     return llvm::createStringError(
-        "ExecutionContext created with an empty ExecutionContextRef");
+        "StoppedExecutionContext created with an empty ExecutionContextRef");
 
   lldb::TargetSP target_sp = exe_ctx_ref_ptr->GetTargetSP();
   if (!target_sp)
     return llvm::createStringError(
-        "ExecutionContext created with a null target");
+        "StoppedExecutionContext created with a null target");
 
   auto api_lock =
       std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
@@ -151,12 +151,12 @@ lldb_private::GetStoppedExecutionContext(
   auto process_sp = exe_ctx_ref_ptr->GetProcessSP();
   if (!process_sp)
     return llvm::createStringError(
-        "ExecutionContext created with a null process");
+        "StoppedExecutionContext created with a null process");
 
   ProcessRunLock::ProcessRunLocker stop_locker;
   if (!stop_locker.TryLock(&process_sp->GetRunLock()))
     return llvm::createStringError(
-        "attempted to create an ExecutionContext with a running process");
+        "attempted to create a StoppedExecutionContext with a running process");
 
   auto thread_sp = exe_ctx_ref_ptr->GetThreadSP();
   auto frame_sp = exe_ctx_ref_ptr->GetFrameSP();
@@ -164,7 +164,7 @@ lldb_private::GetStoppedExecutionContext(
                                  std::move(api_lock), std::move(stop_locker));
 }
 
-std::unique_lock<std::recursive_mutex> StoppedExecutionContext::Destroy() {
+std::unique_lock<std::recursive_mutex> StoppedExecutionContext::AllowResume() {
   Clear();
   m_stop_locker = ProcessRunLock::ProcessRunLocker();
   return std::move(m_api_lock);

Copy link
Collaborator

@jimingham jimingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@felipepiovezan felipepiovezan merged commit c416034 into llvm:main Aug 12, 2025
11 checks passed
@felipepiovezan felipepiovezan deleted the felipe/execution_ctx_followup branch August 12, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants