[Lldb-commits] [lldb] r150871 - in /lldb/trunk: include/lldb/Target/ lldb.xcodeproj/xcshareddata/xcschemes/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Plugins/Disassembler/llvm/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Symbol/ source/Target/ tools/debugserver/debugserver.xcodeproj/xcshareddata/xcschemes/

Greg Clayton gclayton at apple.com
Fri Feb 17 21:35:26 PST 2012


Author: gclayton
Date: Fri Feb 17 23:35:26 2012
New Revision: 150871

URL: http://llvm.org/viewvc/llvm-project?rev=150871&view=rev
Log:
The second part in thread hardening the internals of LLDB where we make
the lldb_private::StackFrame objects hold onto a weak pointer to the thread
object. The lldb_private::StackFrame objects the the most volatile objects
we have as when we are doing single stepping, frames can often get lost or
thrown away, only to be re-created as another object that still refers to the
same frame. We have another bug tracking that. But we need to be able to 
have frames no longer be able to get the thread when they are not part of
a thread anymore, and this is the first step (this fix makes that possible
but doesn't implement it yet).

Also changed lldb_private::ExecutionContextScope to return shared pointers to
all objects in the execution context to further thread harden the internals.



Modified:
    lldb/trunk/include/lldb/Target/ExecutionContextScope.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/include/lldb/Target/RegisterContext.h
    lldb/trunk/include/lldb/Target/StackFrame.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme
    lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme
    lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Core/Address.cpp
    lldb/trunk/source/Core/DataExtractor.cpp
    lldb/trunk/source/Core/EmulateInstruction.cpp
    lldb/trunk/source/Core/ValueObjectRegister.cpp
    lldb/trunk/source/Expression/ClangExpressionParser.cpp
    lldb/trunk/source/Expression/ClangFunction.cpp
    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
    lldb/trunk/source/Symbol/FuncUnwinders.cpp
    lldb/trunk/source/Symbol/Variable.cpp
    lldb/trunk/source/Target/ExecutionContext.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/RegisterContext.cpp
    lldb/trunk/source/Target/StackFrame.cpp
    lldb/trunk/source/Target/StackFrameList.cpp
    lldb/trunk/source/Target/Target.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
    lldb/trunk/tools/debugserver/debugserver.xcodeproj/xcshareddata/xcschemes/debugserver.xcscheme

Modified: lldb/trunk/include/lldb/Target/ExecutionContextScope.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ExecutionContextScope.h?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ExecutionContextScope.h (original)
+++ lldb/trunk/include/lldb/Target/ExecutionContextScope.h Fri Feb 17 23:35:26 2012
@@ -42,16 +42,16 @@
     virtual
     ~ExecutionContextScope () {}
 
-    virtual Target *
+    virtual lldb::TargetSP
     CalculateTarget () = 0;
 
-    virtual Process *
+    virtual lldb::ProcessSP
     CalculateProcess () = 0;
 
-    virtual Thread *
+    virtual lldb::ThreadSP
     CalculateThread () = 0;
 
-    virtual StackFrame *
+    virtual lldb::StackFrameSP
     CalculateStackFrame () = 0;
 
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Fri Feb 17 23:35:26 2012
@@ -3064,28 +3064,25 @@
     //------------------------------------------------------------------
     // lldb::ExecutionContextScope pure virtual functions
     //------------------------------------------------------------------
-    virtual Target *
-    CalculateTarget ()
-    {
-        return &m_target;
-    }
-
-    virtual Process *
+    virtual lldb::TargetSP
+    CalculateTarget ();
+    
+    virtual lldb::ProcessSP
     CalculateProcess ()
     {
-        return this;
+        return shared_from_this();
     }
-
-    virtual Thread *
+    
+    virtual lldb::ThreadSP
     CalculateThread ()
     {
-        return NULL;
+        return lldb::ThreadSP();
     }
-
-    virtual StackFrame *
+    
+    virtual lldb::StackFrameSP
     CalculateStackFrame ()
     {
-        return NULL;
+        return lldb::StackFrameSP();
     }
 
     virtual void

Modified: lldb/trunk/include/lldb/Target/RegisterContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/RegisterContext.h?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/RegisterContext.h (original)
+++ lldb/trunk/include/lldb/Target/RegisterContext.h Fri Feb 17 23:35:26 2012
@@ -157,16 +157,16 @@
     //------------------------------------------------------------------
     // lldb::ExecutionContextScope pure virtual functions
     //------------------------------------------------------------------
-    virtual Target *
+    virtual lldb::TargetSP
     CalculateTarget ();
-
-    virtual Process *
+    
+    virtual lldb::ProcessSP
     CalculateProcess ();
-
-    virtual Thread *
+    
+    virtual lldb::ThreadSP
     CalculateThread ();
-
-    virtual StackFrame *
+    
+    virtual lldb::StackFrameSP
     CalculateStackFrame ();
 
     virtual void

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Fri Feb 17 23:35:26 2012
@@ -41,24 +41,24 @@
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
-    StackFrame (lldb::user_id_t frame_idx, 
+    StackFrame (const lldb::ThreadSP &thread_sp,
+                lldb::user_id_t frame_idx, 
                 lldb::user_id_t concrete_frame_idx, 
-                Thread &thread, 
                 lldb::addr_t cfa, 
                 lldb::addr_t pc, 
                 const SymbolContext *sc_ptr);
 
-    StackFrame (lldb::user_id_t frame_idx, 
+    StackFrame (const lldb::ThreadSP &thread_sp,
+                lldb::user_id_t frame_idx, 
                 lldb::user_id_t concrete_frame_idx, 
-                Thread &thread, 
                 const lldb::RegisterContextSP &reg_context_sp, 
                 lldb::addr_t cfa, 
                 lldb::addr_t pc, 
                 const SymbolContext *sc_ptr);
     
-    StackFrame (lldb::user_id_t frame_idx, 
+    StackFrame (const lldb::ThreadSP &thread_sp,
+                lldb::user_id_t frame_idx, 
                 lldb::user_id_t concrete_frame_idx, 
-                Thread &thread, 
                 const lldb::RegisterContextSP &reg_context_sp, 
                 lldb::addr_t cfa, 
                 const Address& pc, 
@@ -66,13 +66,11 @@
 
     virtual ~StackFrame ();
 
-    Thread &
-    GetThread()
-    { return m_thread; }
-
-    const Thread &
-    GetThread() const
-    { return m_thread; }
+    lldb::ThreadSP
+    GetThread () const
+    {
+        return m_thread_wp.lock();
+    }
 
     StackID&
     GetStackID();
@@ -151,16 +149,16 @@
     //------------------------------------------------------------------
     // lldb::ExecutionContextScope pure virtual functions
     //------------------------------------------------------------------
-    virtual Target *
+    virtual lldb::TargetSP
     CalculateTarget ();
-
-    virtual Process *
+    
+    virtual lldb::ProcessSP
     CalculateProcess ();
-
-    virtual Thread *
+    
+    virtual lldb::ThreadSP
     CalculateThread ();
-
-    virtual StackFrame *
+    
+    virtual lldb::StackFrameSP
     CalculateStackFrame ();
 
     virtual void
@@ -187,11 +185,12 @@
 
     bool
     HasCachedData () const;
+    
 private:
     //------------------------------------------------------------------
     // For StackFrame only
     //------------------------------------------------------------------
-    Thread &m_thread;
+    lldb::ThreadWP m_thread_wp;
     uint32_t m_frame_index;
     uint32_t m_concrete_frame_index;
     lldb::RegisterContextSP m_reg_context_sp;

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Feb 17 23:35:26 2012
@@ -842,16 +842,16 @@
     //------------------------------------------------------------------
     // lldb::ExecutionContextScope pure virtual functions
     //------------------------------------------------------------------
-    virtual Target *
+    virtual lldb::TargetSP
     CalculateTarget ();
-
-    virtual Process *
+    
+    virtual lldb::ProcessSP
     CalculateProcess ();
-
-    virtual Thread *
+    
+    virtual lldb::ThreadSP
     CalculateThread ();
-
-    virtual StackFrame *
+    
+    virtual lldb::StackFrameSP
     CalculateStackFrame ();
 
     virtual void

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Fri Feb 17 23:35:26 2012
@@ -730,16 +730,16 @@
     //------------------------------------------------------------------
     // lldb::ExecutionContextScope pure virtual functions
     //------------------------------------------------------------------
-    virtual Target *
+    virtual lldb::TargetSP
     CalculateTarget ();
-
-    virtual Process *
+    
+    virtual lldb::ProcessSP
     CalculateProcess ();
-
-    virtual Thread *
+    
+    virtual lldb::ThreadSP
     CalculateThread ();
-
-    virtual StackFrame *
+    
+    virtual lldb::StackFrameSP
     CalculateStackFrame ();
 
     virtual void

Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme Fri Feb 17 23:35:26 2012
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   version = "1.3">
+   LastUpgradeVersion = "0430"
+   version = "1.8">
    <BuildAction
       parallelizeBuildables = "NO"
       buildImplicitDependencies = "YES">
@@ -28,6 +29,15 @@
       buildConfiguration = "Debug">
       <Testables>
       </Testables>
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "26F5C26910F3D9A4009D5894"
+            BuildableName = "lldb"
+            BlueprintName = "lldb-tool"
+            ReferencedContainer = "container:lldb.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
       <EnvironmentVariables>
          <EnvironmentVariable
             key = "BLUBBY"
@@ -43,7 +53,10 @@
       displayScale = "1.00"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Debug">
+      buildConfiguration = "Debug"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      allowLocationSimulation = "YES">
       <BuildableProductRunnable>
          <BuildableReference
             BuildableIdentifier = "primary"
@@ -69,7 +82,8 @@
       shouldUseLaunchSchemeArgsEnv = "YES"
       savedToolIdentifier = ""
       useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Release">
+      buildConfiguration = "Release"
+      debugDocumentVersioning = "YES">
       <EnvironmentVariables>
          <EnvironmentVariable
             key = "BLUBBY"

Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme Fri Feb 17 23:35:26 2012
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   version = "1.3">
+   LastUpgradeVersion = "0430"
+   version = "1.8">
    <BuildAction
       parallelizeBuildables = "NO"
       buildImplicitDependencies = "YES">
@@ -37,13 +38,16 @@
       </EnvironmentVariables>
    </TestAction>
    <LaunchAction
-      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
       displayScaleIsEnabled = "NO"
       displayScale = "1.00"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Debug">
+      buildConfiguration = "Debug"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      allowLocationSimulation = "YES">
       <BuildableProductRunnable>
          <BuildableReference
             BuildableIdentifier = "primary"
@@ -69,7 +73,8 @@
       shouldUseLaunchSchemeArgsEnv = "YES"
       savedToolIdentifier = ""
       useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Release">
+      buildConfiguration = "Release"
+      debugDocumentVersioning = "YES">
       <BuildableProductRunnable>
          <BuildableReference
             BuildableIdentifier = "primary"

Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Fri Feb 17 23:35:26 2012
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
+   LastUpgradeVersion = "0430"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Fri Feb 17 23:35:26 2012
@@ -54,7 +54,7 @@
         {
             if (frame_sp)
             {
-                m_thread_wp = frame_sp->GetThread().shared_from_this();
+                m_thread_wp = frame_sp->GetThread();
                 m_stack_id = frame_sp->GetStackID();
             }
         }
@@ -81,11 +81,11 @@
                     // Our frame is still alive, make sure that our thread
                     // still has this exact frame...
                     lldb::StackFrameSP tmp_frame_sp (thread_sp->GetStackFrameAtIndex (frame_sp->GetFrameIndex()));
-                    if (tmp_frame_sp.get() == frame_sp.get())
+                    if (tmp_frame_sp == frame_sp)
                         return frame_sp;
                 }
                 // The original stack frame might have gone away,
-                // we need to check for the stac
+                // we need to check for the frame by stack ID
                 frame_sp = thread_sp->GetFrameWithStackID (m_stack_id);
                 m_frame_wp = frame_sp;
             }
@@ -98,7 +98,7 @@
             if (frame_sp)
             {
                 m_frame_wp = frame_sp;
-                m_thread_wp = frame_sp->GetThread().shared_from_this();
+                m_thread_wp = frame_sp->GetThread();
                 m_stack_id = frame_sp->GetStackID();
             }
             else
@@ -203,17 +203,19 @@
 {
 
     SBSymbolContext sb_sym_ctx;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_sym_ctx.SetSymbolContext(&frame_sp->GetSymbolContext (resolve_scope));
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext (resolve_scope));
     }
 
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)", 
-                     frame_sp.get(), resolve_scope, sb_sym_ctx.get());
+                     frame, resolve_scope, sb_sym_ctx.get());
 
     return sb_sym_ctx;
 }
