<rdar://problem/13697881>

Fixed the GDB remote with the python OS plug-in to not show core threads when they aren't desired and also to have the threads "to the right thing" when continuing.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179912 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 378d026..72c9a2a 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -542,20 +542,24 @@
     // We distinguish between the plan on the top of the stack and the lower
     // plans in case a plan needs to do any special business before it runs.
     
+    bool need_to_resume = false;
     ThreadPlan *plan_ptr = GetCurrentPlan();
-    bool need_to_resume = plan_ptr->WillResume(resume_state, true);
+    if (plan_ptr)
+    {
+        need_to_resume = plan_ptr->WillResume(resume_state, true);
 
-    while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
-    {
-        plan_ptr->WillResume (resume_state, false);
-    }
-    
-    // If the WillResume for the plan says we are faking a resume, then it will have set an appropriate stop info.
-    // In that case, don't reset it here.
-    
-    if (need_to_resume && resume_state != eStateSuspended)
-    {
-        m_actual_stop_info_sp.reset();
+        while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
+        {
+            plan_ptr->WillResume (resume_state, false);
+        }
+        
+        // If the WillResume for the plan says we are faking a resume, then it will have set an appropriate stop info.
+        // In that case, don't reset it here.
+        
+        if (need_to_resume && resume_state != eStateSuspended)
+        {
+            m_actual_stop_info_sp.reset();
+        }
     }
 
     return need_to_resume;
@@ -571,6 +575,7 @@
 Thread::ShouldStop (Event* event_ptr)
 {
     ThreadPlan *current_plan = GetCurrentPlan();
+    
     bool should_stop = true;
 
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
@@ -955,8 +960,8 @@
 {
     // There will always be at least the base plan.  If somebody is mucking with a
     // thread with an empty plan stack, we should assert right away.
-    assert (!m_plan_stack.empty());
-
+    if (m_plan_stack.empty())
+        return NULL;
     return m_plan_stack.back().get();
 }