Switching back to using std::tr1::shared_ptr. We originally switched away
due to RTTI worries since llvm and clang don't use RTTI, but I was able to 
switch back with no issues as far as I can tell. Once the RTTI issue wasn't
an issue, we were looking for a way to properly track weak pointers to objects
to solve some of the threading issues we have been running into which naturally
led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared 
pointer from just a pointer, which is also easily solved using the 
std::tr1::enable_shared_from_this class. 

The main reason for this move back is so we can start properly having weak
references to objects. Currently a lldb_private::Thread class has a refrence
to its parent lldb_private::Process. This doesn't work well when we now hand
out a SBThread object that contains a shared pointer to a lldb_private::Thread
as this SBThread can be held onto by external clients and if they end up
using one of these objects we can easily crash.

So the next task is to start adopting std::tr1::weak_ptr where ever it makes
sense which we can do with lldb_private::Debugger, lldb_private::Target,
lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and
many more objects now that they are no longer using intrusive ref counted
pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive
pointers).



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@149207 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp
index f005965..6e6a806 100644
--- a/source/API/SBAddress.cpp
+++ b/source/API/SBAddress.cpp
@@ -32,7 +32,7 @@
         }
 
         AddressImpl (const Address &addr) :
-            m_module_sp (addr.GetModule()),
+            m_module_sp (addr.GetModuleSP()),
             m_address (addr)
         {
         }
@@ -301,7 +301,7 @@
     {
         Module *module = m_opaque_ap->GetModule();
         if (module)
-            *sb_module = module;
+            *sb_module = module->shared_from_this();
     }
     return sb_module;
 }
diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp
index 62e4a4c..33bdbe0 100644
--- a/source/API/SBBreakpoint.cpp
+++ b/source/API/SBBreakpoint.cpp
@@ -497,14 +497,14 @@
             Process *process = ctx->exe_ctx.GetProcessPtr();
             if (process)
             {
-                SBProcess sb_process (process->GetSP());
+                SBProcess sb_process (process->shared_from_this());
                 SBThread sb_thread;
                 SBBreakpointLocation sb_location;
                 assert (bp_sp);
                 sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id));
                 Thread *thread = ctx->exe_ctx.GetThreadPtr();
                 if (thread)
-                    sb_thread.SetThread(thread->GetSP());
+                    sb_thread.SetThread(thread->shared_from_this());
 
                 return data->callback (data->callback_baton, 
                                           sb_process, 
diff --git a/source/API/SBBreakpointLocation.cpp b/source/API/SBBreakpointLocation.cpp
index 619428e..57cf5a1 100644
--- a/source/API/SBBreakpointLocation.cpp
+++ b/source/API/SBBreakpointLocation.cpp
@@ -301,7 +301,7 @@
     if (m_opaque_sp)
     {
         Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
-        *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
+        *sb_bp = m_opaque_sp->GetBreakpoint ().shared_from_this();
     }
 
     if (log)
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index 3a3c582..c0a6978 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -553,7 +553,7 @@
     if (m_opaque_sp)
     {
         Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
-        sb_thread.SetThread (m_opaque_sp->GetThread().GetSP());
+        sb_thread.SetThread (m_opaque_sp->GetThread().shared_from_this());
     }
 
     if (log)
diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp
index 4e23b9d..f55b214 100644
--- a/source/API/SBFunction.cpp
+++ b/source/API/SBFunction.cpp
@@ -133,10 +133,10 @@
             target->CalculateExecutionContext (exe_ctx);
             exe_ctx.SetProcessSP(target->GetProcessSP());
         }
-        Module *module = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule();
-        if (module)
+        ModuleSP module_sp = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModuleSP();
+        if (module_sp)
         {
-            sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture(),
+            sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture(),
                                                                              NULL,
                                                                              exe_ctx,
                                                                              m_opaque_ptr->GetAddressRange()));
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index aacec52..76c1bad 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -238,7 +238,7 @@
 
     SBTarget sb_target;
     if (m_opaque_sp)
-        sb_target = m_opaque_sp->GetTarget().GetSP();
+        sb_target = m_opaque_sp->GetTarget().shared_from_this();
     
     if (log)
         log->Printf ("SBProcess(%p)::GetTarget () => SBTarget(%p)", m_opaque_sp.get(), sb_target.get());
diff --git a/source/API/SBSection.cpp b/source/API/SBSection.cpp
index ed6dba7..dedcc7a 100644
--- a/source/API/SBSection.cpp
+++ b/source/API/SBSection.cpp
@@ -29,7 +29,7 @@
             m_section (section)
         {
             if (section)
-                m_module_sp = section->GetModule();
+                m_module_sp = section->GetModule()->shared_from_this();
         }
         
         SectionImpl (const SectionImpl &rhs) :
diff --git a/source/API/SBSymbol.cpp b/source/API/SBSymbol.cpp
index 1765dbd..51bb98c 100644
--- a/source/API/SBSymbol.cpp
+++ b/source/API/SBSymbol.cpp
@@ -131,10 +131,10 @@
         const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr();
         if (symbol_range)
         {
-            Module *module = symbol_range->GetBaseAddress().GetModule();
-            if (module)
+            ModuleSP module_sp = symbol_range->GetBaseAddress().GetModuleSP();
+            if (module_sp)
             {
-                sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture (),
+                sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture (),
                                                                                  NULL,
                                                                                  exe_ctx,
                                                                                  *symbol_range));
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 82224a9..f594827 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -119,7 +119,7 @@
 {
     SBDebugger debugger;
     if (m_opaque_sp)
-        debugger.reset (m_opaque_sp->GetDebugger().GetSP());
+        debugger.reset (m_opaque_sp->GetDebugger().shared_from_this());
     return debugger;
 }
 
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index 1ed3fea..87413e0 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -883,7 +883,7 @@
     {
         if (m_opaque_sp->GetExecutionContextScope())
         {
-            result = SBThread(m_opaque_sp->GetExecutionContextScope()->CalculateThread()->GetSP());
+            result = SBThread(m_opaque_sp->GetExecutionContextScope()->CalculateThread()->shared_from_this());
         }
     }
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -905,7 +905,7 @@
     {
         if (m_opaque_sp->GetExecutionContextScope())
         {
-            result.SetFrame (m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame()->GetSP());
+            result.SetFrame (m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame()->shared_from_this());
         }
     }
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));