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/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 84b8bff..1eeeb00 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -590,7 +590,8 @@
                         break;
                     }
 
-                    if (try_all_threads)
+                    if (try_all_threads 
+                        && (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent (event_sp.get())))
                     {
                         
                         call_plan_ptr->SetStopOthers (false);
diff --git a/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
index 2a9754a..4509eb7 100644
--- a/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
@@ -55,6 +55,7 @@
 
 ThreadMacOSX::~ThreadMacOSX ()
 {
+    DestroyThread();
 }
 
 #if defined (__i386__) || defined (__x86_64__)
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 6ee1406..c1b5fa4 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -48,6 +48,7 @@
 ThreadGDBRemote::~ThreadGDBRemote ()
 {
     ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::~ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+    DestroyThread();
 }
 
 
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 *
diff --git a/source/Target/ThreadPlanBase.cpp b/source/Target/ThreadPlanBase.cpp
index 55ef2f7..eceb383 100644
--- a/source/Target/ThreadPlanBase.cpp
+++ b/source/Target/ThreadPlanBase.cpp
@@ -36,7 +36,14 @@
     ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes, eVoteNoOpinion)
 {
     // Set the tracer to a default tracer.
+    // FIXME: need to add a thread settings variable to pix various tracers...
+#define THREAD_PLAN_USE_ASSEMBLY_TRACER 1
+
+#ifdef THREAD_PLAN_USE_ASSEMBLY_TRACER
+    ThreadPlanTracerSP new_tracer_sp (new ThreadPlanAssemblyTracer (m_thread));
+#else
     ThreadPlanTracerSP new_tracer_sp (new ThreadPlanTracer (m_thread));
+#endif
     new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState());
     SetThreadPlanTracer(new_tracer_sp);
 }