aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2008-07-11 11:07:39 +0000
committerPedro Alves <palves@redhat.com>2008-07-11 11:07:39 +0000
commit4f8d22e3b4e0e9a71f94f24deb77d2f4753deb85 (patch)
tree2c8b6857cf1322ed3a4f1d17b143dcec74ef164d /gdb/cli
parent8cae4b3f0b7457fe342df1784b21e2a48086db83 (diff)
downloadgdb-4f8d22e3b4e0e9a71f94f24deb77d2f4753deb85.zip
gdb-4f8d22e3b4e0e9a71f94f24deb77d2f4753deb85.tar.gz
gdb-4f8d22e3b4e0e9a71f94f24deb77d2f4753deb85.tar.bz2
Exited threads.
* thread.c (enum thread_state): New. (thread_state main_thread_running): Delete, in favor of... (thread_state main_thread_state): ... this. Update throughout. (clear_thread_inferior_resources): New, split from free_thread. (free_thread): Call clear_thread_inferior_resources. (init_thread_list): Set main thread to stopped state. (add_thread_silent): Take care of PTID reuses. (delete_thread): If deleting inferior_ptid or a thread with refcount > 0, mark it as exited, but still keep it in the list. Only notify of thread exits, if we haven't done so yet. (iterate_over_threads): Make it safe to delete threads while iterating over them. (do_captured_list_thread_ids): Don't account for exited threads. (thread_alive): Check for the THREAD_EXITED state, and don't set ptid to -1 on exited threads. (set_running): Update to account for extra possible states. (is_thread_state): New. (is_stopped, is_exited): New. (is_running): Implement in terms of is_thread_state. (any_running): Update. (print_thread_info): Update. Account for exited threads. Don't warn about missed frame restoring here, its done in the cleanup. (switch_to_thread): Don't read from a thread that has gone. (restore_current_thread): In non-stop mode, do a full context switch. (restore_selected_frame): Add a frame_level argument. Rewrite. (struct current_thread_cleanup): Add selected_frame_level and was_stopped members. (do_restore_current_thread_cleanup): Check if thread was stopped and still is, and if the target has registers, stack and memory before restoring the selected frame. Don't delete the cleanup argument here. (restore_current_thread_cleanup_dtor): New. (make_cleanup_restore_current_thread): Remove all arguments. Rewrite. (thread_apply_all_command): Update. Prune threads. (thread_apply_command): Update. (thread_command): Account for currently selected exited thread. (do_captured_thread_select): Check for a running thread. Prune threads. (_initialize_thread): Make "info threads", "thread", "thread apply", and "thread apply all" appliable without a selected thread. * gdbthread.h (struct thread_info): Replace running_ by state_. Add refcount. (is_exited, is_stopped): Declare. (make_cleanup_restore_current_thread): Remove all arguments. * infrun.c: Include "event-top.h". (fetch_inferior_event): In non-stop mode, restore selected thread and frame after handling the event and running breakpoint commands. Display GDB prompt if needed. (normal_stop): In non-stop mode, don't print thread switching notice. * cli/cli-decode.c (set_cmd_no_selected_thread_ok) (get_cmd_no_selected_thread_ok): New. * cli/cli-decode.h (CMD_NO_SELECTED_THREAD_OK): New. (set_cmd_no_selected_thread_ok, get_cmd_no_selected_thread_ok): Declare. * cli/cli-cmds.c: Set "pwd", "help", "info", "show" as no-selected-thread ok. * top.c (execute_command): Check for non no-selected-thread-ok commands. * linux-nat.c (struct saved_ptids, threads_to_delete) (record_dead_thread, prune_lwps): Delete. (exit_lwp): Unconditionally delete thread. (linux_nat_resume): Remove prune_lwps call. * infcmd.c (proceed_thread_callback): Check if !is_stopped instead of is_running. Adjust to make_cleanup_restore_current_thread interface change. * mi/mi-main.c (mi_cmd_execute): Only allow a few commands if the selected thread has exited. * inf-loop.c (inferior_event_handler): Don't display the prompt here. * varobj.c (c_value_of_root): Update. * defs.h (make_cleanup_dtor): Declare. * utils.c (make_cleanup_dtor): New. * Makefile.in (infrun.o): Depend on $(event_top_h).
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c5
-rw-r--r--gdb/cli/cli-decode.c12
-rw-r--r--gdb/cli/cli-decode.h11
3 files changed, 28 insertions, 0 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index b0f5fa0..efd3137 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1245,6 +1245,8 @@ The commands below can be used to select other frames by number or address."),
c = add_com ("pwd", class_files, pwd_command, _("\
Print working directory. This is used for your program as well."));
set_cmd_async_ok (c);
+ set_cmd_no_selected_thread_ok (c);
+
c = add_cmd ("cd", class_files, cd_command, _("\
Set working directory to DIR for debugger and program being debugged.\n\
The change does not take effect for the program being debugged\n\
@@ -1285,6 +1287,7 @@ when GDB is started."), gdbinit);
_("Print list of commands."));
set_cmd_completer (c, command_completer);
set_cmd_async_ok (c);
+ set_cmd_no_selected_thread_ok (c);
add_com_alias ("q", "quit", class_support, 1);
add_com_alias ("h", "help", class_support, 1);
@@ -1314,6 +1317,7 @@ Without an argument, history expansion is enabled."),
Generic command for showing things about the program being debugged."),
&infolist, "info ", 0, &cmdlist);
set_cmd_async_ok (c);
+ set_cmd_no_selected_thread_ok (c);
add_com_alias ("i", "info", class_info, 1);
add_com ("complete", class_obscure, complete_command,
@@ -1323,6 +1327,7 @@ Generic command for showing things about the program being debugged."),
Generic command for showing things about the debugger."),
&showlist, "show ", 0, &cmdlist);
set_cmd_async_ok (c);
+ set_cmd_no_selected_thread_ok (c);
/* Another way to get at the same thing. */
add_info ("set", show_command, _("Show all GDB settings."));
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 05a0b27..07bb587 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -117,6 +117,18 @@ get_cmd_async_ok (struct cmd_list_element *cmd)
return cmd->flags & CMD_ASYNC_OK;
}
+void
+set_cmd_no_selected_thread_ok (struct cmd_list_element *cmd)
+{
+ cmd->flags |= CMD_NO_SELECTED_THREAD_OK;
+}
+
+int
+get_cmd_no_selected_thread_ok (struct cmd_list_element *cmd)
+{
+ return cmd->flags & CMD_NO_SELECTED_THREAD_OK;
+}
+
enum cmd_types
cmd_type (struct cmd_list_element *cmd)
{
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index f133b3d..c790398 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -51,6 +51,10 @@ cmd_types;
/* This flag is set if the command is allowed during async execution. */
#define CMD_ASYNC_OK 0x8
+/* This flag is set if the command is allowed to run when the target
+ has execution, but there's no selected thread. */
+#define CMD_NO_SELECTED_THREAD_OK 0x10
+
struct cmd_list_element
{
/* Points to next command in this list. */
@@ -253,6 +257,13 @@ extern void set_cmd_async_ok (struct cmd_list_element *);
/* Return true if command is async-ok. */
extern int get_cmd_async_ok (struct cmd_list_element *);
+/* Mark command as ok to call when there is no selected thread. There
+ is no way to disable this once set. */
+extern void set_cmd_no_selected_thread_ok (struct cmd_list_element *);
+
+/* Return true if command is no-selected-thread-ok. */
+extern int get_cmd_no_selected_thread_ok (struct cmd_list_element *);
+
extern struct cmd_list_element *lookup_cmd (char **,
struct cmd_list_element *, char *,
int, int);