From 9941e0c5c123c37b55ff77cb4caa78e87b95823e Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 19 Apr 2011 15:16:14 +0000 Subject: [PATCH] 2011-04-19 Marc Khouzam * 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 | 7 +++++++ gdb/gdbthread.h | 2 +- gdb/thread.c | 12 ++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1ef5a80f69d..7dbfa1d6fc7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2011-04-19 Marc Khouzam + + * 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 * xcoffread.c (process_xcoff_symbol): Remove useless cast. diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 43db95a7716..0b19a8dc3c5 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -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. */ diff --git a/gdb/thread.c b/gdb/thread.c index 6ad1807db83..5f07c83ff3b 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -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 -- 2.30.2