[Lldb-commits] [lldb] r139985 - in /lldb/trunk: include/lldb/ include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Target/ include/lldb/Utility/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Interpreter/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/ source/Utility/

Greg Clayton gclayton at apple.com
Sat Sep 17 01:33:24 PDT 2011


Author: gclayton
Date: Sat Sep 17 03:33:22 2011
New Revision: 139985

URL: http://llvm.org/viewvc/llvm-project?rev=139985&view=rev
Log:
Adopt the intrusive pointers in:

lldb_private::Breakpoint
lldb_private::BreakpointLocations
lldb_private::BreakpointSite
lldb_private::Debugger
lldb_private::StackFrame
lldb_private::Thread
lldb_private::Target


Modified:
    lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
    lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h
    lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
    lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/include/lldb/Target/StackFrame.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h
    lldb/trunk/include/lldb/Utility/SharingPtr.h
    lldb/trunk/include/lldb/lldb-forward-rtti.h
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
    lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/SearchFilter.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Interpreter/Options.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/StackFrame.cpp
    lldb/trunk/source/Target/Target.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlanTestCondition.cpp
    lldb/trunk/source/Utility/SharingPtr.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Sat Sep 17 03:33:22 2011
@@ -74,6 +74,7 @@
 /// not by the breakpoint.
 //----------------------------------------------------------------------
 class Breakpoint:
