2011-04-19 Marc Khouzam <marc.khouzam@ericsson.com>
authorMarc Khouzam <marc.khouzam@ericsson.com>
Tue, 19 Apr 2011 15:16:14 +0000 (15:16 +0000)
committerMarc Khouzam <marc.khouzam@ericsson.com>
Tue, 19 Apr 2011 15:16:14 +0000 (15:16 +0000)
* thread.c (any_live_thread_of_process): Prioritize threads
that are not executing.
* gdbthread.h (any_live_thread_of_process): Update comment
as per above change.

gdb/ChangeLog
gdb/gdbthread.h
gdb/thread.c

index 1ef5a80f69dd7f852b4c459b3307e1d3e86bef62..7dbfa1d6fc7a3de43208fd5de61196866ac916b5 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-19  Marc Khouzam  <marc.khouzam@ericsson.com>
+
+       * thread.c (any_live_thread_of_process): Prioritize threads
+       that are not executing.
+       * gdbthread.h (any_live_thread_of_process): Update comment
+       as per above change.
+
 2011-04-19  Andreas Schwab  <schwab@linux-m68k.org>
 
        * xcoffread.c (process_xcoff_symbol): Remove useless cast.
index 43db95a771604ad2fbd5e8c4a062f836250eabd4..0b19a8dc3c5ea82f6ef49623ce88dceabe2a3af6 100644 (file)
@@ -287,7 +287,7 @@ struct thread_info *first_thread_of_process (int pid);
 extern struct thread_info *any_thread_of_process (int pid);
 
 /* Returns any non-exited thread of process PID, giving preference for
-   already stopped threads.  */
+   not executing threads.  */
 extern struct thread_info *any_live_thread_of_process (int pid);
 
 /* Change the ptid of thread OLD_PTID to NEW_PTID.  */
index 6ad1807db83247e89b499c44984e5f8702e1505d..5f07c83ff3b84aa9daa9d13d5804d0f387cde96e 100644 (file)
@@ -470,18 +470,18 @@ struct thread_info *
 any_live_thread_of_process (int pid)
 {
   struct thread_info *tp;
-  struct thread_info *tp_running = NULL;
+  struct thread_info *tp_executing = NULL;
 
   for (tp = thread_list; tp; tp = tp->next)
-    if (ptid_get_pid (tp->ptid) == pid)
+    if (tp->state_ != THREAD_EXITED && ptid_get_pid (tp->ptid) == pid)
       {
-       if (tp->state_ == THREAD_STOPPED)
+       if (tp->executing_)
+         tp_executing = tp;
+       else
          return tp;
-       else if (tp->state_ == THREAD_RUNNING)
-         tp_running = tp;
       }
 
-  return tp_running;
+  return tp_executing;
 }
 
 /* Print a list of thread ids currently known, and the total number of