[Lldb-commits] [lldb] r142025 - in /lldb/trunk/source/Target: Thread.cpp ThreadList.cpp

Jim Ingham jingham at apple.com
Fri Oct 14 17:23:43 PDT 2011


Author: jingham
Date: Fri Oct 14 19:23:43 2011
New Revision: 142025

URL: http://llvm.org/viewvc/llvm-project?rev=142025&view=rev
Log:
Make the "log enable lldb-step" output easier to parse.

Modified:
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadList.cpp

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=142025&r1=142024&r2=142025&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Fri Oct 14 19:23:43 2011
@@ -262,9 +262,11 @@
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
     if (log)
     {
+        log->Printf ("^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
         StreamString s;
+        s.IndentMore();
         DumpThreadPlans(&s);
-        log->PutCString (s.GetData());
+        log->Printf ("Plan stack initial state:\n%s", s.GetData());
     }
     
     // The top most plan always gets to do the trace log...
@@ -274,6 +276,9 @@
     {
         bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
         
+        if (log)
+            log->Printf("Plan %s explains stop, auto-continue %i.", current_plan->GetName(), over_ride_stop);
+            
         // We're starting from the base plan, so just let it decide;
         if (PlanIsBasePlan(current_plan))
         {
@@ -330,7 +335,7 @@
     }
     else if (current_plan->TracerExplainsStop())
     {
-        return false;
+        should_stop = false;
     }
     else
     {
@@ -348,6 +353,14 @@
         }
     }
 
+    if (log)
+    {
+        StreamString s;
+        s.IndentMore();
+        DumpThreadPlans(&s);
+        log->Printf ("Plan stack final state:\n%s", s.GetData());
+        log->Printf ("vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv", should_stop);
+    }
     return should_stop;
 }
 
@@ -850,36 +863,48 @@
 {
     uint32_t stack_size = m_plan_stack.size();
     int i;
+    s->Indent();
     s->Printf ("Plan Stack for thread #%u: tid = 0x%4.4x, stack_size = %d\n", GetIndexID(), GetID(), stack_size);
     for (i = stack_size - 1; i >= 0; i--)
     {
-        s->Printf ("Element %d: ", i);
         s->IndentMore();
+        s->Indent();
+        s->Printf ("Element %d: ", i);
         m_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
-        s->IndentLess();
         s->EOL();
+        s->IndentLess();
     }
 
     stack_size = m_completed_plan_stack.size();
-    s->Printf ("Completed Plan Stack: %d elements.\n", stack_size);
-    for (i = stack_size - 1; i >= 0; i--)
+    if (stack_size > 0)
     {
-        s->Printf ("Element %d: ", i);
-        s->IndentMore();
-        m_completed_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
-        s->IndentLess();
-        s->EOL();
+        s->Indent();
+        s->Printf ("Completed Plan Stack: %d elements.\n", stack_size);
+        for (i = stack_size - 1; i >= 0; i--)
+        {
+            s->IndentMore();
+            s->Indent();
+            s->Printf ("Element %d: ", i);
+            m_completed_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
+            s->EOL();
+            s->IndentLess();
+        }
     }
 
     stack_size = m_discarded_plan_stack.size();
-    s->Printf ("Discarded Plan Stack: %d elements.\n", stack_size);
-    for (i = stack_size - 1; i >= 0; i--)
+    if (stack_size > 0)
     {
-        s->Printf ("Element %d: ", i);
-        s->IndentMore();
-        m_discarded_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
-        s->IndentLess();
-        s->EOL();
+        s->Indent();
+        s->Printf ("Discarded Plan Stack: %d elements.\n", stack_size);
+        for (i = stack_size - 1; i >= 0; i--)
+        {
+            s->IndentMore();
+            s->Indent();
+            s->Printf ("Element %d: ", i);
+            m_discarded_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
+            s->EOL();
+            s->IndentLess();
+        }
     }
 
 }

Modified: lldb/trunk/source/Target/ThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=142025&r1=142024&r2=142025&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadList.cpp (original)
+++ lldb/trunk/source/Target/ThreadList.cpp Fri Oct 14 19:23:43 2011
@@ -187,7 +187,10 @@
     collection::iterator pos, end = m_threads.end();
 
     if (log)
-        log->Printf ("%s %zu threads", __FUNCTION__, m_threads.size());
+    {
+        log->PutCString("");
+        log->Printf ("ThreadList::%s: %zu threads", __FUNCTION__, m_threads.size());
+    }
 
     // Run through the threads and ask whether we should stop.  Don't ask
     // suspended threads, however, it makes more sense for them to preserve their
