aboutsummaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-06-10 10:23:54 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-06-10 10:23:54 +0000
commite1ac3328737bc34a23dbfff92b416a9d9306329a (patch)
treea6ffb502159f70dbab8c069def57709877ec7b9d /gdb/thread.c
parentf7f9a841a31878b377a60bfc7c793e6c8400fafe (diff)
downloadgdb-e1ac3328737bc34a23dbfff92b416a9d9306329a.zip
gdb-e1ac3328737bc34a23dbfff92b416a9d9306329a.tar.gz
gdb-e1ac3328737bc34a23dbfff92b416a9d9306329a.tar.bz2
Implement *running.
* Makefile.in: Update dependencies. * gdbthread.h (struct thread_info): New field running_. (set_running, is_running): New. * thread.c (set_running, is_running): New. * inferior.h (suppress_normal_stop_observer): Rename to... (suppress_run_stop_observers): ..this. * infcmd.c (suppress_normal_stop_observer): Rename to... (suppress_run_stop_observers): ..this. (finish_command_continuation, finish_command): Adjust. * infcall.c (call_function_by_hand): Adjust. * infrun.c (normal_stop): Call set_running. * target.c (target_resume): New. Call set_running. * target.h (target_resume): Convert from macro to a function. * mi/mi-interp.c (mi_on_resume): New. (mi_interpreter_init): Register mi_on_resume.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index 446a55e..64d41eb 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -414,6 +414,67 @@ prune_threads (void)
}
}
+static int main_thread_running = 0;
+
+void
+set_running (ptid_t ptid, int running)
+{
+ struct thread_info *tp;
+
+ if (!thread_list)
+ {
+ /* This is one of the targets that does not add main
+ thread to the thread list. Just use a single
+ global flag to indicate that a thread is running.
+
+ This problem is unique to ST programs. For MT programs,
+ the main thread is always present in the thread list. If it's
+ not, the first call to context_switch will mess up GDB internal
+ state. */
+ if (running && !main_thread_running && !suppress_run_stop_observers)
+ observer_notify_target_resumed (ptid);
+ main_thread_running = running;
+ return;
+ }
+
+ /* We try not to notify the observer if no thread has actually changed
+ the running state -- merely to reduce the number of messages to
+ frontend. Frontend is supposed to handle multiple *running just fine. */
+ if (PIDGET (ptid) == -1)
+ {
+ int any_started = 0;
+ for (tp = thread_list; tp; tp = tp->next)
+ {
+ if (running && !tp->running_)
+ any_started = 1;
+ tp->running_ = running;
+ }
+ if (any_started && !suppress_run_stop_observers)
+ observer_notify_target_resumed (ptid);
+ }
+ else
+ {
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ if (running && !tp->running_ && !suppress_run_stop_observers)
+ observer_notify_target_resumed (ptid);
+ tp->running_ = running;
+ }
+}
+
+int
+is_running (ptid_t ptid)
+{
+ struct thread_info *tp;
+
+ if (!thread_list)
+ return main_thread_running;
+
+ tp = find_thread_pid (ptid);
+ gdb_assert (tp);
+ return tp->running_;
+}
+
/* Prints the list of threads and their details on UIOUT.
This is a version of 'info_thread_command' suitable for
use from MI.