@@ -223,18 +225,20 @@
 {
     SBModule sb_module;
     ModuleSP module_sp;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        module_sp = frame_sp->GetSymbolContext (eSymbolContextModule).module_sp;
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        module_sp = frame->GetSymbolContext (eSymbolContextModule).module_sp;
         sb_module.SetSP (module_sp);
     }
 
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)", 
-                     frame_sp.get(), module_sp.get());
+                     frame, module_sp.get());
 
     return sb_module;
 }
@@ -243,16 +247,18 @@
 SBFrame::GetCompileUnit () const
 {
     SBCompileUnit sb_comp_unit;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_comp_unit.reset (frame_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_comp_unit.reset (frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetModule () => SBCompileUnit(%p)", 
-                     frame_sp.get(), sb_comp_unit.get());
+                     frame, sb_comp_unit.get());
 
     return sb_comp_unit;
 }
@@ -261,16 +267,18 @@
 SBFrame::GetFunction () const
 {
     SBFunction sb_function;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_function.reset(frame_sp->GetSymbolContext (eSymbolContextFunction).function);
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_function.reset(frame->GetSymbolContext (eSymbolContextFunction).function);
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)", 
-                     frame_sp.get(), sb_function.get());
+                     frame, sb_function.get());
 
     return sb_function;
 }
@@ -279,16 +287,18 @@
 SBFrame::GetSymbol () const
 {
     SBSymbol sb_symbol;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_symbol.reset(frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_symbol.reset(frame->GetSymbolContext (eSymbolContextSymbol).symbol);
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", 
-                     frame_sp.get(), sb_symbol.get());
+                     frame, sb_symbol.get());
     return sb_symbol;
 }
 
@@ -296,16 +306,18 @@
 SBFrame::GetBlock () const
 {
     SBBlock sb_block;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_block.SetPtr (frame_sp->GetSymbolContext (eSymbolContextBlock).block);
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_block.SetPtr (frame->GetSymbolContext (eSymbolContextBlock).block);
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)", 
-                     frame_sp.get(), sb_block.GetPtr());
+                     frame, sb_block.GetPtr());
     return sb_block;
 }
 
@@ -313,16 +325,18 @@
 SBFrame::GetFrameBlock () const
 {
     SBBlock sb_block;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_block.SetPtr(frame_sp->GetFrameBlock ());
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_block.SetPtr(frame->GetFrameBlock ());
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", 
-                     frame_sp.get(), sb_block.GetPtr());
+                     frame, sb_block.GetPtr());
     return sb_block;    
 }
 
@@ -330,16 +344,18 @@
 SBFrame::GetLineEntry () const
 {
     SBLineEntry sb_line_entry;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_line_entry.SetLineEntry (frame_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry);
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_line_entry.SetLineEntry (frame->GetSymbolContext (eSymbolContextLineEntry).line_entry);
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", 
-                     frame_sp.get(), sb_line_entry.get());
+                     frame, sb_line_entry.get());
     return sb_line_entry;
 }
 
@@ -349,14 +365,16 @@
     uint32_t frame_idx = UINT32_MAX;
     
     
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
-        frame_idx = frame_sp->GetFrameIndex ();
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
+        frame_idx = frame->GetFrameIndex ();
     
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::GetFrameID () => %u", 
-                     frame_sp.get(), frame_idx);
+                     frame, frame_idx);
     return frame_idx;
 }
 
@@ -364,16 +382,18 @@
 SBFrame::GetPC () const
 {
     addr_t addr = LLDB_INVALID_ADDRESS;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        addr = frame_sp->GetFrameCodeAddress().GetOpcodeLoadAddress (&frame_sp->GetThread().GetProcess().GetTarget());
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target);
     }
 
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", frame_sp.get(), addr);
+        log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", frame, addr);
 
     return addr;
 }
@@ -382,17 +402,19 @@
 SBFrame::SetPC (addr_t new_pc)
 {
     bool ret_val = false;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        ret_val = frame_sp->GetRegisterContext()->SetPC (new_pc);
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        ret_val = frame->GetRegisterContext()->SetPC (new_pc);
     }
 
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%llx) => %i", 
-                     frame_sp.get(), new_pc, ret_val);
+                     frame, new_pc, ret_val);
 
     return ret_val;
 }
