Added support for breakpoint conditions.  I also had to separate the "run the expression" part of ClangFunction::Execute from the "Gather the expression result" so that in the case of the Breakpoint condition I can move the condition evaluation into the normal thread plan processing.

Also added support for remembering the "last set breakpoint" so that "break modify" will act on the last set breakpoint.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116542 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index 4aabf52..c1eeb24 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -215,27 +215,18 @@
 }
 
 bool
-ClangUserExpression::Execute (Stream &error_stream,
-                              ExecutionContext &exe_ctx,
-                              ClangExpressionVariable *&result)
+ClangUserExpression::PrepareToExecuteJITExpression (Stream &error_stream,
+                                       ExecutionContext &exe_ctx,
+                                       lldb::addr_t &struct_address,
+                                       lldb::addr_t object_ptr)
 {
     Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
 
-    if (m_dwarf_opcodes.get())
+    if (m_jit_addr != LLDB_INVALID_ADDRESS)
     {
-        // TODO execute the JITted opcodes
-        
-        error_stream.Printf("We don't currently support executing DWARF expressions");
-        
-        return false;
-    }
-    else if (m_jit_addr != LLDB_INVALID_ADDRESS)
-    {
-        lldb::addr_t struct_address;
         
         Error materialize_error;
         
-        lldb::addr_t object_ptr = NULL;
         
         if (m_needs_object_ptr && !(m_expr_decl_map->GetObjectPointer(object_ptr, &exe_ctx, materialize_error)))
         {
@@ -274,6 +265,64 @@
                 }
             }
         }
+    }
+    return true;
+}
+
+ThreadPlan *
+ClangUserExpression::GetThreadPlanToExecuteJITExpression (Stream &error_stream,
+                                       ExecutionContext &exe_ctx)
+{
+    lldb::addr_t struct_address;
+            
+    lldb::addr_t object_ptr = NULL;
+    
+    PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr);
+    
+    return ClangFunction::GetThreadPlanToCallFunction (exe_ctx, 
+                                        m_jit_addr, 
+                                        struct_address, 
+                                        error_stream,
+                                        true,
+                                        true, 
+                                        (m_needs_object_ptr ? &object_ptr : NULL));
+}
+
+bool
+ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
+                                           ExecutionContext &exe_ctx,
+                                           ClangExpressionVariable *&result)
+{
+    Error expr_error;
+    
+    if (!m_expr_decl_map->Dematerialize(&exe_ctx, result, expr_error))
+    {
+        error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error"));
+        return false;
+    }
+    return true;
+}        
+
+bool
+ClangUserExpression::Execute (Stream &error_stream,
+                              ExecutionContext &exe_ctx,
+                              ClangExpressionVariable *&result)
+{
+    if (m_dwarf_opcodes.get())
+    {
+        // TODO execute the JITted opcodes
+        
+        error_stream.Printf("We don't currently support executing DWARF expressions");
+        
+        return false;
+    }
+    else if (m_jit_addr != LLDB_INVALID_ADDRESS)
+    {
+        lldb::addr_t struct_address;
+                
+        lldb::addr_t object_ptr = NULL;
+        
+        PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr);
         
         ClangFunction::ExecutionResults execution_result = 
         ClangFunction::ExecuteFunction (exe_ctx, 
@@ -312,15 +361,7 @@
             return false;
         }
         
-        Error expr_error;
-        
-        if (!m_expr_decl_map->Dematerialize(&exe_ctx, result, expr_error))
-        {
-            error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error"));
-            return false;
-        }
-        
-        return true;
+        return FinalizeJITExecution (error_stream, exe_ctx, result);
     }
     else
     {