diff options
author | Pedro Alves <palves@redhat.com> | 2008-07-09 22:16:15 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2008-07-09 22:16:15 +0000 |
commit | 8ea051c51f64f1f720b12a7424c56ac31ff9a58b (patch) | |
tree | 9ec47d09116f6c80e49cdf1d3a3bc1dce8c944b5 /gdb/thread.c | |
parent | 4487aabf2e89820ee5243a62c3d7ea9c0c5353f4 (diff) | |
download | gdb-8ea051c51f64f1f720b12a7424c56ac31ff9a58b.zip gdb-8ea051c51f64f1f720b12a7424c56ac31ff9a58b.tar.gz gdb-8ea051c51f64f1f720b12a7424c56ac31ff9a58b.tar.bz2 |
Add "executing" property to threads.
* inferior.h (target_executing): Delete.
* gdbthread.h (struct thread_info): Add executing_ field.
(set_executing, is_executing): New.
* thread.c (main_thread_executing): New.
(init_thread_list): Clear it and also main_thread_running.
(is_running): Return false if target has no execution.
(any_running, is_executing, set_executing): New.
* top.c: Include "gdbthread.h".
(target_executing): Delete.
(execute_command): Replace target_executing check by any_running.
* event-top.c: Include "gdbthread.h".
(display_gdb_prompt, command_handler): Replace target_executing by
is_running.
* inf-loop.c: Include "gdbthread.h". Don't mark as not executing
here. Replace target_executing by is_running.
* infrun.c (handle_inferior_event): Mark all threads as
not-executing.
* linux-nat.c (linux_nat_resume): Don't mark thread as executing
here.
* stack.c (get_selected_block): Return null if inferior is
executing.
* target.c (target_resume): Mark resumed ptid as executing.
* breakpoint.c (until_break_command): Replace target_executing
check by is_executing.
* remote.c (remote_async_resume): Don't mark inferior as executing
here.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Replace target_executing
by any_running.
* mi/mi-main.c (mi_cmd_exec_interrupt, mi_cmd_execute)
(mi_execute_async_cli_command): Replace target_executing by
is_running.
* frame.c (get_current_frame): Error out if the current thread is
executing.
(has_stack_frames): New.
(get_selected_frame, deprecated_safe_get_selected_frame): Check
has_stack_frames.
* Makefile.in (event-top.o, frame.o, inf-loop.o, top.o): Depend on
$(gdbthread_h).
Diffstat (limited to 'gdb/thread.c')
-rw-r--r-- | gdb/thread.c | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/gdb/thread.c b/gdb/thread.c index aa18228..9bd5f04 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -63,6 +63,9 @@ static void thread_apply_command (char *, int); static void restore_current_thread (ptid_t); static void prune_threads (void); +static int main_thread_running = 0; +static int main_thread_executing = 0; + void delete_step_resume_breakpoint (void *arg) { @@ -104,6 +107,9 @@ init_thread_list (void) struct thread_info *tp, *tpnext; highest_thread_num = 0; + main_thread_running = 0; + main_thread_executing = 0; + if (!thread_list) return; @@ -441,8 +447,6 @@ prune_threads (void) } } -static int main_thread_running = 0; - void set_running (ptid_t ptid, int running) { @@ -494,6 +498,9 @@ is_running (ptid_t ptid) { struct thread_info *tp; + if (!target_has_execution) + return 0; + if (!thread_list) return main_thread_running; @@ -502,6 +509,67 @@ is_running (ptid_t ptid) return tp->running_; } +int +any_running (void) +{ + struct thread_info *tp; + + if (!target_has_execution) + return 0; + + if (!thread_list) + return main_thread_running; + + for (tp = thread_list; tp; tp = tp->next) + if (tp->running_) + return 1; + + return 0; +} + +int +is_executing (ptid_t ptid) +{ + struct thread_info *tp; + + if (!target_has_execution) + return 0; + + if (!thread_list) + return main_thread_executing; + + tp = find_thread_pid (ptid); + gdb_assert (tp); + return tp->executing_; +} + +void +set_executing (ptid_t ptid, int executing) +{ + struct thread_info *tp; + + if (!thread_list) + { + /* This target does not add the main thread to the thread list. + Use a global flag to indicate that the thread is + executing. */ + main_thread_executing = executing; + return; + } + + if (PIDGET (ptid) == -1) + { + for (tp = thread_list; tp; tp = tp->next) + tp->executing_ = executing; + } + else + { + tp = find_thread_pid (ptid); + gdb_assert (tp); + tp->executing_ = executing; + } +} + /* Prints the list of threads and their details on UIOUT. This is a version of 'info_thread_command' suitable for use from MI. |