[Lldb-commits] [lldb] r272354 - Make all the SBFrame API's take the target lock.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 9 17:37:44 PDT 2016


Author: jingham
Date: Thu Jun  9 19:37:44 2016
New Revision: 272354

URL: http://llvm.org/viewvc/llvm-project?rev=272354&view=rev
Log:
Make all the SBFrame API's take the target lock.

For some reason, the conversion to taking the target lock when acquiring
the ExecutionContext was only done for some of the functions here. That was
allowing lock inversion in some complex uses.

<rdar://problem/26705635>

Modified:
    lldb/trunk/source/API/SBFrame.cpp

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=272354&r1=272353&r2=272354&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Thu Jun  9 19:37:44 2016
@@ -455,7 +455,9 @@ SBFrame::GetFrameID () const
 {
     uint32_t frame_idx = UINT32_MAX;
 
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     if (frame)
         frame_idx = frame->GetFrameIndex ();
@@ -470,7 +472,9 @@ SBFrame::GetFrameID () const
 lldb::addr_t
 SBFrame::GetCFA () const
 {
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     if (frame)
         return frame->GetStackID().GetCallFrameAddress();
@@ -689,7 +693,9 @@ lldb::SBValue
 SBFrame::GetValueForVariablePath (const char *var_path)
 {
     SBValue sb_value;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     Target *target = exe_ctx.GetTargetPtr();
     if (frame && target)
@@ -754,7 +760,9 @@ SBValue
 SBFrame::FindVariable (const char *name)
 {
     SBValue value;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     Target *target = exe_ctx.GetTargetPtr();
     if (frame && target)
@@ -844,7 +852,9 @@ SBValue
 SBFrame::FindValue (const char *name, ValueType value_type)
 {
     SBValue value;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     Target *target = exe_ctx.GetTargetPtr();
     if (frame && target)
@@ -1027,7 +1037,9 @@ SBFrame::GetThread () const
 {
     Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     ThreadSP thread_sp (exe_ctx.GetThreadSP());
     SBThread sb_thread (thread_sp);
 
@@ -1091,7 +1103,9 @@ SBFrame::GetVariables (bool arguments,
                        bool in_scope_only)
 {
     SBValueList value_list;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     Target *target = exe_ctx.GetTargetPtr();
     if (frame && target)
@@ -1119,7 +1133,9 @@ SBFrame::GetVariables (bool arguments,
                        bool in_scope_only,
                        lldb::DynamicValueType  use_dynamic)
 {
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     Target *target = exe_ctx.GetTargetPtr();
     const bool include_runtime_support_values = target ? target->GetDisplayRuntimeSupportValues() : false;
     SBVariablesOptions options;
@@ -1403,7 +1419,9 @@ SBValue
 SBFrame::EvaluateExpression (const char *expr)
 {
     SBValue result;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     Target *target = exe_ctx.GetTargetPtr();
     if (frame && target)
@@ -1429,7 +1447,9 @@ SBFrame::EvaluateExpression (const char
     options.SetFetchDynamicValue (fetch_dynamic_value);
     options.SetUnwindOnError (true);
     options.SetIgnoreBreakpoints (true);
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     Target *target = exe_ctx.GetTargetPtr();
     if (target && target->GetLanguage() != eLanguageTypeUnknown)
@@ -1443,7 +1463,9 @@ SBValue
 SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)
 {
     SBExpressionOptions options;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     options.SetFetchDynamicValue (fetch_dynamic_value);
     options.SetUnwindOnError (unwind_on_error);
     options.SetIgnoreBreakpoints (true);
@@ -1549,7 +1571,9 @@ bool
 SBFrame::IsInlined() const
 {
     Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = nullptr;
     Target *target = exe_ctx.GetTargetPtr();
     Process *process = exe_ctx.GetProcessPtr();
@@ -1593,7 +1617,9 @@ SBFrame::GetFunctionName() const
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     const char *name = nullptr;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = nullptr;
     Target *target = exe_ctx.GetTargetPtr();
     Process *process = exe_ctx.GetProcessPtr();
@@ -1649,7 +1675,10 @@ SBFrame::GetDisplayFunctionName()
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     const char *name = nullptr;
-    ExecutionContext exe_ctx(m_opaque_sp.get());
+
+    std::unique_lock<std::recursive_mutex> lock;
+    ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
     StackFrame *frame = nullptr;
     Target *target = exe_ctx.GetTargetPtr();
     Process *process = exe_ctx.GetProcessPtr();




More information about the lldb-commits mailing list