[Lldb-commits] [lldb] r270593 - Lock out Process::RunThreadPlan so only one can be in flight at a time.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Tue May 24 11:29:36 PDT 2016

Author: jingham
Date: Tue May 24 13:29:36 2016
New Revision: 270593

URL: http://llvm.org/viewvc/llvm-project?rev=270593&view=rev
Lock out Process::RunThreadPlan so only one can be in flight at a time.

What with all sorts of folks (TSAN, ASAN, queue detection, etc...) trying to
gather info by calling functions down in the lower layers of lldb, we've started
to see people running expressions simultaneously.  The expression evaluation part
is okay, but only one RunThreadPlan can be active at a time.  I added a lock to
enforce that.



Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=270593&r1=270592&r2=270593&view=diff
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue May 24 13:29:36 2016
@@ -3402,6 +3402,7 @@ protected:
     bool m_destroy_in_process;
     bool m_can_interpret_function_calls; // Some targets, e.g the OSX kernel, don't support the ability to modify the stack.
     WarningsCollection          m_warnings_issued;  // A set of object pointers which have already had warnings printed
+    std::mutex                  m_run_thread_plan_lock;
     enum {
         eCanJITDontKnow= 0,

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=270593&r1=270592&r2=270593&view=diff
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue May 24 13:29:36 2016
@@ -771,6 +771,7 @@ Process::Process(lldb::TargetSP target_s
+      m_run_thread_plan_lock(),
@@ -5195,6 +5196,8 @@ Process::RunThreadPlan(ExecutionContext
                        const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager)
     ExpressionResults return_value = eExpressionSetupError;
+    std::lock_guard<std::mutex> run_thread_plan_locker(m_run_thread_plan_lock);
     if (!thread_plan_sp)
@@ -5223,7 +5226,7 @@ Process::RunThreadPlan(ExecutionContext
     // We need to change some of the thread plan attributes for the thread plan runner.  This will restore them
     // when we are done:
     RestorePlanState thread_plan_restorer(thread_plan_sp);
     // We rely on the thread plan we are running returning "PlanCompleted" if when it successfully completes.

More information about the lldb-commits mailing list