@@ -401,15 +423,17 @@
 SBFrame::GetSP () const
 {
     addr_t addr = LLDB_INVALID_ADDRESS;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        addr = frame_sp->GetRegisterContext()->GetSP();
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        addr = frame->GetRegisterContext()->GetSP();
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", frame_sp.get(), addr);
+        log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", frame, addr);
 
     return addr;
 }
@@ -419,16 +443,18 @@
 SBFrame::GetFP () const
 {
     addr_t addr = LLDB_INVALID_ADDRESS;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        addr = frame_sp->GetRegisterContext()->GetFP();
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        addr = frame->GetRegisterContext()->GetFP();
     }
 
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", frame_sp.get(), addr);
+        log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", frame, addr);
     return addr;
 }
 
@@ -437,15 +463,17 @@
 SBFrame::GetPCAddress () const
 {
     SBAddress sb_addr;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_addr.SetAddress (&frame_sp->GetFrameCodeAddress());
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        sb_addr.SetAddress (&frame->GetFrameCodeAddress());
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", frame_sp.get(), sb_addr.get());
+        log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", frame, sb_addr.get());
     return sb_addr;
 }
 
@@ -459,10 +487,12 @@
 SBFrame::GetValueForVariablePath (const char *var_path)
 {
     SBValue sb_value;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        lldb::DynamicValueType  use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
+        lldb::DynamicValueType  use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
         sb_value = GetValueForVariablePath (var_path, use_dynamic);
     }
     return sb_value;
@@ -472,17 +502,19 @@
 SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic)
 {
     SBValue sb_value;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp && var_path && var_path[0])
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target && var_path && var_path[0])
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
+        Mutex::Locker api_locker (target->GetAPIMutex());
         VariableSP var_sp;
         Error error;
-        ValueObjectSP value_sp (frame_sp->GetValueForVariableExpressionPath (var_path, 
-                                                                             use_dynamic,
-                                                                             StackFrame::eExpressionPathOptionCheckPtrVsMember,
-                                                                             var_sp,
-                                                                             error));
+        ValueObjectSP value_sp (frame->GetValueForVariableExpressionPath (var_path, 
+                                                                          use_dynamic,
+                                                                          StackFrame::eExpressionPathOptionCheckPtrVsMember,
+                                                                          var_sp,
+                                                                          error));
         sb_value.SetSP(value_sp);
     }
     return sb_value;
@@ -492,10 +524,12 @@
 SBFrame::FindVariable (const char *name)
 {
     SBValue value;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        lldb::DynamicValueType  use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
+        lldb::DynamicValueType  use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
         value = FindVariable (name, use_dynamic);
     }
     return value;
@@ -508,12 +542,14 @@
     VariableSP var_sp;
     SBValue sb_value;
     ValueObjectSP value_sp;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp && name && name[0])
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target && name && name[0])
     {
         VariableList variable_list;
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        SymbolContext sc (frame_sp->GetSymbolContext (eSymbolContextBlock));
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
 
         if (sc.block)
         {
@@ -532,7 +568,7 @@
 
         if (var_sp)
         {
-            value_sp = frame_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic);
+            value_sp = frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
             sb_value.SetSP(value_sp);
         }
         
@@ -541,7 +577,7 @@
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)", 
-                     frame_sp.get(), name, value_sp.get());
+                     frame, name, value_sp.get());
 
     return sb_value;
 }
@@ -550,10 +586,12 @@
 SBFrame::FindValue (const char *name, ValueType value_type)
 {
     SBValue value;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
+        lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
         value = FindValue (name, value_type, use_dynamic);
     }
     return value;
@@ -564,10 +602,12 @@
 {
     SBValue sb_value;
     ValueObjectSP value_sp;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp && name && name[0])
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target && name && name[0])
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
+        Mutex::Locker api_locker (target->GetAPIMutex());
     
         switch (value_type)
         {
@@ -576,9 +616,9 @@
         case eValueTypeVariableArgument:    // function argument variables
         case eValueTypeVariableLocal:       // function local variables
             {
-                VariableList *variable_list = frame_sp->GetVariableList(true);
+                VariableList *variable_list = frame->GetVariableList(true);
 
-                SymbolContext sc (frame_sp->GetSymbolContext (eSymbolContextBlock));
+                SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
 
                 const bool can_create = true;
                 const bool get_parent_variables = true;
@@ -598,7 +638,7 @@
                             variable_sp->GetScope() == value_type &&
                             variable_sp->GetName() == const_name)
                         {
-                            value_sp = frame_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic);
+                            value_sp = frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic);
                             sb_value.SetSP (value_sp);
                             break;
                         }
@@ -609,7 +649,7 @@
 
         case eValueTypeRegister:            // stack frame register value
             {
-                RegisterContextSP reg_ctx (frame_sp->GetRegisterContext());
+                RegisterContextSP reg_ctx (frame->GetRegisterContext());
                 if (reg_ctx)
                 {
                     const uint32_t num_regs = reg_ctx->GetRegisterCount();
@@ -620,7 +660,7 @@
                             ((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
                              (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
                         {
-                            value_sp = ValueObjectRegister::Create (frame_sp.get(), reg_ctx, reg_idx);
+                            value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx);
                             sb_value.SetSP (value_sp);
                             break;
                         }
@@ -631,7 +671,7 @@
 
         case eValueTypeRegisterSet:         // A collection of stack frame register values
             {
-                RegisterContextSP reg_ctx (frame_sp->GetRegisterContext());
+                RegisterContextSP reg_ctx (frame->GetRegisterContext());
                 if (reg_ctx)
                 {
                     const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
@@ -642,7 +682,7 @@
                             ((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
                              (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
                         {
-                            value_sp = ValueObjectRegisterSet::Create (frame_sp.get(), reg_ctx, set_idx);
+                            value_sp = ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx);
                             sb_value.SetSP (value_sp);
                             break;
                         }
@@ -654,7 +694,7 @@
         case eValueTypeConstResult:         // constant result variables
             {
                 ConstString const_name(name);
-                ClangExpressionVariableSP expr_var_sp (frame_sp->GetThread().GetProcess().GetTarget().GetPersistentVariables().GetVariable (const_name));
+                ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
                 if (expr_var_sp)
                 {
                     value_sp = expr_var_sp->GetValueObject();
@@ -671,7 +711,7 @@
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)", 
-                     frame_sp.get(), name, value_type, value_sp.get());
+                     frame, name, value_type, value_sp.get());
 
     
     return sb_value;
@@ -694,22 +734,18 @@
 {
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
-    SBThread sb_thread;
-    ThreadSP thread_sp;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
-    {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        thread_sp = frame_sp->GetThread().shared_from_this();
-        sb_thread.SetThread (thread_sp);
-    }
+    ExecutionContext exe_ctx(GetFrameSP());
+    ThreadSP thread_sp (exe_ctx.GetThreadSP());
+    SBThread sb_thread (thread_sp);
 
     if (log)
     {
         SBStream sstr;
         sb_thread.GetDescription (sstr);
-        log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s", frame_sp.get(), 
-                     thread_sp.get(), sstr.GetData());
+        log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s", 
+                     exe_ctx.GetFramePtr(), 
+                     thread_sp.get(), 
+                     sstr.GetData());
     }
 
     return sb_thread;
@@ -719,16 +755,18 @@
 SBFrame::Disassemble () const
 {
     const char *disassembly = NULL;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        disassembly = frame_sp->Disassemble();
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        disassembly = frame->Disassemble();
     }
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (log)
-        log->Printf ("SBFrame(%p)::Disassemble () => %s", frame_sp.get(), disassembly);
+        log->Printf ("SBFrame(%p)::Disassemble () => %s", frame, disassembly);
 
     return disassembly;
 }
@@ -741,10 +779,12 @@
                        bool in_scope_only)
 {
     SBValueList value_list;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
+        lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
         value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
     }
     return value_list;
@@ -760,25 +800,27 @@
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBValueList value_list;
-    StackFrameSP frame_sp(GetFrameSP());
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
 
     if (log)
         log->Printf ("SBFrame(%p)::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)", 
-                     frame_sp.get(), 
+                     frame, 
                      arguments,
                      locals,
                      statics,
                      in_scope_only);
     
-    if (frame_sp)
+    if (frame && target)
     {
 
         size_t i;
         VariableList *variable_list = NULL;
         // Scope for locker
         {
-            Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-            variable_list = frame_sp->GetVariableList(true);
+            Mutex::Locker api_locker (target->GetAPIMutex());
+            variable_list = frame->GetVariableList(true);
         }
         if (variable_list)
         {
@@ -811,10 +853,10 @@
                         }
                         if (add_variable)
                         {
-                            if (in_scope_only && !variable_sp->IsInScope(frame_sp.get()))
+                            if (in_scope_only && !variable_sp->IsInScope(frame))
                                 continue;
 
-                            value_list.Append(frame_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
+                            value_list.Append(frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
                         }
                     }
                 }
@@ -824,7 +866,7 @@
 
     if (log)
     {
-        log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame_sp.get(),
+        log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame,
                      value_list.get());
     }
 
@@ -837,23 +879,25 @@
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBValueList value_list;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        RegisterContextSP reg_ctx (frame_sp->GetRegisterContext());
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        RegisterContextSP reg_ctx (frame->GetRegisterContext());
         if (reg_ctx)
         {
             const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
             for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
             {
-                value_list.Append(ValueObjectRegisterSet::Create (frame_sp.get(), reg_ctx, set_idx));
+                value_list.Append(ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx));
             }
         }
     }
 
     if (log)
-        log->Printf ("SBFrame(%p)::Registers () => SBValueList(%p)", frame_sp.get(), value_list.get());
+        log->Printf ("SBFrame(%p)::Registers () => SBValueList(%p)", frame, value_list.get());
 
     return value_list;
 }
@@ -863,11 +907,13 @@
 {
     Stream &strm = description.ref();
 
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        frame_sp->DumpUsingSettingsFormat (&strm);
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        frame->DumpUsingSettingsFormat (&strm);
     }
     else
         strm.PutCString ("No value");
@@ -879,10 +925,12 @@
 SBFrame::EvaluateExpression (const char *expr)
 {
     SBValue result;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
+        lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
         result = EvaluateExpression (expr, use_dynamic);
     }
     return result;
@@ -899,17 +947,19 @@
     SBValue expr_result;
     ValueObjectSP expr_value_sp;
 
-    StackFrameSP frame_sp(GetFrameSP());
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
     if (log)
-        log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", frame_sp.get(), expr);
+        log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", frame, expr);
 
-    if (frame_sp)
+    if (frame && target)
     {
-        Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
+        Mutex::Locker api_locker (target->GetAPIMutex());
         
         
         StreamString frame_description;
-        frame_sp->DumpUsingSettingsFormat (&frame_description);
+        frame->DumpUsingSettingsFormat (&frame_description);
 
         Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
                                              expr, fetch_dynamic_value, frame_description.GetString().c_str());
@@ -918,14 +968,14 @@
         const bool unwind_on_error = true;
         const bool keep_in_memory = false;
 
-        exe_results = frame_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, 
-                                                                                        frame_sp.get(),
-                                                                                        eExecutionPolicyOnlyWhenNeeded,
-                                                                                        coerce_to_id,
-                                                                                        unwind_on_error, 
-                                                                                        keep_in_memory, 
-                                                                                        fetch_dynamic_value, 
-                                                                                        expr_value_sp);
+        exe_results = target->EvaluateExpression (expr, 
+                                                  frame,
+                                                  eExecutionPolicyOnlyWhenNeeded,
+                                                  coerce_to_id,
+                                                  unwind_on_error, 
+                                                  keep_in_memory, 
+                                                  fetch_dynamic_value, 
+                                                  expr_value_sp);
         expr_result.SetSP(expr_value_sp);
         Host::SetCrashDescription (NULL);
     }
