[Lldb-commits] [lldb] r155927 - in /lldb/trunk: include/lldb/Target/ThreadPlan.h include/lldb/Target/ThreadPlanStepInRange.h include/lldb/Target/ThreadPlanStepOverRange.h include/lldb/Target/ThreadPlanStepRange.h source/Target/Thread.cpp source/Target/ThreadPlan.cpp source/Target/ThreadPlanStepInRange.cpp source/Target/ThreadPlanStepOverRange.cpp source/Target/ThreadPlanStepRange.cpp

Jim Ingham jingham at apple.com
Tue May 1 11:38:37 PDT 2012


Author: jingham
Date: Tue May  1 13:38:37 2012
New Revision: 155927

URL: http://llvm.org/viewvc/llvm-project?rev=155927&view=rev
Log:
Fix reporting of stop reasons when the StepOver & StepIn plans stop because of a crash or breakpoint.  Added the ability for a plan to say it is done but doesn't want to be the reason for the stop.

Modified:
    lldb/trunk/include/lldb/Target/ThreadPlan.h
    lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h
    lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h
    lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlan.cpp
    lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
    lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp
    lldb/trunk/source/Target/ThreadPlanStepRange.cpp

Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlan.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlan.h Tue May  1 13:38:37 2012
@@ -142,6 +142,16 @@
 //  all threads will be called, the stop event is placed on the Process's public broadcaster, and
 //  control returns to the upper layers of the debugger.
 //
+//  Reporting the stop:
+//
+//  When the process stops, the thread is given a StopReason, in the form of a StopInfo object.  If there is a completed
+//  plan corresponding to the stop, then the "actual" stop reason will be suppressed, and instead a StopInfoThreadPlan
+//  object will be cons'ed up from the highest completed plan in the stack.  However, if the plan doesn't want to be
+//  the stop reason, then it can call SetPlanComplete and pass in "false" for the "success" parameter.  In that case,
+//  the real stop reason will be used instead.  One exapmle of this is the "StepRangeStepIn" thread plan.  If it stops
+//  because of a crash or breakpoint hit, it wants to unship itself, because it isn't so useful to have step in keep going
+//  after a breakpoint hit.  But it can't be the reason for the stop or no-one would see that they had hit a breakpoint.
+//
 //  Automatically Resuming:
 //
 //  If ShouldStop for all threads returns "false", then the target process will resume.  This then cycles back to
@@ -396,7 +406,13 @@
     IsPlanComplete();
     
     void
-    SetPlanComplete ();
+    SetPlanComplete (bool success = true);
+    
+    bool
+    PlanSucceeded ()
+    {
+        return m_plan_succeeded;
+    }
     
     virtual bool
     IsBasePlan()
@@ -489,6 +505,7 @@
     bool m_plan_private;
     bool m_okay_to_discard;
     bool m_is_master_plan;
+    bool m_plan_succeeded;
     
     lldb::ThreadPlanTracerSP m_tracer_sp;
 

Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h Tue May  1 13:38:37 2012
@@ -49,6 +49,9 @@
     static void
     SetDefaultFlagValue (uint32_t new_value);
 
+    virtual bool
+    PlanExplainsStop ();
+
 protected:
 
     virtual void

Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h Tue May  1 13:38:37 2012
@@ -35,6 +35,7 @@
 
     virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
     virtual bool ShouldStop (Event *event_ptr);
+    virtual bool PlanExplainsStop ();
 
 protected:
 

Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h Tue May  1 13:38:37 2012
@@ -42,7 +42,6 @@
     virtual lldb::StateType GetPlanRunState ();
     virtual bool WillStop ();
     virtual bool MischiefManaged ();
-    virtual bool PlanExplainsStop ();
     virtual void DidPush ();
 
 

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue May  1 13:38:37 2012
@@ -97,7 +97,7 @@
 Thread::GetStopInfo ()
 {
     ThreadPlanSP plan_sp (GetCompletedPlan());
-    if (plan_sp)
+    if (plan_sp && plan_sp->PlanSucceeded())
         return StopInfo::CreateStopReasonWithPlan (plan_sp, GetReturnValueObject());
     else
     {

Modified: lldb/trunk/source/Target/ThreadPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlan.cpp?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlan.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlan.cpp Tue May  1 13:38:37 2012
@@ -37,7 +37,8 @@
     m_plan_complete (false),
     m_plan_private (false),
     m_okay_to_discard (false),
-    m_is_master_plan (false)
+    m_is_master_plan (false),
+    m_plan_succeeded(true)
 {
     SetID (GetNextID());
 }
@@ -57,10 +58,11 @@
 }
 
 void
-ThreadPlan::SetPlanComplete ()
+ThreadPlan::SetPlanComplete (bool success)
 {
     Mutex::Locker locker(m_plan_complete_mutex);
     m_plan_complete = true;
+    m_plan_succeeded = success;
 }
 
 bool

Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue May  1 13:38:37 2012
@@ -295,3 +295,41 @@
 
     return NULL;
 }
+
+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.
+    // We also set ourselves complete when we stop for this sort of unintended reason, but mark
+    // success as false so we don't end up being the reason for the stop.
+    //
+    // The only variation is that if we are doing "step by running to next branch" in which case
+    // if we hit our branch breakpoint we don't set the plan to complete.
+    
+    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:
+            if (NextRangeBreakpointExplainsStop(stop_info_sp))
+                return true;
+        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(false);
+            break;
+        default:
+            break;
+        }
+    }
+    return true;
+}

Modified: lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp Tue May  1 13:38:37 2012
@@ -170,3 +170,41 @@
     else
         return false;
 }
+
+bool
+ThreadPlanStepOverRange::PlanExplainsStop ()
+{
+    // For crashes, breakpoint hits, signals, etc, let the base plan (or some plan above us)
+    // handle the stop.  That way the user can see the stop, step around, and then when they
+    // are done, continue and have their step complete.  The exception is if we've hit our
+    // "run to next branch" breakpoint.
+    // Note, unlike the step in range plan, we don't mark ourselves complete if we hit an
+    // unexplained breakpoint/crash.
+    
+    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:
+            if (NextRangeBreakpointExplainsStop(stop_info_sp))
+                return true;
+            else
+                return false;
+            break;
+        case eStopReasonWatchpoint:
+        case eStopReasonSignal:
+        case eStopReasonException:
+            if (log)
+                log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
+            return false;
+            break;
+        default:
+            break;
+        }
+    }
+    return true;
+}

Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=155927&r1=155926&r2=155927&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Tue May  1 13:38:37 2012
@@ -350,42 +350,6 @@
 }
 
 bool
-ThreadPlanStepRange::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:
-            if (NextRangeBreakpointExplainsStop(stop_info_sp))
-                return true;
-            else
-                return false;
-            break;
-        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
 ThreadPlanStepRange::WillStop ()
 {
     return true;





More information about the lldb-commits mailing list