[Lldb-commits] [lldb] r184619 - Add some useful logging for tracking thread matching problems.

Jim Ingham jingham at apple.com
Fri Jun 21 17:27:45 PDT 2013


Author: jingham
Date: Fri Jun 21 19:27:45 2013
New Revision: 184619

URL: http://llvm.org/viewvc/llvm-project?rev=184619&view=rev
Log:
Add some useful logging for tracking thread matching problems.

Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlan.cpp

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=184619&r1=184618&r2=184619&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Jun 21 19:27:45 2013
@@ -1314,7 +1314,24 @@ ProcessGDBRemote::UpdateThreadList (Thre
             tid_t tid = m_thread_ids[i];
             ThreadSP thread_sp (old_thread_list_copy.RemoveThreadByProtocolID(tid, false));
             if (!thread_sp)
+            {
                 thread_sp.reset (new ThreadGDBRemote (*this, tid));
+                if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
+                    log->Printf(
+                            "ProcessGDBRemote::%s Making new thread: %p for thread ID: 0x%" PRIx64 ".\n",
+                            __FUNCTION__,
+                            thread_sp.get(),
+                            thread_sp->GetID());
+            }
+            else
+            {
+                if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
+                    log->Printf(
+                           "ProcessGDBRemote::%s Found old thread: %p for thread ID: 0x%" PRIx64 ".\n",
+                           __FUNCTION__,
+                           thread_sp.get(),
+                           thread_sp->GetID());
+            }
             new_thread_list.AddThread(thread_sp);
         }
     }
@@ -1403,6 +1420,13 @@ ProcessGDBRemote::SetThreadStopInfo (Str
                     {
                         // Create the thread if we need to
                         thread_sp.reset (new ThreadGDBRemote (*this, tid));
+                        Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD));
+                        if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
+                            log->Printf ("ProcessGDBRemote::%s Adding new thread: %p for thread ID: 0x%" PRIx64 ".\n",
+                                         __FUNCTION__,
+                                         thread_sp.get(),
+                                         thread_sp->GetID());
+                                         
                         m_thread_list_real.AddThread(thread_sp);
                     }
                     gdb_thread = static_cast<ThreadGDBRemote *> (thread_sp.get());

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=184619&r1=184618&r2=184619&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Fri Jun 21 19:27:45 2013
@@ -704,8 +704,9 @@ Thread::ShouldStop (Event* event_ptr)
     
     if (log)
     {
-        log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64,
-                     __FUNCTION__, 
+        log->Printf ("Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64,
+                     __FUNCTION__,
+                     this,
                      GetID (),
                      GetProtocolID (),
                      GetRegisterContext() ? GetRegisterContext()->GetPC() : LLDB_INVALID_ADDRESS);
@@ -966,8 +967,9 @@ Thread::ShouldReportRun (Event* event_pt
     {
         // Don't use GetCompletedPlan here, since that suppresses private plans.
         if (log)
-            log->Printf ("Current Plan for thread %d (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
-                         GetIndexID(), 
+            log->Printf ("Current Plan for thread %d(%p) (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
+                         GetIndexID(),
+                         this,
                          GetID(),
                          StateAsCString(GetTemporaryResumeState()),
                          m_completed_plan_stack.back()->GetName());
@@ -977,8 +979,9 @@ Thread::ShouldReportRun (Event* event_pt
     else
     {
         if (log)
-            log->Printf ("Current Plan for thread %d (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
-                         GetIndexID(), 
+            log->Printf ("Current Plan for thread %d(%p) (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
+                         GetIndexID(),
+                         this,
                          GetID(),
                          StateAsCString(GetTemporaryResumeState()),
                          GetCurrentPlan()->GetName());
@@ -1013,7 +1016,8 @@ Thread::PushPlan (ThreadPlanSP &thread_p
         {
             StreamString s;
             thread_plan_sp->GetDescription (&s, lldb::eDescriptionLevelFull);
-            log->Printf("Pushing plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
+            log->Printf("Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
+                        this,
                         s.GetData(),
                         thread_plan_sp->GetThread().GetID());
         }
@@ -1043,9 +1047,13 @@ Thread::PopPlan ()
 void
 Thread::DiscardPlan ()
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
     if (m_plan_stack.size() > 1)
     {
         ThreadPlanSP &plan = m_plan_stack.back();
+        if (log)
+            log->Printf("Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".", plan->GetName(), plan->GetThread().GetID());
+
         m_discarded_plan_stack.push_back (plan);
         plan->WillPop();
         m_plan_stack.pop_back();

Modified: lldb/trunk/source/Target/ThreadPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlan.cpp?rev=184619&r1=184618&r2=184619&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlan.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlan.cpp Fri Jun 21 19:27:45 2013
@@ -159,10 +159,11 @@ ThreadPlan::WillResume (StateType resume
             addr_t pc = reg_ctx->GetPC();
             addr_t sp = reg_ctx->GetSP();
             addr_t fp = reg_ctx->GetFP();
-            log->Printf("%s Thread #%u: tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64 ", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
+            log->Printf("%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64 ", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
                         "plan = '%s', state = %s, stop others = %d", 
                         __FUNCTION__,
-                        m_thread.GetIndexID(), 
+                        m_thread.GetIndexID(),
+                        &m_thread,
                         m_thread.GetID(),  
                         (uint64_t)pc,
                         (uint64_t)sp,





More information about the lldb-commits mailing list