Converted the lldb_private::Process over to use the intrusive
shared pointers.

Changed the ExecutionContext over to use shared pointers for
the target, process, thread and frame since these objects can
easily go away at any time and any object that was holding onto
an ExecutionContext was running the risk of using a bad object.

Now that the shared pointers for target, process, thread and
frame are just a single pointer (they all use the instrusive
shared pointers) the execution context is much safer and still
the same size. 

Made the shared pointers in the the ExecutionContext class protected
and made accessors for all of the various ways to get at the pointers,
references, and shared pointers.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140298 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 21acb5b..642463d 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -237,7 +237,7 @@
 bool
 ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors)
 {
-    Process *process = exe_ctx.process;
+    Process *process = exe_ctx.GetProcessPtr();
 
     if (!process)
         return false;
@@ -266,8 +266,8 @@
     
     if (!jit_error.Success())
         return false;
-    if (exe_ctx.process && m_jit_alloc != LLDB_INVALID_ADDRESS)
-        m_jit_process_sp = exe_ctx.process->GetSP();
+    if (process && m_jit_alloc != LLDB_INVALID_ADDRESS)
+        m_jit_process_sp = process->GetSP();
 
     return true;
 }
@@ -299,7 +299,7 @@
     using namespace clang;
     ExecutionResults return_value = eExecutionSetupError;
 
-    Process *process = exe_ctx.process;
+    Process *process = exe_ctx.GetProcessPtr();
 
     if (process == NULL)
         return return_value;
@@ -324,7 +324,7 @@
     }
 
     // TODO: verify fun_addr needs to be a callable address
-    Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.target));
+    Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.GetTargetPtr()));
     int first_offset = m_member_offsets[0];
     process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr, process->GetAddressByteSize(), error);
 
@@ -394,8 +394,8 @@
                                             lldb::addr_t *cmd_arg)
 {
     // FIXME: Use the errors Stream for better error reporting.
-
-    if (exe_ctx.thread == NULL)
+    Thread *thread = exe_ctx.GetThreadPtr();
+    if (thread == NULL)
     {
         errors.Printf("Can't call a function without a valid thread.");
         return NULL;
@@ -404,7 +404,7 @@
     // Okay, now run the function:
 
     Address wrapper_address (NULL, func_addr);
-    ThreadPlan *new_plan = new ThreadPlanCallFunction (*exe_ctx.thread, 
+    ThreadPlan *new_plan = new ThreadPlanCallFunction (*thread, 
                                                        wrapper_address,
                                                        args_addr,
                                                        stop_others, 
@@ -420,7 +420,7 @@
     // Read the return value - it is the last field in the struct:
     // FIXME: How does clang tell us there's no return value?  We need to handle that case.
     
-    Process *process = exe_ctx.process;
+    Process *process = exe_ctx.GetProcessPtr();
     
     if (process == NULL)
         return false;
@@ -446,7 +446,7 @@
     if (pos != m_wrapper_args_addrs.end())
         m_wrapper_args_addrs.erase(pos);
     
-    exe_ctx.process->DeallocateMemory(args_addr);
+    exe_ctx.GetProcessRef().DeallocateMemory(args_addr);
 }
 
 ExecutionResults
@@ -490,16 +490,24 @@
         Stream &errors,
         lldb::addr_t *this_arg)
 {
-    lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg, 
-                                                                               errors, stop_others, discard_on_error, 
-                                                                               this_arg));
+    lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx, 
+                                                                                 function_address, 
+                                                                                 void_arg, 
+                                                                                 errors, 
+                                                                                 stop_others, 
+                                                                                 discard_on_error, 
+                                                                                 this_arg));
     if (call_plan_sp == NULL)
         return eExecutionSetupError;
     
     call_plan_sp->SetPrivate(true);
     
-    return exe_ctx.process->RunThreadPlan (exe_ctx, call_plan_sp, stop_others, try_all_threads, discard_on_error,
-                                            single_thread_timeout_usec, errors);
+    return exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp, 
+                                                  stop_others, 
+                                                  try_all_threads, 
+                                                  discard_on_error,
+                                                  single_thread_timeout_usec, 
+                                                  errors);
 }  
 
 ExecutionResults