@@ -199,7 +202,7 @@
         if (thread_sp->GetResumeState () == eStateSuspended)
         {
             if (log)
-                log->Printf ("%s tid = 0x%4.4x, pc = 0x%16.16llx, should_stop = 0 (ignore since thread was suspended)", 
+                log->Printf ("ThreadList::%s for tid = 0x%4.4x, pc = 0x%16.16llx, should_stop = 0 (ignore since thread was suspended)", 
                              __FUNCTION__, 
                              thread_sp->GetID (), 
                              thread_sp->GetRegisterContext()->GetPC());
@@ -209,26 +212,25 @@
         if (thread_sp->ThreadStoppedForAReason() == false)
         {
             if (log)
-                log->Printf ("%s tid = 0x%4.4x, pc = 0x%16.16llx, should_stop = 0 (ignore since no stop reason)", 
+                log->Printf ("ThreadList::%s for tid = 0x%4.4x, pc = 0x%16.16llx, should_stop = 0 (ignore since no stop reason)", 
                              __FUNCTION__, 
                              thread_sp->GetID (), 
                              thread_sp->GetRegisterContext()->GetPC());
             continue;
         }
 
-        const bool thread_should_stop = thread_sp->ShouldStop(event_ptr);
         if (log)
-            log->Printf ("%s tid = 0x%4.4x, pc = 0x%16.16llx, should_stop = %i", 
+            log->Printf ("ThreadList::%s for tid = 0x%4.4x, pc = 0x%16.16llx", 
                          __FUNCTION__, 
                          thread_sp->GetID (), 
-                         thread_sp->GetRegisterContext()->GetPC(), 
-                         thread_should_stop);
+                         thread_sp->GetRegisterContext()->GetPC());
+        const bool thread_should_stop = thread_sp->ShouldStop(event_ptr);
         if (thread_should_stop)
             should_stop |= true;
     }
 
     if (log)
-        log->Printf ("%s overall should_stop = %i", __FUNCTION__, should_stop);
+        log->Printf ("ThreadList::%s overall should_stop = %i", __FUNCTION__, should_stop);
 
     if (should_stop)
     {
@@ -254,7 +256,7 @@
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
 
     if (log)
-        log->Printf ("%s %zu threads", __FUNCTION__, m_threads.size());
+        log->Printf ("ThreadList::%s %zu threads", __FUNCTION__, m_threads.size());
 
     // Run through the threads and ask whether we should report this event.
     // For stopping, a YES vote wins over everything.  A NO vote wins over NO opinion.
@@ -265,7 +267,7 @@
         {
             const Vote vote = thread_sp->ShouldReportStop (event_ptr);
             if (log)
-                log->Printf  ("%s thread 0x%4.4x: pc = 0x%16.16llx, vote = %s", 
+                log->Printf  ("ThreadList::%s thread 0x%4.4x: pc = 0x%16.16llx, vote = %s", 
                               __FUNCTION__,
                               thread_sp->GetID (), 
                               thread_sp->GetRegisterContext()->GetPC(),
@@ -287,7 +289,7 @@
                 else
                 {
                     if (log)
-                        log->Printf ("%s thread 0x%4.4x: pc = 0x%16.16llx voted %s, but lost out because result was %s", 
+                        log->Printf ("ThreadList::%s thread 0x%4.4x: pc = 0x%16.16llx voted %s, but lost out because result was %s", 
                                      __FUNCTION__,
                                      thread_sp->GetID (), 
                                      thread_sp->GetRegisterContext()->GetPC(),
@@ -299,7 +301,7 @@
         }
     }
     if (log)
-        log->Printf ("%s returning %s", __FUNCTION__, GetVoteAsCString (result));
+        log->Printf ("ThreadList::%s returning %s", __FUNCTION__, GetVoteAsCString (result));
     return result;
 }
 
@@ -360,7 +362,7 @@
     m_process->UpdateThreadListIfNeeded();
     
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (log)
+    if (log && log->GetVerbose())
         log->Printf ("Turning off notification of new threads while single stepping a thread.");
 
     collection::iterator pos, end = m_threads.end();
@@ -416,14 +418,14 @@
     if (wants_solo_run)
     {
         LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
+        if (log && log->GetVerbose())
             log->Printf ("Turning on notification of new threads while single stepping a thread.");
         m_process->StartNoticingNewThreads();
     }
     else
     {
         LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
+        if (log && log->GetVerbose())
             log->Printf ("Turning off notification of new threads while single stepping a thread.");
         m_process->StopNoticingNewThreads();
     }





More information about the lldb-commits mailing list