+    public ReferenceCountedBase<Breakpoint>,
     public Stoppoint
 {
 public:
@@ -514,21 +515,6 @@
     InvokeCallback (StoppointCallbackContext *context,
                     lldb::break_id_t bp_loc_id);
 
-    //------------------------------------------------------------------
-    /// Returns the shared pointer that this breakpoint holds for the
-    /// breakpoint location passed in as \a bp_loc_ptr.  Passing in a 
-    /// breakpoint location that doesn't belong to this breakpoint will
-    /// cause an assert.
-    ///
-    /// Meant to be used by the BreakpointLocation::GetSP() function.
-    ///
-    /// @return
-    ///     A copy of the shared pointer for the given location.
-    //------------------------------------------------------------------
-    lldb::BreakpointLocationSP
-    GetLocationSP (BreakpointLocation *bp_loc_ptr);
-
-
 protected:
     friend class Target;
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h Sat Sep 17 03:33:22 2011
@@ -46,7 +46,9 @@
 /// would be useful if you've set options on the locations.
 //----------------------------------------------------------------------
 
-class BreakpointLocation : public StoppointLocation
+class BreakpointLocation : 
+    public ReferenceCountedBase<BreakpointLocation>,
+    public StoppointLocation
 {
 public:
 

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Sat Sep 17 03:33:22 2011
@@ -116,7 +116,7 @@
     ///     A thread plan to run to test the condition, or NULL if there is no thread plan.
     //------------------------------------------------------------------
     ThreadPlan *GetThreadPlanToTestCondition (ExecutionContext &exe_ctx, 
-                                              lldb::BreakpointLocationSP break_loc_sp, 
+                                              const lldb::BreakpointLocationSP& break_loc_sp, 
                                               Stream &error);
     
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h Sat Sep 17 03:33:22 2011
@@ -38,7 +38,9 @@
 /// site. Breakpoint sites are owned by the process.
 //----------------------------------------------------------------------
 
-class BreakpointSite : public StoppointLocation
+class BreakpointSite : 
+    public ReferenceCountedBase<BreakpointSite>,
+    public StoppointLocation
 {
 public:
 

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Sat Sep 17 03:33:22 2011
@@ -220,6 +220,7 @@
 
 
 class Debugger :
+    public ReferenceCountedBaseVirtual<Debugger>,
     public UserID,
     public DebuggerInstanceSettings
 {
@@ -275,6 +276,7 @@
     static void
     Destroy (lldb::DebuggerSP &debugger_sp);
 
+    virtual
     ~Debugger ();
     
     void Clear();

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Sat Sep 17 03:33:22 2011
@@ -351,13 +351,13 @@
         ExecutionContextScope *
         GetExecutionContextScope ();
                 
-        lldb::TargetSP
+        const lldb::TargetSP &
         GetTargetSP () const
         {
             return m_target_sp;
         }
         
-        lldb::ProcessSP
+        const lldb::ProcessSP &
         GetProcessSP () const
         {
             return m_process_sp;

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Sat Sep 17 03:33:22 2011
@@ -27,6 +27,7 @@
 namespace lldb_private {
 
 class StackFrame :
+    public ReferenceCountedBaseVirtual<StackFrame>,
     public ExecutionContextScope
 {
 public:

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Sat Sep 17 03:33:22 2011
@@ -123,6 +123,7 @@
 // Target
 //----------------------------------------------------------------------
 class Target :
+    public ReferenceCountedBaseVirtual<Target>,
     public Broadcaster,
     public ExecutionContextScope,
     public TargetInstanceSettings

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Sat Sep 17 03:33:22 2011
@@ -85,6 +85,7 @@
 };
 
 class Thread :
+    public ReferenceCountedBaseVirtual<Thread>,
     public UserID,
     public ExecutionContextScope,
     public ThreadInstanceSettings

Modified: lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h Sat Sep 17 03:33:22 2011
@@ -30,10 +30,10 @@
     virtual ~ThreadPlanTestCondition ();
 
     ThreadPlanTestCondition (Thread &thread,
-                         ExecutionContext &exe_ctx,
-                         ClangUserExpression *expression,
-                         lldb::BreakpointLocationSP break_loc_sp,
-                         bool stop_others);
+                             ExecutionContext &exe_ctx,
+                             ClangUserExpression *expression,
+                             const lldb::BreakpointLocationSP &break_loc_sp,
+                             bool stop_others);
                          
     virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
     virtual bool ValidatePlan (Stream *error);

Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharingPtr.h (original)
+++ lldb/trunk/include/lldb/Utility/SharingPtr.h Sat Sep 17 03:33:22 2011
@@ -16,6 +16,20 @@
 namespace lldb_private {
 
 namespace imp {
+    
+template <class T>
+inline T
+increment(T& t)
+{
+    return __sync_add_and_fetch(&t, 1);
+}
+
+template <class T>
+inline T
+decrement(T& t)
+{
+    return __sync_add_and_fetch(&t, -1);
+}
 
 class shared_count
 {
@@ -540,22 +554,16 @@
 class ReferenceCountedBase
 {
 public:
-    explicit ReferenceCountedBase(long refs = 0)
-        : shared_owners_(refs) 
+    explicit ReferenceCountedBase()
+        : shared_owners_(-1) 
     {
     }
     
     void
-    add_shared()
-    {
-        __sync_add_and_fetch(&shared_owners_, 1);
-    }
+    add_shared();
+
     void
-    release_shared()
-    {
-        if (__sync_add_and_fetch(&shared_owners_, -1) == -1)
-            delete static_cast<T*>(this);
-    }
+    release_shared();
 
     long 
     use_count() const 
@@ -573,54 +581,20 @@
     ReferenceCountedBase& operator=(const ReferenceCountedBase&);
 };
 
+    template <class T>
+    void
+    lldb_private::ReferenceCountedBase<T>::add_shared()
+    {
+        imp::increment(shared_owners_);
+    }
     
-//template <class T>
-//class ReferenceCountedBaseVirtual
-//{
-//public:
-//    explicit ReferenceCountedBaseVirtual(long refs = 0) : 
-//        shared_owners_(refs) 
-//    {
-//    }
-//    
-//    void
-//    add_shared();
-//
-//    void
-//    release_shared();
-//    
-//    long 
-//    use_count() const 
-//    {
-//        return shared_owners_ + 1;
-//    }
-//    
-//protected:
-//    long shared_owners_;
-//    
-//    virtual ~ReferenceCountedBaseVirtual() {}
-//    
-//    friend class IntrusiveSharingPtr<T>;
-//    
-//private:
-//    ReferenceCountedBaseVirtual(const ReferenceCountedBaseVirtual&);
-//    ReferenceCountedBaseVirtual& operator=(const ReferenceCountedBaseVirtual&);
-//};
-//
-//template <class T>
-//void
-//ReferenceCountedBaseVirtual<T>::add_shared()
-//{
-//    __sync_add_and_fetch(&shared_owners_, 1);
-//}
-//
-//template <class T>
-//void
-//ReferenceCountedBaseVirtual<T>::release_shared()
-//{
-//    if (__sync_add_and_fetch(&shared_owners_, -1) == -1)
-//        delete this;
-//}
+    template <class T>
+    void
+    lldb_private::ReferenceCountedBase<T>::release_shared()
+    {
+        if (imp::decrement(shared_owners_) == -1)
+            delete static_cast<T*>(this);
+    }
 
     
 template <class T>

Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward-rtti.h (original)
+++ lldb/trunk/include/lldb/lldb-forward-rtti.h Sat Sep 17 03:33:22 2011
@@ -23,9 +23,9 @@
     typedef SharedPtr<lldb_private::AddressResolver>::Type AddressResolverSP;
     typedef SharedPtr<lldb_private::Baton>::Type BatonSP;
     typedef SharedPtr<lldb_private::Block>::Type BlockSP;
-    typedef SharedPtr<lldb_private::Breakpoint>::Type BreakpointSP;
-    typedef SharedPtr<lldb_private::BreakpointSite>::Type BreakpointSiteSP;
-    typedef SharedPtr<lldb_private::BreakpointLocation>::Type BreakpointLocationSP;
+    typedef IntrusiveSharedPtr<lldb_private::Breakpoint>::Type BreakpointSP;
+    typedef IntrusiveSharedPtr<lldb_private::BreakpointSite>::Type BreakpointSiteSP;
+    typedef IntrusiveSharedPtr<lldb_private::BreakpointLocation>::Type BreakpointLocationSP;
     typedef SharedPtr<lldb_private::BreakpointResolver>::Type BreakpointResolverSP;
     typedef SharedPtr<lldb_private::Broadcaster>::Type BroadcasterSP;
     typedef SharedPtr<lldb_private::ClangExpressionVariable>::Type ClangExpressionVariableSP;
@@ -35,7 +35,7 @@
     typedef SharedPtr<lldb_private::CompileUnit>::Type CompUnitSP;
     typedef SharedPtr<lldb_private::DataBuffer>::Type DataBufferSP;
     typedef SharedPtr<lldb_private::DataExtractor>::Type DataExtractorSP;
-    typedef SharedPtr<lldb_private::Debugger>::Type DebuggerSP;
+    typedef IntrusiveSharedPtr<lldb_private::Debugger>::Type DebuggerSP;
     typedef SharedPtr<lldb_private::Disassembler>::Type DisassemblerSP;
     typedef SharedPtr<lldb_private::DynamicLoader>::Type DynamicLoaderSP;
     typedef SharedPtr<lldb_private::Event>::Type EventSP;
@@ -59,7 +59,7 @@
     typedef SharedPtr<lldb_private::Section>::Type SectionSP;
     typedef SharedPtr<lldb_private::SearchFilter>::Type SearchFilterSP;
     typedef SharedPtr<lldb_private::ScriptSummaryFormat>::Type ScriptFormatSP;
-    typedef SharedPtr<lldb_private::StackFrame>::Type StackFrameSP;
+    typedef IntrusiveSharedPtr<lldb_private::StackFrame>::Type StackFrameSP;
     typedef SharedPtr<lldb_private::StackFrameList>::Type StackFrameListSP;
     typedef SharedPtr<lldb_private::StopInfo>::Type StopInfoSP;
     typedef SharedPtr<lldb_private::StoppointLocation>::Type StoppointLocationSP;
@@ -70,8 +70,8 @@
     typedef SharedPtr<lldb_private::SymbolContextSpecifier>::Type SymbolContextSpecifierSP;
     typedef SharedPtr<lldb_private::SyntheticChildren>::Type SyntheticChildrenSP;
     typedef SharedPtr<lldb_private::SyntheticChildrenFrontEnd>::Type SyntheticChildrenFrontEndSP;
-    typedef SharedPtr<lldb_private::Target>::Type TargetSP;
-    typedef SharedPtr<lldb_private::Thread>::Type ThreadSP;
+    typedef IntrusiveSharedPtr<lldb_private::Target>::Type TargetSP;
+    typedef IntrusiveSharedPtr<lldb_private::Thread>::Type ThreadSP;
     typedef SharedPtr<lldb_private::ThreadPlan>::Type ThreadPlanSP;
     typedef SharedPtr<lldb_private::ThreadPlanTracer>::Type ThreadPlanTracerSP;
     typedef SharedPtr<lldb_private::Type>::Type TypeSP;

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Sat Sep 17 03:33:22 2011
@@ -124,13 +124,6 @@
     return m_locations.GetByIndex(index);
 }
 
-BreakpointLocationSP
-Breakpoint::GetLocationSP (BreakpointLocation *bp_loc_ptr)
-{
-    return m_locations.FindByID(bp_loc_ptr->GetID());
-}
-
-
 // For each of the overall options we need to decide how they propagate to
 // the location options.  This will determine the precedence of options on
 // the breakpoint vrs. its locations.
@@ -567,5 +560,7 @@
 const BreakpointSP
 Breakpoint::GetSP ()
 {
-    return m_target.GetBreakpointList().FindBreakpointByID (GetID());
+    // This object contains an instrusive ref count base class so we can
+    // easily make a shared pointer to this object
+    return BreakpointSP (this);
 }

Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Sat Sep 17 03:33:22 2011
@@ -149,11 +149,11 @@
 ThreadPlan *
 BreakpointLocation::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx, Stream &error)
 {
-    lldb::BreakpointLocationSP my_sp(m_owner.GetLocationSP(this));
+    lldb::BreakpointLocationSP this_sp(this);
     if (m_options_ap.get())
-        return m_options_ap->GetThreadPlanToTestCondition (exe_ctx, my_sp, error);
+        return m_options_ap->GetThreadPlanToTestCondition (exe_ctx, this_sp, error);
     else
-        return m_owner.GetThreadPlanToTestCondition (exe_ctx, my_sp, error);
+        return m_owner.GetThreadPlanToTestCondition (exe_ctx, this_sp, error);
 }
 
 const char *
@@ -259,9 +259,9 @@
     if (m_owner.GetTarget().GetSectionLoadList().IsEmpty())
         return false;
 
-    BreakpointLocationSP myself_sp(m_owner.GetLocationSP (this));
+    BreakpointLocationSP this_sp(this);
 
-    lldb::break_id_t new_id = process->CreateBreakpointSite (myself_sp, false);
+    lldb::break_id_t new_id = process->CreateBreakpointSite (this_sp, false);
 
     if (new_id == LLDB_INVALID_BREAK_ID)
     {

Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Sat Sep 17 03:33:22 2011
@@ -172,7 +172,7 @@
 
 ThreadPlan * 
 BreakpointOptions::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx, 
-                                                 lldb::BreakpointLocationSP break_loc_sp,
+                                                 const BreakpointLocationSP &break_loc_sp,
                                                  Stream &error_stream)
 {
     // No condition means we should stop, so return NULL.

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Sat Sep 17 03:33:22 2011
@@ -574,7 +574,7 @@
 
     if (args.GetArgumentCount() == 0)
     {
-        if (target->GetLastCreatedBreakpoint() != NULL)
+        if (target->GetLastCreatedBreakpoint())
         {
             valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
             result.SetStatus (eReturnStatusSuccessFinishNoResult);

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Sat Sep 17 03:33:22 2011
@@ -152,7 +152,7 @@
 }
 
 void
-Debugger::Destroy (lldb::DebuggerSP &debugger_sp)
+Debugger::Destroy (DebuggerSP &debugger_sp)
 {
     if (debugger_sp.get() == NULL)
         return;
@@ -172,29 +172,18 @@
     }
 }
 
-lldb::DebuggerSP
+DebuggerSP
 Debugger::GetSP ()
 {
-    lldb::DebuggerSP debugger_sp;
-    
-    Mutex::Locker locker (GetDebuggerListMutex ());
-    DebuggerList &debugger_list = GetDebuggerList();
-    DebuggerList::iterator pos, end = debugger_list.end();
-    for (pos = debugger_list.begin(); pos != end; ++pos)
-    {
-        if ((*pos).get() == this)
-        {
-            debugger_sp = *pos;
-            break;
-        }
-    }
-    return debugger_sp;
+    // This object contains an instrusive ref count base class so we can
+    // easily make a shared pointer to this object
+    return DebuggerSP (this);
 }
 
-lldb::DebuggerSP
+DebuggerSP
 Debugger::FindDebuggerWithInstanceName (const ConstString &instance_name)
 {
-    lldb::DebuggerSP debugger_sp;
+    DebuggerSP debugger_sp;
    
     Mutex::Locker locker (GetDebuggerListMutex ());
     DebuggerList &debugger_list = GetDebuggerList();
@@ -214,7 +203,7 @@
 TargetSP
 Debugger::FindTargetWithProcessID (lldb::pid_t pid)
 {
-    lldb::TargetSP target_sp;
+    TargetSP target_sp;
     Mutex::Locker locker (GetDebuggerListMutex ());
     DebuggerList &debugger_list = GetDebuggerList();
     DebuggerList::iterator pos, end = debugger_list.end();
@@ -350,7 +339,7 @@
     ExecutionContext exe_ctx;
     exe_ctx.Clear();
     
-    lldb::TargetSP target_sp = GetSelectedTarget();
+    TargetSP target_sp = GetSelectedTarget();
     exe_ctx.target = target_sp.get();
     
     if (target_sp)
@@ -469,7 +458,7 @@
 }
 
 bool
-Debugger::InputReaderIsTopReader (const lldb::InputReaderSP& reader_sp)
+Debugger::InputReaderIsTopReader (const InputReaderSP& reader_sp)
 {
     InputReaderSP top_reader_sp (GetCurrentInputReader());
 
@@ -531,7 +520,7 @@
 }
 
 bool
-Debugger::PopInputReader (const lldb::InputReaderSP& pop_reader_sp)
+Debugger::PopInputReader (const InputReaderSP& pop_reader_sp)
 {
     bool result = false;
 
@@ -627,7 +616,7 @@
 DebuggerSP
 Debugger::FindDebuggerWithID (lldb::user_id_t id)
 {
-    lldb::DebuggerSP debugger_sp;
+    DebuggerSP debugger_sp;
 
     Mutex::Locker locker (GetDebuggerListMutex ());
     DebuggerList &debugger_list = GetDebuggerList();
@@ -710,7 +699,7 @@
                       const char* var_name_end,
                       const char** var_name_final,
                       const char** percent_position,
-                      lldb::Format* custom_format,
+                      Format* custom_format,
                       ValueObject::ValueObjectRepresentationStyle* val_obj_display)
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
@@ -1033,7 +1022,7 @@
                                 
                                 if (*var_name_begin == 's')
                                 {
-                                    valobj = valobj->GetSyntheticValue(lldb::eUseSyntheticFilter).get();
+                                    valobj = valobj->GetSyntheticValue(eUseSyntheticFilter).get();
                                     var_name_begin++;
                                 }
                                 
@@ -1053,7 +1042,7 @@
                                 options.DontCheckDotVsArrowSyntax().DoAllowBitfieldSyntax().DoAllowFragileIVar().DoAllowSyntheticChildren();
                                 ValueObject::ValueObjectRepresentationStyle val_obj_display = ValueObject::eDisplaySummary;
                                 ValueObject* target = NULL;
-                                lldb::Format custom_format = eFormatInvalid;
+                                Format custom_format = eFormatInvalid;
                                 const char* var_name_final = NULL;
                                 const char* var_name_final_if_array_range = NULL;
                                 const char* close_bracket_position = NULL;
@@ -1847,7 +1836,7 @@
 //--------------------------------------------------
 
 Debugger::SettingsController::SettingsController () :
-    UserSettingsController ("", lldb::UserSettingsControllerSP())
+    UserSettingsController ("", UserSettingsControllerSP())
 {
     m_default_settings.reset (new DebuggerInstanceSettings (*this, false, 
                                                             InstanceSettings::GetDefaultName().AsCString()));
@@ -1858,12 +1847,12 @@
 }
 
 
-lldb::InstanceSettingsSP
+InstanceSettingsSP
 Debugger::SettingsController::CreateInstanceSettings (const char *instance_name)
 {
     DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*GetSettingsController(),
                                                                            false, instance_name);
-    lldb::InstanceSettingsSP new_settings_sp (new_settings);
+    InstanceSettingsSP new_settings_sp (new_settings);
     return new_settings_sp;
 }
 
@@ -1900,7 +1889,7 @@
 
     if (live_instance)
     {
-        const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
+        const InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
         CopyInstanceSettings (pending_settings, false);
     }
 }
@@ -1914,7 +1903,7 @@
     m_use_external_editor (rhs.m_use_external_editor),
     m_auto_confirm_on(rhs.m_auto_confirm_on)
 {
-    const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
+    const InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
     CopyInstanceSettings (pending_settings, false);
     m_owner.RemovePendingSettings (m_instance_name);
 }
@@ -2082,7 +2071,7 @@
 }
 
 void
-DebuggerInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
+DebuggerInstanceSettings::CopyInstanceSettings (const InstanceSettingsSP &new_settings,
                                                 bool pending)
 {
     if (new_settings.get() == NULL)

Modified: lldb/trunk/source/Core/SearchFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Core/SearchFilter.cpp (original)
+++ lldb/trunk/source/Core/SearchFilter.cpp Sat Sep 17 03:33:22 2011
@@ -131,7 +131,7 @@
 {
     SymbolContext empty_sc;
 
-    if (m_target_sp == NULL)
+    if (!m_target_sp)
         return;
     empty_sc.target_sp = m_target_sp;
 
@@ -146,7 +146,7 @@
 {
     SymbolContext empty_sc;
 
-    if (m_target_sp == NULL)
+    if (!m_target_sp)
         return;
     empty_sc.target_sp = m_target_sp;
 

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Sat Sep 17 03:33:22 2011
@@ -75,9 +75,15 @@
     else if (exe_ctx.thread)
         m_parser_vars->m_sym_ctx = exe_ctx.thread->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
     else if (exe_ctx.process)
-        m_parser_vars->m_sym_ctx = SymbolContext(exe_ctx.target->GetSP(), ModuleSP());
+    {
+        m_parser_vars->m_sym_ctx.Clear();
+        m_parser_vars->m_sym_ctx.target_sp = exe_ctx.target;
+    }
     else if (exe_ctx.target)
-        m_parser_vars->m_sym_ctx = SymbolContext(exe_ctx.target->GetSP(), ModuleSP());
+    {
+        m_parser_vars->m_sym_ctx.Clear();
+        m_parser_vars->m_sym_ctx.target_sp = exe_ctx.target;
+    }
     
     if (exe_ctx.target)
         m_parser_vars->m_persistent_vars = &exe_ctx.target->GetPersistentVariables();

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Sat Sep 17 03:33:22 2011
@@ -886,7 +886,7 @@
                     FileSpec module_spec(module_name, false);
                     lldb::TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
                     // Search filters require a target...
-                    if (target_sp != NULL)
+                    if (target_sp)
                         filter_ap.reset (new SearchFilterByModule (target_sp, module_spec));
                 }
                 break;

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Sat Sep 17 03:33:22 2011
@@ -19,6 +19,7 @@
 #include <string>
 
 #include "lldb/API/SBValue.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Timer.h"

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=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Sat Sep 17 03:33:22 2011
@@ -373,7 +373,7 @@
                 if (changed_addr != LLDB_INVALID_ADDRESS)
                 {
                     BreakpointSP trampolines_changed_bp_sp = target.CreateBreakpoint (changed_addr, true);
-                    if (trampolines_changed_bp_sp != NULL)
+                    if (trampolines_changed_bp_sp)
                     {
                         m_trampolines_changed_bp_id = trampolines_changed_bp_sp->GetID();
                         trampolines_changed_bp_sp->SetCallback (RefreshTrampolines, this, true);

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Sat Sep 17 03:33:22 2011
@@ -1416,22 +1416,22 @@
     size_t intersect_size;
     size_t opcode_offset;
     size_t idx;
-    BreakpointSiteSP bp;
+    BreakpointSiteSP bp_sp;
     BreakpointSiteList bp_sites_in_range;
 
     if (m_breakpoint_site_list.FindInRange (bp_addr, bp_addr + size, bp_sites_in_range))
     {
-        for (idx = 0; (bp = bp_sites_in_range.GetByIndex(idx)) != NULL; ++idx)
+        for (idx = 0; (bp_sp = bp_sites_in_range.GetByIndex(idx)); ++idx)
         {
-            if (bp->GetType() == BreakpointSite::eSoftware)
+            if (bp_sp->GetType() == BreakpointSite::eSoftware)
             {
-                if (bp->IntersectsRange(bp_addr, size, &intersect_addr, &intersect_size, &opcode_offset))
+                if (bp_sp->IntersectsRange(bp_addr, size, &intersect_addr, &intersect_size, &opcode_offset))
                 {
                     assert(bp_addr <= intersect_addr && intersect_addr < bp_addr + size);
                     assert(bp_addr < intersect_addr + intersect_size && intersect_addr + intersect_size <= bp_addr + size);
-                    assert(opcode_offset + intersect_size <= bp->GetByteSize());
+                    assert(opcode_offset + intersect_size <= bp_sp->GetByteSize());
                     size_t buf_offset = intersect_addr - bp_addr;
-                    ::memcpy(buf + buf_offset, bp->GetSavedOpcodeBytes() + opcode_offset, intersect_size);
+                    ::memcpy(buf + buf_offset, bp_sp->GetSavedOpcodeBytes() + opcode_offset, intersect_size);
                 }
             }
         }

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Sat Sep 17 03:33:22 2011
@@ -41,11 +41,11 @@
 
 StackFrame::StackFrame 
 (
-    lldb::user_id_t frame_idx, 
-    lldb::user_id_t unwind_frame_index, 
+    user_id_t frame_idx, 
+    user_id_t unwind_frame_index, 
     Thread &thread, 
-    lldb::addr_t cfa, 
-    lldb::addr_t pc, 
+    addr_t cfa, 
+    addr_t pc, 
     const SymbolContext *sc_ptr
 ) :
     m_thread (thread),
@@ -71,12 +71,12 @@
 
 StackFrame::StackFrame 
 (
-    lldb::user_id_t frame_idx, 
-    lldb::user_id_t unwind_frame_index, 
+    user_id_t frame_idx, 
+    user_id_t unwind_frame_index, 
     Thread &thread, 
     const RegisterContextSP &reg_context_sp, 
-    lldb::addr_t cfa, 
-    lldb::addr_t pc, 
+    addr_t cfa, 
+    addr_t pc, 
     const SymbolContext *sc_ptr
 ) :
     m_thread (thread),
@@ -108,11 +108,11 @@
 
 StackFrame::StackFrame 
 (
-    lldb::user_id_t frame_idx, 
-    lldb::user_id_t unwind_frame_index, 
+    user_id_t frame_idx, 
+    user_id_t unwind_frame_index, 
     Thread &thread, 
     const RegisterContextSP &reg_context_sp, 
-    lldb::addr_t cfa, 
+    addr_t cfa, 
     const Address& pc_addr,
     const SymbolContext *sc_ptr
 ) :
@@ -515,9 +515,9 @@
 
 ValueObjectSP
 StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, 
-                                               lldb::DynamicValueType use_dynamic,
+                                               DynamicValueType use_dynamic,
                                                uint32_t options, 
-                                               lldb::VariableSP &var_sp,
+                                               VariableSP &var_sp,
                                                Error &error)
 {
 
@@ -643,7 +643,7 @@
                             if (!child_valobj_sp)
                             {
                                 if (no_synth_child == false)
-                                    child_valobj_sp = valobj_sp->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildMemberWithName (child_name, true);
+                                    child_valobj_sp = valobj_sp->GetSyntheticValue(eUseSyntheticFilter)->GetChildMemberWithName (child_name, true);
                                 
                                 if (no_synth_child || !child_valobj_sp)
                                 {
@@ -667,7 +667,7 @@
                             }
                             // Remove the child name from the path
                             var_path.erase(0, child_name.GetLength());
-                            if (use_dynamic != lldb::eNoDynamicValues)
+                            if (use_dynamic != eNoDynamicValues)
                             {
                                 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
                                 if (dynamic_value_sp)
@@ -728,12 +728,12 @@
                                     if (no_synth_child == false
                                         && 
                                         ClangASTType::GetMinimumLanguage(valobj_sp->GetClangAST(),
-                                                                         valobj_sp->GetClangType()) == lldb::eLanguageTypeObjC /* is ObjC pointer */
+                                                                         valobj_sp->GetClangType()) == eLanguageTypeObjC /* is ObjC pointer */
                                         &&
                                         ClangASTContext::IsPointerType(ClangASTType::GetPointeeType(valobj_sp->GetClangType())) == false /* is not double-ptr */)
                                     {
                                         // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children
-                                        lldb::ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(lldb::eUseSyntheticFilter);
+                                        ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(eUseSyntheticFilter);
                                         if (synthetic.get() == NULL /* no synthetic */
                                             || synthetic == valobj_sp) /* synthetic is the same as the original object */
                                         {
@@ -805,7 +805,7 @@
                                 }
                                 else
                                 {
-                                    lldb::ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(lldb::eUseSyntheticFilter);
+                                    ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(eUseSyntheticFilter);
                                     if (no_synth_child /* synthetic is forbidden */ ||
                                         synthetic.get() == NULL /* no synthetic */
                                         || synthetic == valobj_sp) /* synthetic is the same as the original object */
@@ -847,7 +847,7 @@
                                 // %i is the array index
                                 var_path.erase(0, (end - var_path.c_str()) + 1);
                                 separator_idx = var_path.find_first_of(".-[");
-                                if (use_dynamic != lldb::eNoDynamicValues)
+                                if (use_dynamic != eNoDynamicValues)
                                 {
                                     ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
                                     if (dynamic_value_sp)
@@ -948,7 +948,7 @@
                                 // %i is the index
                                 var_path.erase(0, (real_end - var_path.c_str()) + 1);
                                 separator_idx = var_path.find_first_of(".-[");
-                                if (use_dynamic != lldb::eNoDynamicValues)
+                                if (use_dynamic != eNoDynamicValues)
                                 {
                                     ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
                                     if (dynamic_value_sp)
@@ -1077,7 +1077,7 @@
 
 
 ValueObjectSP
-StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, lldb::DynamicValueType use_dynamic)
+StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
 {
     ValueObjectSP valobj_sp;
     VariableList *var_list = GetVariableList (true);
@@ -1098,7 +1098,7 @@
             }
         }
     }
-    if (use_dynamic != lldb::eNoDynamicValues && valobj_sp)
+    if (use_dynamic != eNoDynamicValues && valobj_sp)
     {
         ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (use_dynamic);
         if (dynamic_sp)
@@ -1108,7 +1108,7 @@
 }
 
 ValueObjectSP
-StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, lldb::DynamicValueType use_dynamic)
+StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
 {
     // Check to make sure we aren't already tracking this variable?
     ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic));
@@ -1254,10 +1254,12 @@
     return false;
 }
 
-lldb::StackFrameSP
+StackFrameSP
 StackFrame::GetSP ()
 {
-    return m_thread.GetStackFrameSPForStackFramePtr (this);
+    // This object contains an instrusive ref count base class so we can
+    // easily make a shared pointer to this object
+    return StackFrameSP (this);
 }
 
 

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Sat Sep 17 03:33:22 2011
@@ -146,7 +146,9 @@
 lldb::TargetSP
 Target::GetSP()
 {
-    return m_debugger.GetTargetList().GetTargetSP(this);
+    // This object contains an instrusive ref count base class so we can
+    // easily make a shared pointer to this object
+    return TargetSP(this);
 }
 
 void

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Sat Sep 17 03:33:22 2011
@@ -970,7 +970,9 @@
 lldb::ThreadSP
 Thread::GetSP ()
 {
-    return m_process.GetThreadList().GetThreadSPForThreadPtr(this);
+    // This object contains an instrusive ref count base class so we can
+    // easily make a shared pointer to this object
+    return ThreadSP(this);
 }
 
 

Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Sat Sep 17 03:33:22 2011
@@ -37,12 +37,11 @@
 // based on the value of \a type.
 //----------------------------------------------------------------------
 
-ThreadPlanTestCondition::ThreadPlanTestCondition (
-        Thread& thread,
-        ExecutionContext &exe_ctx, 
-        ClangUserExpression *expression, 
-        lldb::BreakpointLocationSP break_loc_sp, 
-        bool stop_others) :
+ThreadPlanTestCondition::ThreadPlanTestCondition (Thread& thread,
+                                                  ExecutionContext &exe_ctx, 
+                                                  ClangUserExpression *expression, 
+                                                  const BreakpointLocationSP &break_loc_sp, 
+                                                  bool stop_others) :
     ThreadPlan (ThreadPlan::eKindTestCondition, "test condition", thread, eVoteNoOpinion, eVoteNoOpinion),
     m_expression (expression),
     m_exe_ctx (exe_ctx),

Modified: lldb/trunk/source/Utility/SharingPtr.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/SharingPtr.cpp?rev=139985&r1=139984&r2=139985&view=diff
==============================================================================
--- lldb/trunk/source/Utility/SharingPtr.cpp (original)
+++ lldb/trunk/source/Utility/SharingPtr.cpp Sat Sep 17 03:33:22 2011
@@ -14,19 +14,6 @@
 namespace imp
 {
 
-    template <class T>
-    inline T
-    increment(T& t)
-    {
-        return __sync_add_and_fetch(&t, 1);
-    }
-
-    template <class T>
-    inline T
-    decrement(T& t)
-    {
-        return __sync_add_and_fetch(&t, -1);
-    }
 
     shared_count::~shared_count()
     {





More information about the lldb-commits mailing list