Add API and implementation for SBDebugger::Destroy and Debugger::Destroy.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124011 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index eea2ba2..6901fa2 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -83,6 +83,24 @@
     return debugger;
 }
 
+void
+SBDebugger::Destroy (SBDebugger &debugger)
+{
+    LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    if (log)
+    {
+        SBStream sstr;
+        debugger.GetDescription (sstr);
+        log->Printf ("SBDebugger::Destroy () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData());
+    }
+    
+    Debugger::Destroy (debugger.m_opaque_sp);
+    
+    if (debugger.m_opaque_sp.get() != NULL)
+        debugger.m_opaque_sp.reset();
+}
+
 SBDebugger::SBDebugger () :
     m_opaque_sp ()
 {
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index ffb2809..b94489c 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -114,6 +114,26 @@
     return debugger_sp;
 }
 
+void
+Debugger::Destroy (lldb::DebuggerSP &debugger_sp)
+{
+    if (debugger_sp.get() == NULL)
+        return;
+        
+    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() == debugger_sp.get())
+        {
+            debugger_list.erase (pos);
+            return;
+        }
+    }
+
+}
+
 lldb::DebuggerSP
 Debugger::GetSP ()
 {