[Lldb-commits] [lldb] r154683 - /lldb/trunk/source/API/SBValue.cpp

Jim Ingham jingham at apple.com
Fri Apr 13 11:30:20 PDT 2012


Author: jingham
Date: Fri Apr 13 13:30:20 2012
New Revision: 154683

URL: http://llvm.org/viewvc/llvm-project?rev=154683&view=rev
Log:
Couple more places in SBValue where you need to take the run-lock.

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

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=154683&r1=154682&r2=154683&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Fri Apr 13 13:30:20 2012
@@ -293,15 +293,30 @@
 SBType
 SBValue::GetType()
 {
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     SBType sb_type;
     lldb::ValueObjectSP value_sp(GetSP());
     TypeImplSP type_sp;
     if (value_sp)
     {
-        type_sp.reset (new TypeImpl(ClangASTType (value_sp->GetClangAST(), value_sp->GetClangType())));
-        sb_type.SetSP(type_sp);
+        ProcessSP process_sp(value_sp->GetProcessSP());
+        Process::StopLocker stop_locker;
+        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+        {
+            if (log)
+                log->Printf ("SBValue(%p)::GetValueDidChange() => error: process is running", value_sp.get());
+        }
+        else
+        {
+            TargetSP target_sp(value_sp->GetTargetSP());
+            if (target_sp)
+            {
+                Mutex::Locker api_locker (target_sp->GetAPIMutex());
+                type_sp.reset (new TypeImpl(ClangASTType (value_sp->GetClangAST(), value_sp->GetClangType())));
+                sb_type.SetSP(type_sp);
+            }
+        }
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (type_sp)
@@ -453,15 +468,26 @@
     lldb::ValueObjectSP value_sp(GetSP());
     if (value_sp)
     {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
+        ProcessSP process_sp(value_sp->GetProcessSP());
+        Process::StopLocker stop_locker;
+        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
         {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-            if (value_sp->UpdateValueIfNeeded(true))
+            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            if (log)
+                log->Printf ("SBValue(%p)::GetTypeSummary() => error: process is running", value_sp.get());
+        }
+        else
+        {
+            TargetSP target_sp(value_sp->GetTargetSP());
+            if (target_sp)
             {
-                lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
-                if (format_sp)
-                    format.SetSP(format_sp);
+                Mutex::Locker api_locker (target_sp->GetAPIMutex());
+                if (value_sp->UpdateValueIfNeeded(true))
+                {
+                    lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
+                    if (format_sp)
+                        format.SetSP(format_sp);
+                }
             }
         }
     }
@@ -587,13 +613,29 @@
     lldb::ValueObjectSP new_value_sp;
     if (value_sp)
     {
-        TypeImplSP type_sp (type.GetSP());
-        if (type.IsValid())
+        ProcessSP process_sp(value_sp->GetProcessSP());
+        Process::StopLocker stop_locker;
+        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
         {
-            sb_value = SBValue(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(), true));
-            new_value_sp = sb_value.GetSP();
-            if (new_value_sp)
-                new_value_sp->SetName(ConstString(name));
+            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            if (log)
+                log->Printf ("SBValue(%p)::GetTypeSynthetic() => error: process is running", value_sp.get());
+        }
+        else
+        {
+            TargetSP target_sp(value_sp->GetTargetSP());
+            if (target_sp)
+            {
+                Mutex::Locker api_locker (target_sp->GetAPIMutex());
+                TypeImplSP type_sp (type.GetSP());
+                if (type.IsValid())
+                {
+                    sb_value = SBValue(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(), true));
+                    new_value_sp = sb_value.GetSP();
+                    if (new_value_sp)
+                        new_value_sp->SetName(ConstString(name));
+                }
+            }
         }
     }
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));





More information about the lldb-commits mailing list