[Lldb-commits] [lldb] r124934 - in /lldb/branches/apple/calcite/lldb: include/lldb/Target/Thread.h source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp source/Target/Process.cpp source/Target/Thread.cpp source/Target/ThreadPlanBase.cpp

Jim Ingham jingham at apple.com
Fri Feb 4 20:17:26 PST 2011


Author: jingham
Date: Fri Feb  4 22:17:26 2011
New Revision: 124934

URL: http://llvm.org/viewvc/llvm-project?rev=124934&view=rev
Log:
A little more logging.
Also, if plans above the base plan on the plan stack explain the event, let the last of those plans
have the final say, don't defer to the base plan in this case.

Modified:
    lldb/branches/apple/calcite/lldb/include/lldb/Target/Thread.h
    lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
    lldb/branches/apple/calcite/lldb/source/Target/Process.cpp
    lldb/branches/apple/calcite/lldb/source/Target/Thread.cpp
    lldb/branches/apple/calcite/lldb/source/Target/ThreadPlanBase.cpp

Modified: lldb/branches/apple/calcite/lldb/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Target/Thread.h?rev=124934&r1=124933&r2=124934&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/include/lldb/Target/Thread.h (original)
+++ lldb/branches/apple/calcite/lldb/include/lldb/Target/Thread.h Fri Feb  4 22:17:26 2011
@@ -553,6 +553,16 @@
     ThreadPlan *
     GetCurrentPlan ();
 
+private:
+    bool
+    PlanIsBasePlan (ThreadPlan *plan_ptr)
+    {
+        if (m_plan_stack.size() == 0)
+            return false;
+        return m_plan_stack[0].get() == plan_ptr;
+    }
+public:
+
     //------------------------------------------------------------------
     /// Gets the inner-most plan that was popped off the plan stack in the
     /// most recent stop.  Useful for printing the stop reason accurately.

Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=124934&r1=124933&r2=124934&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Fri Feb  4 22:17:26 2011
@@ -13,6 +13,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Core/State.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
@@ -85,6 +86,9 @@
     Thread::WillResume(resume_state);
 
     int signo = GetResumeSignal();
+    lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP));
+    if (log)
+        log->Printf ("Resuming thread: %4.4x with state: %s.", GetID(), StateAsCString(resume_state));
 
     switch (resume_state)
     {

Modified: lldb/branches/apple/calcite/lldb/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Target/Process.cpp?rev=124934&r1=124933&r2=124934&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Target/Process.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Target/Process.cpp Fri Feb  4 22:17:26 2011
@@ -2814,7 +2814,7 @@
                 if (first_timeout)
                     real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec);
                 else
-                    real_timeout.OffsetWithSeconds(2);
+                    real_timeout.OffsetWithSeconds(10);
                     
                 timeout_ptr = &real_timeout;
             }

Modified: lldb/branches/apple/calcite/lldb/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Target/Thread.cpp?rev=124934&r1=124933&r2=124934&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Target/Thread.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Target/Thread.cpp Fri Feb  4 22:17:26 2011
@@ -260,38 +260,56 @@
     if (current_plan->PlanExplainsStop())
     {
         bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
-        while (1)
+        
+        // We're starting from the base plan, so just let it decide;
+        if (PlanIsBasePlan(current_plan))
+        {
+            should_stop = current_plan->ShouldStop (event_ptr);
+            if (log)
+                log->Printf("Base plan says should stop: %d.", current_plan->GetName(), should_stop);
+        }
+        else
         {
-            should_stop = current_plan->ShouldStop(event_ptr);
-            if (current_plan->MischiefManaged())
+            // Otherwise, don't let the base plan override what the other plans say to do, since
+            // presumably if there were other plans they would know what to do...
+            while (1)
             {
-                if (should_stop)
-                    current_plan->WillStop();
-
-                // If a Master Plan wants to stop, and wants to stick on the stack, we let it.
-                // Otherwise, see if the plan's parent wants to stop.
-
-                if (should_stop && current_plan->IsMasterPlan() && !current_plan->OkayToDiscard())
-                {
-                    PopPlan();
+                if (PlanIsBasePlan(current_plan))
                     break;
-                }
-                else
+                    
+                should_stop = current_plan->ShouldStop(event_ptr);
+                if (log)
+                    log->Printf("Plan %s should stop: %d.", current_plan->GetName(), should_stop);
+                if (current_plan->MischiefManaged())
                 {
+                    if (should_stop)
+                        current_plan->WillStop();
 
-                    PopPlan();
+                    // If a Master Plan wants to stop, and wants to stick on the stack, we let it.
+                    // Otherwise, see if the plan's parent wants to stop.
 
-                    current_plan = GetCurrentPlan();
-                    if (current_plan == NULL)
+                    if (should_stop && current_plan->IsMasterPlan() && !current_plan->OkayToDiscard())
                     {
+                        PopPlan();
                         break;
                     }
-                }
+                    else
+                    {
 
-            }
-            else
-            {
-                break;
+                        PopPlan();
+
+                        current_plan = GetCurrentPlan();
+                        if (current_plan == NULL)
+                        {
+                            break;
+                        }
+                    }
+
+                }
+                else
+                {
+                    break;
+                }
             }
         }
         if (over_ride_stop)
@@ -477,7 +495,6 @@
 bool
 Thread::IsThreadPlanDone (ThreadPlan *plan)
 {
-    ThreadPlanSP empty_plan_sp;
     if (!m_completed_plan_stack.empty())
     {
         for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
@@ -492,7 +509,6 @@
 bool
 Thread::WasThreadPlanDiscarded (ThreadPlan *plan)
 {
-    ThreadPlanSP empty_plan_sp;
     if (!m_discarded_plan_stack.empty())
     {
         for (int i = m_discarded_plan_stack.size() - 1; i >= 0; i--)

Modified: lldb/branches/apple/calcite/lldb/source/Target/ThreadPlanBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Target/ThreadPlanBase.cpp?rev=124934&r1=124933&r2=124934&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Target/ThreadPlanBase.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Target/ThreadPlanBase.cpp Fri Feb  4 22:17:26 2011
@@ -18,6 +18,7 @@
 #include "lldb/Breakpoint/BreakpointSite.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
@@ -82,6 +83,8 @@
     m_stop_vote = eVoteYes;
     m_run_vote = eVoteYes;
 
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+
     StopInfoSP stop_info_sp = GetPrivateStopReason();
     if (stop_info_sp)
     {
@@ -101,6 +104,8 @@
                 // If we are going to stop for a breakpoint, then unship the other plans
                 // at this point.  Don't force the discard, however, so Master plans can stay
                 // in place if they want to.
+                if (log)
+                    log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (breakpoint hit.)", m_thread.GetID());
                 m_thread.DiscardThreadPlans(false);
                 return true;
             }
@@ -127,12 +132,16 @@
         case eStopReasonException:
             // If we crashed, discard thread plans and stop.  Don't force the discard, however,
             // since on rerun the target may clean up this exception and continue normally from there.
+                if (log)
+                    log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (exception.)", m_thread.GetID());
             m_thread.DiscardThreadPlans(false);
             return true;
 
         case eStopReasonSignal:
             if (stop_info_sp->ShouldStop(event_ptr))
             {
+                if (log)
+                    log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (signal.)", m_thread.GetID());
                 m_thread.DiscardThreadPlans(false);
                 return true;
             }





More information about the lldb-commits mailing list