[Lldb-commits] [lldb] r138577 - in /lldb/trunk: include/lldb/Target/ThreadList.h source/Core/Debugger.cpp source/Interpreter/CommandInterpreter.cpp source/Plugins/Process/Utility/InferiorCallPOSIX.cpp source/Target/Process.cpp source/Target/ThreadList.cpp

Johnny Chen johnny.chen at apple.com
Thu Aug 25 12:38:34 PDT 2011


Author: johnny
Date: Thu Aug 25 14:38:34 2011
New Revision: 138577

URL: http://llvm.org/viewvc/llvm-project?rev=138577&view=rev
Log:
Make ThreadList::GetSelectedThread() select and return the 0th thread if there's no
currently selected thread.  And update the call sites accordingly.

Modified:
    lldb/trunk/include/lldb/Target/ThreadList.h
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/ThreadList.cpp

Modified: lldb/trunk/include/lldb/Target/ThreadList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadList.h?rev=138577&r1=138576&r2=138577&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadList.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadList.h Thu Aug 25 14:38:34 2011
@@ -45,6 +45,8 @@
     void
     AddThread (lldb::ThreadSP &thread_sp);
 
+    // Return the selected thread if there is one.  Otherwise, return the thread
+    // selected at index 0.
     lldb::ThreadSP
     GetSelectedThread ();
 

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=138577&r1=138576&r2=138577&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Aug 25 14:38:34 2011
@@ -346,8 +346,6 @@
         if (exe_ctx.process && exe_ctx.process->IsRunning() == false)
         {
             exe_ctx.thread = exe_ctx.process->GetThreadList().GetSelectedThread().get();
-            if (exe_ctx.thread == NULL)
-                exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get();
             if (exe_ctx.thread)
             {
                 exe_ctx.frame = exe_ctx.thread->GetSelectedFrame().get();

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=138577&r1=138576&r2=138577&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Aug 25 14:38:34 2011
@@ -2230,13 +2230,6 @@
             if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning())
             {
                 m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get();
-                if (m_exe_ctx.thread == NULL)
-                {
-                    m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get();
-                    // If we didn't have a selected thread, select one here.
-                    if (m_exe_ctx.thread != NULL)
-                        m_exe_ctx.process->GetThreadList().SetSelectedThreadByID(m_exe_ctx.thread->GetID());
-                }
                 if (m_exe_ctx.thread)
                 {
                     m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get();

Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=138577&r1=138576&r2=138577&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Thu Aug 25 14:38:34 2011
@@ -26,8 +26,6 @@
                                     unsigned flags, addr_t fd, addr_t offset) {
     Thread *thread = process->GetThreadList().GetSelectedThread().get();
     if (thread == NULL)
-        thread = process->GetThreadList().GetThreadAtIndex(0).get();
-    if (thread == NULL)
         return false;
 
     const bool append = true;
@@ -129,7 +127,7 @@
                                       addr_t length) {
    Thread *thread = process->GetThreadList().GetSelectedThread().get();
    if (thread == NULL)
-       thread = process->GetThreadList().GetThreadAtIndex(0).get();
+       return false;
    
    const bool append = true;
    const bool include_symbols = true;

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=138577&r1=138576&r2=138577&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Aug 25 14:38:34 2011
@@ -1138,8 +1138,6 @@
     if (error.Success())
     {
         ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
-        if (thread_sp == NULL)
-            thread_sp = GetThreadList ().GetThreadAtIndex(0, true);
         
         if (thread_sp)
         {
@@ -1205,8 +1203,6 @@
             if (error.Success())
             {
                 ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
-                if (thread_sp == NULL)
-                    thread_sp = GetThreadList ().GetThreadAtIndex(0, true);
                 
                 if (thread_sp)
                 {

Modified: lldb/trunk/source/Target/ThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=138577&r1=138576&r2=138577&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadList.cpp (original)
+++ lldb/trunk/source/Target/ThreadList.cpp Thu Aug 25 14:38:34 2011
@@ -545,6 +545,8 @@
 ThreadList::GetSelectedThread ()
 {
     Mutex::Locker locker(m_threads_mutex);
+    if (m_selected_tid == LLDB_INVALID_THREAD_ID)
+        SetSelectedThreadByID(m_threads[0]->GetID());
     return FindThreadByID(m_selected_tid);
 }
 





More information about the lldb-commits mailing list