Make the ThreadPlanStepThrough set a backstop breakpoint on the return address from
the function it is being asked to step through, so that even if we get the trampoline
target wrong (for instance) we will still not lose control.

The other fix here is to tighten up the handling of the case where the current plan
doesn't explain the stop, but a plan above us does.  In that case, if the plan that
does explain the stop says it is done, we need to clean up the plans below it and 
continue on with our processing.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@145740 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 9d3bd24..b1c1bbc 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -68,6 +68,37 @@
 }
 
 bool
+ThreadPlanStepInRange::PlanExplainsStop ()
+{
+    // We always explain a stop.  Either we've just done a single step, in which
+    // case we'll do our ordinary processing, or we stopped for some
+    // reason that isn't handled by our sub-plans, in which case we want to just stop right
+    // away.
+    
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+    StopInfoSP stop_info_sp = GetPrivateStopReason();
+    if (stop_info_sp)
+    {
+        StopReason reason = stop_info_sp->GetStopReason();
+
+        switch (reason)
+        {
+        case eStopReasonBreakpoint:
+        case eStopReasonWatchpoint:
+        case eStopReasonSignal:
+        case eStopReasonException:
+            if (log)
+                log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
+            SetPlanComplete();
+            break;
+        default:
+            break;
+        }
+    }
+    return true;
+}
+
+bool
 ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
@@ -81,6 +112,9 @@
         log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
     }
 
+    if (IsPlanComplete())
+        return true;
+        
     // If we're still in the range, keep going.
     if (InRange())
         return false;