<rdar://problem/12027563> Making sure that some class of stop-hook commands that involve po'ing objects do not cause an endless recursion

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@161271 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index d75f5eb..f716f67 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -504,13 +504,23 @@
     
     call_plan_sp->SetPrivate(true);
     
-    return exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp, 
-                                                  stop_others, 
-                                                  try_all_threads, 
-                                                  discard_on_error,
-                                                  single_thread_timeout_usec, 
-                                                  errors);
-}  
+    // <rdar://problem/12027563> we need to make sure we record the fact that we are running an expression here
+    // otherwise this fact will fail to be recorded when fetching an Objective-C object description
+    if (exe_ctx.GetProcessPtr())
+        exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
+    
+    ExecutionResults results = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp,
+                                                                      stop_others, 
+                                                                      try_all_threads, 
+                                                                      discard_on_error,
+                                                                      single_thread_timeout_usec, 
+                                                                      errors);
+    
+    if (exe_ctx.GetProcessPtr())
+        exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
+    
+    return results;
+}
 
 ExecutionResults
 ClangFunction::ExecuteFunction(
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 8160174..95a13cf 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -1935,7 +1935,12 @@
         
     if (!m_process_sp)
         return;
-        
+    
+    // <rdar://problem/12027563> make sure we check that we are not stopped because of us running a user expression
+    // since in that case we do not want to run the stop-hooks
+    if (m_process_sp->GetModIDRef().IsLastResumeForUserExpression())
+        return;
+    
     if (m_stop_hooks.empty())
         return;