@@ -936,7 +986,8 @@
                          expr_result.GetSummary());
     
     if (log)
-        log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", frame_sp.get(), 
+        log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", 
+                     frame, 
                      expr, 
                      expr_value_sp.get(),
                      exe_results);
@@ -947,10 +998,12 @@
 bool
 SBFrame::IsInlined()
 {
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        Block *block = frame_sp->GetSymbolContext(eSymbolContextBlock).block;
+        Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
         if (block)
             return block->GetContainingInlinedBlock () != NULL;
     }
@@ -961,10 +1014,12 @@
 SBFrame::GetFunctionName()
 {
     const char *name = NULL;
-    StackFrameSP frame_sp(GetFrameSP());
-    if (frame_sp)
+    ExecutionContext exe_ctx(GetFrameSP());
+    StackFrame *frame = exe_ctx.GetFramePtr();
+    Target *target = exe_ctx.GetTargetPtr();
+    if (frame && target)
     {
-        SymbolContext sc (frame_sp->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
+        SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
         if (sc.block)
         {
             Block *inlined_block = sc.block->GetContainingInlinedBlock ();

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Feb 17 23:35:26 2012
@@ -278,8 +278,9 @@
 
                     bool show_frame_info = true;
                     bool show_source = !already_shown;
-                    uint32_t source_lines_before = 3;
-                    uint32_t source_lines_after = 3;
+                    Debugger &debugger = m_interpreter.GetDebugger();
+                    const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true);
+                    const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false);
                     if (frame->GetStatus (result.GetOutputStream(),
                                           show_frame_info,
                                           show_source,

Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Fri Feb 17 23:35:26 2012
@@ -28,12 +28,12 @@
     if (exe_scope == NULL)
         return 0;
 
-    Target *target = exe_scope->CalculateTarget();
-    if (target)
+    TargetSP target_sp (exe_scope->CalculateTarget());
+    if (target_sp)
     {
         Error error;
         bool prefer_file_cache = false;
-        return target->ReadMemory (address, prefer_file_cache, dst, dst_len, error);
+        return target_sp->ReadMemory (address, prefer_file_cache, dst, dst_len, error);
     }
     return 0;
 }
@@ -46,11 +46,11 @@
     if (exe_scope == NULL)
         return false;
 
-    Target *target = exe_scope->CalculateTarget();
-    if (target)
+    TargetSP target_sp (exe_scope->CalculateTarget());
+    if (target_sp)
     {
-        byte_order = target->GetArchitecture().GetByteOrder();
-        addr_size = target->GetArchitecture().GetAddressByteSize();
+        byte_order = target_sp->GetArchitecture().GetByteOrder();
+        addr_size = target_sp->GetArchitecture().GetAddressByteSize();
     }
 
     if (byte_order == eByteOrderInvalid || addr_size == 0)
@@ -362,18 +362,13 @@
     if (m_section == NULL)
         style = DumpStyleLoadAddress;
 
-    Target *target = NULL;
-    Process *process = NULL;
-    if (exe_scope)
-    {
-        target = exe_scope->CalculateTarget();
-        process = exe_scope->CalculateProcess();
-    }
+    ExecutionContext exe_ctx (exe_scope);
+    Target *target = exe_ctx.GetTargetPtr();
     // If addr_byte_size is UINT32_MAX, then determine the correct address
     // byte size for the process or default to the size of addr_t
     if (addr_size == UINT32_MAX)
     {
-        if (process)
+        if (target)
             addr_size = target->GetArchitecture().GetAddressByteSize ();
         else
             addr_size = sizeof(addr_t);
@@ -517,8 +512,8 @@
                             {
                                 SymbolContext func_sc;
                                 target->GetImages().ResolveSymbolContextForAddress (so_addr,
-                                                                                    eSymbolContextEverything,
-                                                                                    func_sc);
+                                                                                             eSymbolContextEverything,
+                                                                                             func_sc);
                                 if (func_sc.function || func_sc.symbol)
                                 {
                                     showed_info = true;
@@ -608,8 +603,8 @@
                                 if (target)
                                 {
                                     target->GetImages().ResolveSymbolContextForAddress (so_addr,
-                                                                                        eSymbolContextEverything,
-                                                                                        pointer_sc);
+                                                                                                 eSymbolContextEverything,
+                                                                                                 pointer_sc);
                                     if (pointer_sc.function || pointer_sc.symbol)
                                     {
                                         s->PutCString(": ");

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Fri Feb 17 23:35:26 2012
@@ -1354,17 +1354,17 @@
 
     if (item_format == eFormatInstruction)
     {
-        Target *target = NULL;
+        TargetSP target_sp;
         if (exe_scope)
-            target = exe_scope->CalculateTarget();
-        if (target)
+            target_sp = exe_scope->CalculateTarget();
+        if (target_sp)
         {
-            DisassemblerSP disassembler_sp (Disassembler::FindPlugin(target->GetArchitecture(), NULL));
+            DisassemblerSP disassembler_sp (Disassembler::FindPlugin(target_sp->GetArchitecture(), NULL));
             if (disassembler_sp)
             {
                 lldb::addr_t addr = base_addr + start_offset;
                 lldb_private::Address so_addr;
-                if (!target->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
+                if (!target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
                 {
                     so_addr.SetOffset(addr);
                     so_addr.SetSection(NULL);
@@ -1724,9 +1724,9 @@
                 s->Printf("0x%*.*llx", 2 * item_byte_size, 2 * item_byte_size, addr);
                 if (exe_scope)
                 {
-                    Target *target = exe_scope->CalculateTarget();
+                    TargetSP target_sp (exe_scope->CalculateTarget());
                     lldb_private::Address so_addr;
-                    if (target && target->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
+                    if (target_sp && target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
                     {
                         s->PutChar(' ');
                         so_addr.Dump (s, 

Modified: lldb/trunk/source/Core/EmulateInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Core/EmulateInstruction.cpp (original)
+++ lldb/trunk/source/Core/EmulateInstruction.cpp Fri Feb 17 23:35:26 2012
@@ -10,7 +10,6 @@
 #include "lldb/Core/EmulateInstruction.h"
 
 #include "lldb/Core/Address.h"
-#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Core/PluginManager.h"
@@ -287,24 +286,20 @@
                                      const Context &context, 
                                      lldb::addr_t addr, 
                                      void *dst,
-                                     size_t length)
+                                     size_t dst_len)
 {
-    if (!baton)
+    if (!baton || dst == NULL || dst_len == 0)
         return 0;
-    
-    
+
     StackFrame *frame = (StackFrame *) baton;
 
-    DataBufferSP data_sp (new DataBufferHeap (length, '\0'));
-    Error error;
-    
-    size_t bytes_read = frame->GetThread().GetProcess().ReadMemory (addr, data_sp->GetBytes(), data_sp->GetByteSize(),
-                                                                    error);
-    
-    if (bytes_read > 0)
-        ((DataBufferHeap *) data_sp.get())->CopyData (dst, length);
-        
-    return bytes_read;
+    ProcessSP process_sp (frame->CalculateProcess());
+    if (process_sp)
+    {
+        Error error;
+        return process_sp->ReadMemory (addr, dst, dst_len, error);
+    }
+    return 0;
 }
 
 size_t 
@@ -312,26 +307,19 @@
                                       void *baton,
                                       const Context &context, 
                                       lldb::addr_t addr, 
-                                      const void *dst,
-                                      size_t length)
+                                      const void *src,
+                                      size_t src_len)
 {
-    if (!baton)
+    if (!baton || src == NULL || src_len == 0)
         return 0;
     
     StackFrame *frame = (StackFrame *) baton;
 
-    lldb::DataBufferSP data_sp (new DataBufferHeap (dst, length));
-    if (data_sp)
+    ProcessSP process_sp (frame->CalculateProcess());
+    if (process_sp)
     {
-        length = data_sp->GetByteSize();
-        if (length > 0)
-        {
-            Error error;
-            size_t bytes_written = frame->GetThread().GetProcess().WriteMemory (addr, data_sp->GetBytes(), length, 
-                                                                                error);
-            
-            return bytes_written;
-        }
+        Error error;
+        return process_sp->WriteMemory (addr, src, src_len, error);
     }
     
     return 0;

Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectRegister.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectRegister.cpp Fri Feb 17 23:35:26 2012
@@ -307,10 +307,11 @@
 {
     if (m_clang_type == NULL)
     {
-        Process *process = m_reg_ctx_sp->CalculateProcess ();
-        if (process)
+        ExecutionContext exe_ctx (GetExecutionContextRef());
+        Target *target = exe_ctx.GetTargetPtr();
+        if (target)
         {
-            Module *exe_module = process->GetTarget().GetExecutableModulePointer();
+            Module *exe_module = target->GetExecutableModulePointer();
             if (exe_module)
             {
                 m_clang_type = exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding, 
@@ -338,10 +339,11 @@
 clang::ASTContext *
 ValueObjectRegister::GetClangAST ()
 {
-    Process *process = m_reg_ctx_sp->CalculateProcess ();
-    if (process)
+    ExecutionContext exe_ctx (GetExecutionContextRef());
+    Target *target = exe_ctx.GetTargetPtr();
+    if (target)
     {
-        Module *exe_module = process->GetTarget().GetExecutableModulePointer();
+        Module *exe_module = target->GetExecutableModulePointer();
         if (exe_module)
             return exe_module->GetClangASTContext().getASTContext();
     }

Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Fri Feb 17 23:35:26 2012
@@ -224,15 +224,15 @@
         break;
     }
     
-    Process *process = NULL;
+    lldb::ProcessSP process_sp;
     if (exe_scope)
-        process = exe_scope->CalculateProcess();
+        process_sp = exe_scope->CalculateProcess();
 
-    if (process && m_compiler->getLangOpts().ObjC1)
+    if (process_sp && m_compiler->getLangOpts().ObjC1)
     {
-        if (process->GetObjCLanguageRuntime())
+        if (process_sp->GetObjCLanguageRuntime())
         {
-            if (process->GetObjCLanguageRuntime()->GetRuntimeVersion() == eAppleObjC_V2)
+            if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == eAppleObjC_V2)
             {
                 m_compiler->getLangOpts().ObjCNonFragileABI = true;     // NOT i386
                 m_compiler->getLangOpts().ObjCNonFragileABI2 = true;    // NOT i386
@@ -256,18 +256,18 @@
     m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
     
     // Set the target triple.
-    Target *target = NULL;
+    lldb::TargetSP target_sp;
     if (exe_scope)
-        target = exe_scope->CalculateTarget();
+        target_sp = exe_scope->CalculateTarget();
 
     // TODO: figure out what to really do when we don't have a valid target.
     // Sometimes this will be ok to just use the host target triple (when we
     // evaluate say "2+3", but other expressions like breakpoint conditions
     // and other things that _are_ target specific really shouldn't just be 
     // using the host triple. This needs to be fixed in a better way.
-    if (target && target->GetArchitecture().IsValid())
+    if (target_sp && target_sp->GetArchitecture().IsValid())
     {
-        std::string triple = target->GetArchitecture().GetTriple().str();
+        std::string triple = target_sp->GetArchitecture().GetTriple().str();
         
         int dash_count = 0;
         for (size_t i = 0; i < triple.size(); ++i)

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Fri Feb 17 23:35:26 2012
@@ -66,11 +66,9 @@
     m_compiled (false),
     m_JITted (false)
 {
-    Process *process = exe_scope.CalculateProcess();
+    m_jit_process_sp = exe_scope.CalculateProcess();
     // Can't make a ClangFunction without a process.
-    assert (process != NULL);
-        
-    m_jit_process_sp = process->shared_from_this();
+    assert (m_jit_process_sp);
 }
 
 ClangFunction::ClangFunction
@@ -91,11 +89,9 @@
     m_compiled (false),
     m_JITted (false)
 {
-    Process *process = exe_scope.CalculateProcess();
+    m_jit_process_sp = exe_scope.CalculateProcess();
     // Can't make a ClangFunction without a process.
-    assert (process != NULL);
-        
-    m_jit_process_sp = process->shared_from_this();
+    assert (m_jit_process_sp);
 
     m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
     m_function_return_qual_type = m_function_ptr->GetReturnClangType();

Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri Feb 17 23:35:26 2012
@@ -106,19 +106,22 @@
         s->Printf("%s ", str.c_str());
 }
 static void
-AddSymbolicInfo (ExecutionContextScope *exe_scope, 
+AddSymbolicInfo (const ExecutionContext *exe_ctx, 
                  StreamString &comment, 
                  uint64_t operand_value, 
                  const Address &inst_addr)
 {
     Address so_addr;
     Target *target = NULL;
-    if (exe_scope)
-        target = exe_scope->CalculateTarget();
+    if (exe_ctx)
+        target = exe_ctx->GetTargetPtr();
     if (target && !target->GetSectionLoadList().IsEmpty())
     {
         if (target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr))
-            so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset);
+            so_addr.Dump (&comment, 
+                          exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL, 
+                          Address::DumpStyleResolvedDescriptionNoModule, 
+                          Address::DumpStyleSectionNameOffset);
     }
     else
     {
@@ -126,7 +129,10 @@
         if (module)
         {
             if (module->ResolveFileAddress(operand_value, so_addr))
-                so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset);
+                so_addr.Dump (&comment, 
+                              exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL, 
+                              Address::DumpStyleResolvedDescriptionNoModule, 
+                              Address::DumpStyleSectionNameOffset);
         }
     }
 }
@@ -166,7 +172,7 @@
     uint32_t max_opcode_byte_size,
     bool show_address,
     bool show_bytes,
-    const lldb_private::ExecutionContext* exe_ctx,
+    const ExecutionContext* exe_ctx,
     bool raw
 )
 {
@@ -336,7 +342,7 @@
                                         comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
                                     }
 
-                                    AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress());
+                                    AddSymbolicInfo(exe_ctx, comment, operand_value, GetAddress());
                                 } // EDEvaluateOperand
                             } // EDOperandIsMemory
                         } // EDGetOperand
@@ -365,7 +371,7 @@
                     uint64_t operand_value = PC + atoi(++pos);
                     // Put the address value into the operands.
                     operands.Printf("0x%8.8llx ", operand_value);
-                    AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress());
+                    AddSymbolicInfo(exe_ctx, comment, operand_value, GetAddress());
                 }
             }
             // Yet more workaround for "bl #..." and "blx #...".
@@ -387,7 +393,7 @@
                     llvm::StringRef Str(pos - 1);
                     RStrip(Str, '\n');
                     operands.PutCString(Str.str().c_str());
-                    AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress());
+                    AddSymbolicInfo(exe_ctx, comment, operand_value, GetAddress());
                 }
             }
             // END of workaround.
@@ -446,10 +452,9 @@
         int currentOpIndex = -1;
         StreamString comment;
         uint32_t addr_nibble_size = 8;
-        addr_t base_addr = LLDB_INVALID_ADDRESS;        
-        Target *target = NULL;
-        if (exe_scope)
-            target = exe_scope->CalculateTarget();
+        addr_t base_addr = LLDB_INVALID_ADDRESS;
+        ExecutionContext exe_ctx (exe_scope);
+        Target *target = exe_ctx.GetTargetPtr();
         if (target && !target->GetSectionLoadList().IsEmpty())
             base_addr = GetAddress().GetLoadAddress (target);
         if (base_addr == LLDB_INVALID_ADDRESS)
@@ -501,7 +506,7 @@
                                 if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra))
                                 {
                                     comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);                                    
-                                    AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress());
+                                    AddSymbolicInfo (&exe_ctx, comment, operand_value, GetAddress());
                                 }
                             }
                         }
@@ -526,7 +531,7 @@
                 uint64_t operand_value = PC + atoi(++pos);
                 // Put the address value into the operands.
                 comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
-                AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress());
+                AddSymbolicInfo (&exe_ctx, comment, operand_value, GetAddress());
             }
         }
         // Yet more workaround for "bl #..." and "blx #...".
