[Lldb-commits] [lldb] r252355 - Another optimization to keep down gdb-remote traffic. If we have suspended a thread while

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 6 14:45:58 PST 2015


Author: jingham
Date: Fri Nov  6 16:45:57 2015
New Revision: 252355

URL: http://llvm.org/viewvc/llvm-project?rev=252355&view=rev
Log:
Another optimization to keep down gdb-remote traffic.  If we have suspended a thread while
running, don't request the thread status when deciding why we stopped.

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

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=252355&r1=252354&r2=252355&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Fri Nov  6 16:45:57 2015
@@ -1320,6 +1320,12 @@ protected:
     GetStackFrameList ();
 
     void
+    SetTemporaryResumeState(lldb::StateType new_state)
+    {
+        m_temporary_resume_state = new_state;
+    }
+
+    void
     FunctionOptimizationWarning (lldb_private::StackFrame *frame);
 
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=252355&r1=252354&r2=252355&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Fri Nov  6 16:45:57 2015
@@ -726,14 +726,17 @@ Thread::ShouldResume (StateType resume_s
     m_discarded_plan_stack.clear();
     m_override_should_notify = eLazyBoolCalculate;
 
-    m_temporary_resume_state = resume_state;
+    StateType prev_resume_state = GetTemporaryResumeState();
+
+    SetTemporaryResumeState(resume_state);
     
     lldb::ThreadSP backing_thread_sp (GetBackingThread ());
     if (backing_thread_sp)
-        backing_thread_sp->m_temporary_resume_state = resume_state;
+        backing_thread_sp->SetTemporaryResumeState(resume_state);
 
-    // Make sure m_stop_info_sp is valid
-    GetPrivateStopInfo();
+    // Make sure m_stop_info_sp is valid.  Don't do this for threads we suspended in the previous run.
+    if (prev_resume_state != eStateSuspended)
+        GetPrivateStopInfo();
     
     // This is a little dubious, but we are trying to limit how often we actually fetch stop info from
     // the target, 'cause that slows down single stepping.  So assume that if we got to the point where

Modified: lldb/trunk/source/Target/ThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=252355&r1=252354&r2=252355&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadList.cpp (original)
+++ lldb/trunk/source/Target/ThreadList.cpp Fri Nov  6 16:45:57 2015
@@ -257,7 +257,20 @@ ThreadList::ShouldStop (Event *event_ptr
         Mutex::Locker locker(GetMutex());
 
         m_process->UpdateThreadListIfNeeded();
-        threads_copy = m_threads;
+        for (lldb::ThreadSP thread_sp : m_threads)
+        {
+            // This is an optimization...  If we didn't let a thread run in between the previous stop and this
+            // one, we shouldn't have to consult it for ShouldStop.  So just leave it off the list we are going to
+            // inspect.
+            if (thread_sp->GetTemporaryResumeState () != eStateSuspended)
+                threads_copy.push_back(thread_sp);
+        }
+
+        // It is possible the threads we were allowing to run all exited and then maybe the user interrupted
+        // or something, then fall back on looking at all threads:
+
+        if (threads_copy.size() == 0)
+            threads_copy = m_threads;
     }
 
     collection::iterator pos, end = threads_copy.end();
@@ -265,7 +278,10 @@ ThreadList::ShouldStop (Event *event_ptr
     if (log)
     {
         log->PutCString("");
-        log->Printf ("ThreadList::%s: %" PRIu64 " threads", __FUNCTION__, (uint64_t)m_threads.size());
+        log->Printf ("ThreadList::%s: %" PRIu64 " threads, %" PRIu64 " unsuspended threads",
+                     __FUNCTION__,
+                     (uint64_t)m_threads.size(),
+                     (uint64_t)threads_copy.size());
     }
 
     bool did_anybody_stop_for_a_reason = false;




More information about the lldb-commits mailing list