Clean up the usage of "MasterPlan" status in ThreadPlans.  Only user-initiated plans
should be MasterPlans that want to stay on the plan stack.  So make all plans NOT
MasterPlans by default and then have the SB API's and the CommandObjectThread step
commands set this explicitly.

Also added a "clean up" phase to the Thread::ShouldStop so that if plans get stranded
on the stack, we can remove them.  This is done by adding an IsPlanStale method to the
thread plans, and if the plan can know that it is no longer relevant, it returns true,
and the plan and its sub-plans will get discarded.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156101 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index 91fc998..14ed8b6 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -403,3 +403,30 @@
     }
 
 }
+
+bool
+ThreadPlanStepRange::IsPlanStale ()
+{
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+    FrameComparison frame_order = CompareCurrentFrameToStartFrame();
+    
+    if (frame_order == eFrameCompareOlder)
+    {
+        if (log)
+        {
+            log->Printf("ThreadPlanStepRange::IsPlanStale returning true, we've stepped out.");
+        }
+        return true;
+    }
+    else if (frame_order == eFrameCompareEqual && InSymbol())
+    {
+        // If we are not in a place we should step through, we've gotten stale.
+        // One tricky bit here is that some stubs don't push a frame, so we should.  
+        // check that we are in the same symbol.          
+        if (!InRange())
+        {
+            return true;
+        }
+    }
+    return false;
+}