@@ -551,7 +556,7 @@
 //                llvm::StringRef Str(pos - 1);
 //                RStrip(Str, '\n');
 //                operands.PutCString(Str.str().c_str());
-                AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress());
+                AddSymbolicInfo (&exe_ctx, comment, operand_value, GetAddress());
             }
         }
         // END of workaround.

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Fri Feb 17 23:35:26 2012
@@ -630,14 +630,16 @@
         
         lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
         
-        Process *process = thread.CalculateProcess();
-        const ABI *abi = process->GetABI().get();
+        const ABI *abi = NULL;
+        ProcessSP process_sp (thread.CalculateProcess());
+        if (process_sp)
+            abi = process_sp->GetABI().get();
         if (abi == NULL)
             return ret_plan_sp;
             
-        Target *target = thread.CalculateTarget();
+        TargetSP target_sp (thread.CalculateTarget());
         
-        ClangASTContext *clang_ast_context = target->GetScratchClangASTContext();
+        ClangASTContext *clang_ast_context = target_sp->GetScratchClangASTContext();
         ValueList argument_values;
         Value void_ptr_value;
         lldb::clang_type_t clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false);
@@ -671,9 +673,8 @@
         if (!success)
             return ret_plan_sp;
             
-        ExecutionContext exe_ctx;
-        thread.CalculateExecutionContext (exe_ctx);
-
+        ExecutionContext exe_ctx (thread.shared_from_this());
+        Process *process = exe_ctx.GetProcessPtr();
         // isa_addr will store the class pointer that the method is being dispatched to - so either the class
         // directly or the super class if this is one of the objc_msgSendSuper flavors.  That's mostly used to
         // look up the class/selector pair in our cache.

Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original)
+++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Fri Feb 17 23:35:26 2012
@@ -166,10 +166,10 @@
     {
         m_tried_unwind_arch_default = true;
         Address current_pc;
-        Target *target = thread.CalculateTarget();
-        if (target)
+        ProcessSP process_sp (thread.CalculateProcess());
+        if (process_sp)
         {
-            ABI *abi = thread.GetProcess().GetABI().get();
+            ABI *abi = process_sp->GetABI().get();
             if (abi)
             {
                 m_unwind_plan_arch_default_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
@@ -202,10 +202,10 @@
     {
         m_tried_unwind_arch_default_at_func_entry = true;
         Address current_pc;
-        Target *target = thread.CalculateTarget();
-        if (target)
+        ProcessSP process_sp (thread.CalculateProcess());
+        if (process_sp)
         {
-            ABI *abi = thread.GetProcess().GetABI().get();
+            ABI *abi = process_sp->GetABI().get();
             if (abi)
             {
                 m_unwind_plan_arch_default_at_func_entry_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Fri Feb 17 23:35:26 2012
@@ -216,19 +216,19 @@
 
     if (frame)
     {
-        Target *target = &frame->GetThread().GetProcess().GetTarget();
-        
         Function *function = frame->GetSymbolContext(eSymbolContextFunction).function;
         if (function)
         {
-            addr_t loclist_base_load_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress (target);
+            TargetSP target_sp (frame->CalculateTarget());
+            
+            addr_t loclist_base_load_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress (target_sp.get());
             if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
                 return false;
             // It is a location list. We just need to tell if the location
             // list contains the current address when converted to a load
             // address
             return m_location.LocationListContainsAddress (loclist_base_load_addr, 
-                                                           frame->GetFrameCodeAddress().GetLoadAddress (target));
+                                                           frame->GetFrameCodeAddress().GetLoadAddress (target_sp.get()));
         }
     }
     return false;

Modified: lldb/trunk/source/Target/ExecutionContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ExecutionContext.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/ExecutionContext.cpp (original)
+++ lldb/trunk/source/Target/ExecutionContext.cpp Fri Feb 17 23:35:26 2012
@@ -343,7 +343,7 @@
     m_frame_sp = frame_sp;
     if (frame_sp)
     {
-        m_thread_sp = frame_sp->GetThread().shared_from_this();
+        m_thread_sp = frame_sp->CalculateThread();
         if (m_thread_sp)
         {
             m_process_sp = m_thread_sp->GetProcess().shared_from_this();

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Feb 17 23:35:26 2012
@@ -3490,6 +3490,12 @@
     return false;
 }
 
+lldb::TargetSP
+Process::CalculateTarget ()
+{
+    return m_target.shared_from_this();
+}
+
 void
 Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
 {

Modified: lldb/trunk/source/Target/RegisterContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/RegisterContext.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/RegisterContext.cpp (original)
+++ lldb/trunk/source/Target/RegisterContext.cpp Fri Feb 17 23:35:26 2012
@@ -356,32 +356,32 @@
 
 }
 
-Target *
+TargetSP
 RegisterContext::CalculateTarget ()
 {
     return m_thread.CalculateTarget();
 }
 
 
-Process *
+ProcessSP
 RegisterContext::CalculateProcess ()
 {
     return m_thread.CalculateProcess ();
 }
 
-Thread *
+ThreadSP
 RegisterContext::CalculateThread ()
 {
-    return &m_thread;
+    return m_thread.shared_from_this();
 }
 
-StackFrame *
+StackFrameSP
 RegisterContext::CalculateStackFrame ()
 {
     // Register contexts might belong to many frames if we have inlined 
     // functions inside a frame since all inlined functions share the
     // same registers, so we can't definitively say which frame we come from...
-    return NULL;
+    return StackFrameSP();
 }
 
 void

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Fri Feb 17 23:35:26 2012
@@ -39,13 +39,13 @@
 #define RESOLVED_VARIABLES              (GOT_FRAME_BASE << 1)
 #define RESOLVED_GLOBAL_VARIABLES       (RESOLVED_VARIABLES << 1)
 
-StackFrame::StackFrame (user_id_t frame_idx, 
+StackFrame::StackFrame (const ThreadSP &thread_sp, 
+                        user_id_t frame_idx, 
                         user_id_t unwind_frame_index, 
-                        Thread &thread, 
                         addr_t cfa, 
                         addr_t pc, 
                         const SymbolContext *sc_ptr) :
-    m_thread (thread),
+    m_thread_wp (thread_sp),
     m_frame_index (frame_idx),
     m_concrete_frame_index (unwind_frame_index),    
     m_reg_context_sp (),
@@ -66,14 +66,14 @@
     }
 }
 
-StackFrame::StackFrame (user_id_t frame_idx, 
+StackFrame::StackFrame (const ThreadSP &thread_sp, 
+                        user_id_t frame_idx, 
                         user_id_t unwind_frame_index, 
-                        Thread &thread, 
                         const RegisterContextSP &reg_context_sp, 
                         addr_t cfa, 
                         addr_t pc, 
                         const SymbolContext *sc_ptr) :
-    m_thread (thread),
+    m_thread_wp (thread_sp),
     m_frame_index (frame_idx),
     m_concrete_frame_index (unwind_frame_index),    
     m_reg_context_sp (reg_context_sp),
@@ -95,23 +95,24 @@
     
     if (reg_context_sp && !m_sc.target_sp)
     {
-        m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().shared_from_this();
-        m_flags.Set (eSymbolContextTarget);
+        m_sc.target_sp = reg_context_sp->CalculateTarget();
+        if (m_sc.target_sp)
+            m_flags.Set (eSymbolContextTarget);
     }
 }
 
-StackFrame::StackFrame (user_id_t frame_idx, 
+StackFrame::StackFrame (const ThreadSP &thread_sp, 
+                        user_id_t frame_idx, 
                         user_id_t unwind_frame_index, 
-                        Thread &thread, 
                         const RegisterContextSP &reg_context_sp, 
                         addr_t cfa, 
                         const Address& pc_addr,
                         const SymbolContext *sc_ptr) :
-    m_thread (thread),
+    m_thread_wp (thread_sp),
     m_frame_index (frame_idx),
     m_concrete_frame_index (unwind_frame_index),    
     m_reg_context_sp (reg_context_sp),
-    m_id (pc_addr.GetLoadAddress (&thread.GetProcess().GetTarget()), cfa, NULL),
+    m_id (pc_addr.GetLoadAddress (&thread_sp->GetProcess().GetTarget()), cfa, NULL),
     m_frame_code_addr (pc_addr),
     m_sc (),
     m_flags (),
@@ -129,8 +130,9 @@
     
     if (m_sc.target_sp.get() == NULL && reg_context_sp)
     {
-        m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().shared_from_this();
-        m_flags.Set (eSymbolContextTarget);
+        m_sc.target_sp = reg_context_sp->CalculateTarget();
+        if (m_sc.target_sp)
+            m_flags.Set (eSymbolContextTarget);
     }
     
     Module *pc_module = pc_addr.GetModulePtr();
@@ -209,18 +211,25 @@
 
         // Resolve the PC into a temporary address because if ResolveLoadAddress
         // fails to resolve the address, it will clear the address object...
-        
-        if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), &m_thread.GetProcess().GetTarget()))
+        ThreadSP thread_sp (GetThread());
+        if (thread_sp)
         {
-            const Section *section = m_frame_code_addr.GetSection();
-            if (section)
+            TargetSP target_sp (thread_sp->CalculateTarget());
+            if (target_sp)
             {
-                Module *module = section->GetModule();
-                if (module)
+                if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get()))
                 {
-                    m_sc.module_sp = module->shared_from_this();
-                    if (m_sc.module_sp)
-                        m_flags.Set(eSymbolContextModule);
+                    const Section *section = m_frame_code_addr.GetSection();
+                    if (section)
+                    {
+                        Module *module = section->GetModule();
+                        if (module)
+                        {
+                            m_sc.module_sp = module->shared_from_this();
+                            if (m_sc.module_sp)
+                                m_flags.Set(eSymbolContextModule);
+                        }
+                    }
                 }
             }
         }
@@ -235,7 +244,9 @@
     m_frame_code_addr.SetSection(NULL);
     m_sc.Clear();
     m_flags.Reset(0);
-    m_thread.ClearStackFrames ();
+    ThreadSP thread_sp (GetThread());
+    if (thread_sp)
+        thread_sp->ClearStackFrames ();
 }
 
 const char *
