<rdar://problem/11791234>

Fixed a case where the python interpreter could end up holding onto a previous lldb::SBProcess (probably in lldb.process) when run under Xcode. Prior to this fix, the lldb::SBProcess held onto a shared pointer to a lldb_private::Process. This in turn could cause the process to still have a thread list with stack frames. The stack frames would have module shared pointers in the lldb_private::SymbolContext objects. 

We also had issues with things staying in the shared module list too long when we found things by UUID (we didn't remove the out of date ModuleSP from the global module cache).

Now all of this is fixed and everything goes away between runs.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160140 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index 67027a6..b764e55 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -39,7 +39,7 @@
 
 
 SBProcess::SBProcess () :
-    m_opaque_sp()
+    m_opaque_wp()
 {
 }
 
@@ -49,13 +49,13 @@
 //----------------------------------------------------------------------
 
 SBProcess::SBProcess (const SBProcess& rhs) :
-    m_opaque_sp (rhs.m_opaque_sp)
+    m_opaque_wp (rhs.m_opaque_wp)
 {
 }
 
 
 SBProcess::SBProcess (const lldb::ProcessSP &process_sp) :
-    m_opaque_sp (process_sp)
+    m_opaque_wp (process_sp)
 {
 }
 
@@ -63,7 +63,7 @@
 SBProcess::operator = (const SBProcess& rhs)
 {
     if (this != &rhs)
-        m_opaque_sp = rhs.m_opaque_sp;
+        m_opaque_wp = rhs.m_opaque_wp;
     return *this;
 }
 
@@ -83,26 +83,26 @@
 lldb::ProcessSP
 SBProcess::GetSP() const
 {
-    return m_opaque_sp;
+    return m_opaque_wp.lock();
 }
 
 void
 SBProcess::SetSP (const ProcessSP &process_sp)
 {
-    m_opaque_sp = process_sp;
+    m_opaque_wp = process_sp;
 }
 
 void
 SBProcess::Clear ()
 {
-    m_opaque_sp.reset();
+    m_opaque_wp.reset();
 }
 
 
 bool
 SBProcess::IsValid() const
 {
-    return m_opaque_sp.get() != NULL;
+    return m_opaque_wp.lock().get() != NULL;
 }
 
 bool
@@ -119,7 +119,7 @@
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log) {
         log->Printf ("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...",
-                     m_opaque_sp.get(), 
+                     m_opaque_wp.lock().get(),
                      argv, 
                      envp, 
                      stdin_path ? stdin_path : "NULL",