aboutsummaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-01-18 17:42:16 +0000
committerPedro Alves <palves@redhat.com>2009-01-18 17:42:16 +0000
commit29f49a6a4f3f165090de6c85fdb0f29dcb579ae7 (patch)
tree5af7a780ad9ac00b0d292c3f4b1bf92d173a3d5b /gdb/thread.c
parente7243d734732b21fd5b2323fa4e727e4b56c0b79 (diff)
downloadfsf-binutils-gdb-29f49a6a4f3f165090de6c85fdb0f29dcb579ae7.zip
fsf-binutils-gdb-29f49a6a4f3f165090de6c85fdb0f29dcb579ae7.tar.gz
fsf-binutils-gdb-29f49a6a4f3f165090de6c85fdb0f29dcb579ae7.tar.bz2
PR gdb/9747:
* gdbthread.h (finish_thread_state, finish_thread_state_cleanup): Declare. * thread.c (finish_thread_state, finish_thread_state_cleanup): New. * infrun.c (wait_for_inferior, fetch_inferior_event): If an error is thrown while handling an event, finish the thread state. (normal_stop): Use finish_thread_state cleanup. * infcmd.c (run_command_1): If an error is thrown while starting the inferior, finish the thread state.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index 44e4ba2..8a98b8e 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -632,6 +632,55 @@ set_stop_requested (ptid_t ptid, int stop)
observer_notify_thread_stop_requested (ptid);
}
+void
+finish_thread_state (ptid_t ptid)
+{
+ struct thread_info *tp;
+ int all;
+ int any_started = 0;
+
+ all = ptid_equal (ptid, minus_one_ptid);
+
+ if (all || ptid_is_pid (ptid))
+ {
+ for (tp = thread_list; tp; tp = tp->next)
+ {
+ if (tp->state_ == THREAD_EXITED)
+ continue;
+ if (all || ptid_get_pid (ptid) == ptid_get_pid (tp->ptid))
+ {
+ if (tp->executing_ && tp->state_ == THREAD_STOPPED)
+ any_started = 1;
+ tp->state_ = tp->executing_ ? THREAD_RUNNING : THREAD_STOPPED;
+ }
+ }
+ }
+ else
+ {
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ if (tp->state_ != THREAD_EXITED)
+ {
+ if (tp->executing_ && tp->state_ == THREAD_STOPPED)
+ any_started = 1;
+ tp->state_ = tp->executing_ ? THREAD_RUNNING : THREAD_STOPPED;
+ }
+ }
+
+ if (any_started)
+ observer_notify_target_resumed (ptid);
+}
+
+void
+finish_thread_state_cleanup (void *arg)
+{
+ ptid_t *ptid_p = arg;
+
+ gdb_assert (arg);
+
+ finish_thread_state (*ptid_p);
+}
+
/* Prints the list of threads and their details on UIOUT.
This is a version of 'info_thread_command' suitable for
use from MI.