@@ -243,17 +254,19 @@
 {
     if (m_disassembly.GetSize() == 0)
     {
-        ExecutionContext exe_ctx;
-        CalculateExecutionContext(exe_ctx);
-        Target &target = m_thread.GetProcess().GetTarget();
-        Disassembler::Disassemble (target.GetDebugger(),
-                                   target.GetArchitecture(),
-                                   NULL,
-                                   exe_ctx,
-                                   0,
-                                   0,
-                                   0,
-                                   m_disassembly);
+        ExecutionContext exe_ctx (shared_from_this());
+        Target *target = exe_ctx.GetTargetPtr();
+        if (target)
+        {
+            Disassembler::Disassemble (target->GetDebugger(),
+                                       target->GetArchitecture(),
+                                       NULL,
+                                       exe_ctx,
+                                       0,
+                                       0,
+                                       0,
+                                       m_disassembly);
+        }
         if (m_disassembly.GetSize() == 0)
             return NULL;
     }
@@ -411,13 +424,15 @@
             // If we don't have a module, then we can't have the compile unit,
             // function, block, line entry or symbol, so we can safely call
             // ResolveSymbolContextForAddress with our symbol context member m_sc.
-            resolved |= m_thread.GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
+            TargetSP target_sp (CalculateTarget());
+            if (target_sp)
+                resolved |= target_sp->GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
         }
 
         // If the target was requested add that:
