The thread plan destructors may call Thread virtual methods.  That means they have to get cleaned up in the derived class's destructor.  Make sure that happens.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@119675 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index eccb700..22129d6 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -54,7 +54,8 @@
     m_curr_frames_ap (),
     m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER),
     m_resume_state (eStateRunning),
-    m_unwinder_ap ()
+    m_unwinder_ap (),
+    m_destroy_called (false)
 
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
@@ -71,6 +72,17 @@
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
     if (log)
         log->Printf ("%p Thread::~Thread(tid = 0x%4.4x)", this, GetID());
+    /// If you hit this assert, it means your derived class forgot to call DoDestroy in its destructor.
+    assert (m_destroy_called);
+}
+
+void 
+Thread::DestroyThread ()
+{
+    m_plan_stack.clear();
+    m_discarded_plan_stack.clear();
+    m_completed_plan_stack.clear();
+    m_destroy_called = true;
 }
 
 int
@@ -625,7 +637,6 @@
         }
 
     }
-    // FIXME: What should we do about the immediate plans?
 }
 
 ThreadPlan *