-        if (m_sc.target_sp.get() == NULL)
+        if (!m_sc.target_sp)
         {
-            m_sc.target_sp = CalculateProcess()->GetTarget().shared_from_this();
+            m_sc.target_sp = CalculateTarget();
             if (m_sc.target_sp)
                 resolved |= eSymbolContextTarget;
         }
@@ -1019,11 +1034,11 @@
             m_frame_base_error.Clear();
 
             m_flags.Set(GOT_FRAME_BASE);
-            ExecutionContext exe_ctx (&m_thread.GetProcess(), &m_thread, this);
+            ExecutionContext exe_ctx (shared_from_this());
             Value expr_value;
             addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
             if (m_sc.function->GetFrameBaseExpression().IsLocationList())
-                loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess().GetTarget());
+                loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr());
 
             if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, NULL, NULL, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false)
             {
@@ -1055,7 +1070,11 @@
 StackFrame::GetRegisterContext ()
 {
     if (!m_reg_context_sp)
-        m_reg_context_sp = m_thread.CreateRegisterContextForFrame (this);
+    {
+        ThreadSP thread_sp (GetThread());
+        if (thread_sp)
+            m_reg_context_sp = thread_sp->CreateRegisterContextForFrame (this);
+    }
     return m_reg_context_sp;
 }
 
@@ -1130,36 +1149,47 @@
     return false;
 }
 
-Target *
+TargetSP
 StackFrame::CalculateTarget ()
 {
-    return m_thread.CalculateTarget();
+    TargetSP target_sp;
+    ThreadSP thread_sp(GetThread());
+    if (thread_sp)
+    {
+        ProcessSP process_sp (thread_sp->CalculateProcess());
+        if (process_sp)
+            target_sp = process_sp->CalculateTarget();
+    }
+    return target_sp;
 }
 
-Process *
+ProcessSP
 StackFrame::CalculateProcess ()
 {
-    return m_thread.CalculateProcess();
+    ProcessSP process_sp;
+    ThreadSP thread_sp(GetThread());
+    if (thread_sp)
+        process_sp = thread_sp->CalculateProcess();
+    return process_sp;
 }
 
-Thread *
+ThreadSP
 StackFrame::CalculateThread ()
 {
-    return &m_thread;
+    return GetThread();
 }
 
-StackFrame *
+StackFrameSP
 StackFrame::CalculateStackFrame ()
 {
-    return this;
+    return shared_from_this();
 }
 
 
 void
 StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
 {
-    m_thread.CalculateExecutionContext (exe_ctx);
-    exe_ctx.SetFramePtr(this);
+    exe_ctx.SetContext (shared_from_this());
 }
 
 void
@@ -1169,11 +1199,13 @@
         return;
 
     GetSymbolContext(eSymbolContextEverything);
-    ExecutionContext exe_ctx;
-    CalculateExecutionContext(exe_ctx);
+    ExecutionContext exe_ctx (shared_from_this());
     const char *end = NULL;
     StreamString s;
-    const char *frame_format = m_thread.GetProcess().GetTarget().GetDebugger().GetFrameFormat();
+    const char *frame_format = NULL;
+    Target *target = exe_ctx.GetTargetPtr();
+    if (target)
+        frame_format = target->GetDebugger().GetFrameFormat();
     if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end))
     {
         strm->Write(s.GetData(), s.GetSize());
@@ -1193,11 +1225,20 @@
 
     if (show_frame_index)
         strm->Printf("frame #%u: ", m_frame_index);
-    strm->Printf("0x%0*llx ", m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()));
+    ExecutionContext exe_ctx (shared_from_this());
+    Target *target = exe_ctx.GetTargetPtr();
+    strm->Printf("0x%0*llx ", 
+                 target ? (target->GetArchitecture().GetAddressByteSize() * 2) : 16,
+                 GetFrameCodeAddress().GetLoadAddress(target));
     GetSymbolContext(eSymbolContextEverything);
     const bool show_module = true;
     const bool show_inline = true;
-    m_sc.DumpStopContext(strm, &m_thread.GetProcess(), GetFrameCodeAddress(), show_fullpaths, show_module, show_inline);
+    m_sc.DumpStopContext (strm, 
+                          exe_ctx.GetBestExecutionContextScope(), 
+                          GetFrameCodeAddress(), 
+                          show_fullpaths, 
+                          show_module, 
+                          show_inline);
 }
 
 void
@@ -1216,7 +1257,7 @@
 {
     assert (GetStackID() == curr_frame.GetStackID());        // TODO: remove this after some testing
     m_id.SetPC (curr_frame.m_id.GetPC());       // Update the Stack ID PC value
-    assert (&m_thread == &curr_frame.m_thread);
+    assert (GetThread() == curr_frame.GetThread());
     m_frame_index = curr_frame.m_frame_index;
     m_concrete_frame_index = curr_frame.m_concrete_frame_index;
     m_reg_context_sp = curr_frame.m_reg_context_sp;
@@ -1260,29 +1301,28 @@
     
     if (show_source)
     {
-        Target &target = GetThread().GetProcess().GetTarget();
-        Debugger &debugger = target.GetDebugger();
-        const uint32_t source_before = debugger.GetStopSourceLineCount(true);
-        const uint32_t source_after = debugger.GetStopSourceLineCount(false);
+        ExecutionContext exe_ctx (shared_from_this());
         bool have_source = false;
-        if (source_before || source_after)
+        DebuggerInstanceSettings::StopDisassemblyType disasm_display = DebuggerInstanceSettings::eStopDisassemblyTypeNever;
+        Target *target = exe_ctx.GetTargetPtr();
+        if (target && (source_lines_before || source_lines_after))
         {
             GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
 
             if (m_sc.comp_unit && m_sc.line_entry.IsValid())
             {
-                if (target.GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
-                                                                                 m_sc.line_entry.line,
-                                                                                 source_before,
-                                                                                 source_after,
-                                                                                 "->",
-                                                                                 &strm))
+                if (target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
+                                                                                  m_sc.line_entry.line,
+                                                                                  source_lines_before,
+                                                                                  source_lines_after,
+                                                                                  "->",
+                                                                                  &strm))
                 {
                     have_source = true;
                 }
             }
+            disasm_display = target->GetDebugger().GetStopDisassemblyDisplay ();
         }
-        DebuggerInstanceSettings::StopDisassemblyType disasm_display = debugger.GetStopDisassemblyDisplay ();
         
         switch (disasm_display)
         {
@@ -1294,17 +1334,16 @@
                 break;
             // Fall through to next case
         case DebuggerInstanceSettings::eStopDisassemblyTypeAlways:
+            if (target)
             {
-                const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
+                const uint32_t disasm_lines = target->GetDebugger().GetDisassemblyLineCount();
                 if (disasm_lines > 0)
                 {
-                    const ArchSpec &target_arch = target.GetArchitecture();
+                    const ArchSpec &target_arch = target->GetArchitecture();
                     AddressRange pc_range;
                     pc_range.GetBaseAddress() = GetFrameCodeAddress();
                     pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize());
-                    ExecutionContext exe_ctx;
-                    CalculateExecutionContext(exe_ctx);
-                    Disassembler::Disassemble (debugger,
+                    Disassembler::Disassemble (target->GetDebugger(),
                                                target_arch,
                                                NULL,
                                                exe_ctx,

Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Fri Feb 17 23:35:26 2012
@@ -89,9 +89,9 @@
                     {
                         cfa = m_thread.m_reg_context_sp->GetSP();
                         m_thread.GetRegisterContext();
-                        unwind_frame_sp.reset (new StackFrame (m_frames.size(), 
+                        unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(),
+                                                               m_frames.size(), 
                                                                idx, 
-                                                               m_thread, 
                                                                m_thread.m_reg_context_sp, 
                                                                cfa, 
                                                                m_thread.m_reg_context_sp->GetPC(), 
@@ -108,7 +108,7 @@
                 {
                     const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
                     assert (success);
-                    unwind_frame_sp.reset (new StackFrame (m_frames.size(), idx, m_thread, cfa, pc, NULL));
+                    unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(), m_frames.size(), idx, cfa, pc, NULL));
                     m_frames.push_back (unwind_frame_sp);
                 }
 
@@ -130,9 +130,9 @@
                     
                     while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
                     {
-                            StackFrameSP frame_sp(new StackFrame (m_frames.size(),
+                            StackFrameSP frame_sp(new StackFrame (m_thread.shared_from_this(),
+                                                                  m_frames.size(),
                                                                   idx,
-                                                                  m_thread,
                                                                   unwind_frame_sp->GetRegisterContextSP (),
                                                                   cfa,
                                                                   next_frame_address,
@@ -264,9 +264,9 @@
         // context with the stack frame at index zero.
         m_thread.GetRegisterContext();
         assert (m_thread.m_reg_context_sp.get());
-        frame_sp.reset (new StackFrame (0, 
+        frame_sp.reset (new StackFrame (m_thread.shared_from_this(), 
                                         0, 
-                                        m_thread, 
+                                        0,
                                         m_thread.m_reg_context_sp, 
                                         m_thread.m_reg_context_sp->GetSP(), 
                                         m_thread.m_reg_context_sp->GetPC(), 
@@ -289,7 +289,7 @@
                 addr_t pc, cfa;
                 if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
                 {
-                    frame_sp.reset (new StackFrame (idx, idx, m_thread, cfa, pc, NULL));
+                    frame_sp.reset (new StackFrame (m_thread.shared_from_this(), idx, idx, cfa, pc, NULL));
                     
                     Function *function = frame_sp->GetSymbolContext (eSymbolContextFunction).function;
                     if (function)

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Feb 17 23:35:26 2012
@@ -1286,28 +1286,28 @@
 }
 
 
-Target *
+TargetSP
 Target::CalculateTarget ()
 {
-    return this;
+    return shared_from_this();
 }
 
-Process *
+ProcessSP
 Target::CalculateProcess ()
 {
-    return NULL;
+    return ProcessSP();
 }
 
-Thread *
+ThreadSP
 Target::CalculateThread ()
 {
-    return NULL;
+    return ThreadSP();
 }
 
-StackFrame *
+StackFrameSP
 Target::CalculateStackFrame ()
 {
-    return NULL;
+    return StackFrameSP();
 }
 
 void

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Fri Feb 17 23:35:26 2012
@@ -1015,28 +1015,28 @@
 
 }
 
-Target *
+TargetSP
 Thread::CalculateTarget ()
 {
     return m_process.CalculateTarget();
 }
 
-Process *
+ProcessSP
 Thread::CalculateProcess ()
 {
-    return &m_process;
+    return m_process.shared_from_this();
 }
 
-Thread *
+ThreadSP
 Thread::CalculateThread ()
 {
-    return this;
+    return shared_from_this();
 }
 
-StackFrame *
+StackFrameSP
 Thread::CalculateStackFrame ()
 {
-    return NULL;
+    return StackFrameSP();
 }
 
 void

Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Fri Feb 17 23:35:26 2012
@@ -194,13 +194,13 @@
             if (sc.function)
             {
                 func_start_address = sc.function->GetAddressRange().GetBaseAddress();
-                if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget()))
+                if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget().get()))
                     bytes_to_skip = sc.function->GetPrologueByteSize();
             }
             else if (sc.symbol)
             {
                 func_start_address = sc.symbol->GetValue();
-                if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget()))
+                if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget().get()))
                     bytes_to_skip = sc.symbol->GetPrologueByteSize();
             }
             

Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/xcshareddata/xcschemes/debugserver.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/xcshareddata/xcschemes/debugserver.xcscheme?rev=150871&r1=150870&r2=150871&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/debugserver.xcodeproj/xcshareddata/xcschemes/debugserver.xcscheme (original)
+++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/xcshareddata/xcschemes/debugserver.xcscheme Fri Feb 17 23:35:26 2012
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
+   LastUpgradeVersion = "0430"
    version = "1.8">
    <BuildAction
       parallelizeBuildables = "NO"
@@ -53,6 +54,7 @@
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
       buildConfiguration = "Debug"
+      ignoresPersistentStateOnLaunch = "NO"
       debugDocumentVersioning = "YES"
       allowLocationSimulation = "YES">
       <BuildableProductRunnable>





More information about the lldb-commits mailing list