aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2008-04-17 00:25:01 +0000
committerTom Tromey <tromey@redhat.com>2008-04-17 00:25:01 +0000
commit700b53b17a52448cb49f04a4e27d5f0130537924 (patch)
treec6c9be0bfe988471b3e3c8c23096b7669d8c202d /gdb
parentf3c69fcab18257246fa945f4a85388b54a34e512 (diff)
downloadgdb-700b53b17a52448cb49f04a4e27d5f0130537924.zip
gdb-700b53b17a52448cb49f04a4e27d5f0130537924.tar.gz
gdb-700b53b17a52448cb49f04a4e27d5f0130537924.tar.bz2
* cli/cli-decode.h (CMD_ASYNC_OK): New define.
(set_cmd_async_ok, get_cmd_async_ok): Declare. * cli/cli-decode.c (set_cmd_async_ok): New function. (get_cmd_async_ok): New function. * cli/cli-cmds.c (init_cli_cmds): Mark "pwd", "help", "info", and "show" as async-ok. * top.c (execute_command): Use get_cmd_async_ok. * infcmd.c: Include cli/cli-decode.h. (_initialize_infcmd): Mark "interrupt" as async-ok. * Makefile.in (infcmd.o): Depend on cli_decode_h.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/Makefile.in2
-rw-r--r--gdb/cli/cli-cmds.c16
-rw-r--r--gdb/cli/cli-decode.c12
-rw-r--r--gdb/cli/cli-decode.h10
-rw-r--r--gdb/infcmd.c6
-rw-r--r--gdb/top.c9
7 files changed, 52 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dbdf4e5..595f418 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+2008-04-16 Tom Tromey <tromey@redhat.com>
+
+ * cli/cli-decode.h (CMD_ASYNC_OK): New define.
+ (set_cmd_async_ok, get_cmd_async_ok): Declare.
+ * cli/cli-decode.c (set_cmd_async_ok): New function.
+ (get_cmd_async_ok): New function.
+ * cli/cli-cmds.c (init_cli_cmds): Mark "pwd", "help", "info", and
+ "show" as async-ok.
+ * top.c (execute_command): Use get_cmd_async_ok.
+ * infcmd.c: Include cli/cli-decode.h.
+ (_initialize_infcmd): Mark "interrupt" as async-ok.
+ * Makefile.in (infcmd.o): Depend on cli_decode_h.
+
2008-04-16 Daniel Jacobowitz <dan@codesourcery.com>
PR gdb/2445
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 6cd77f1..bdee30d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2314,7 +2314,7 @@ infcmd.o: infcmd.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
$(objfiles_h) $(completer_h) $(ui_out_h) $(event_top_h) \
$(parser_defs_h) $(regcache_h) $(reggroups_h) $(block_h) \
$(solib_h) $(gdb_assert_h) $(observer_h) $(target_descriptions_h) \
- $(user_regs_h) $(exceptions_h)
+ $(user_regs_h) $(exceptions_h) $(cli_decode_h)
inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
$(event_top_h) $(inf_loop_h) $(remote_h) $(exceptions_h) \
$(language_h)
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 96abe8c..ce7378e 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1202,8 +1202,9 @@ The commands below can be used to select other frames by number or address."),
/* Define general commands. */
- add_com ("pwd", class_files, pwd_command, _("\
+ c = add_com ("pwd", class_files, pwd_command, _("\
Print working directory. This is used for your program as well."));
+ set_cmd_async_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\
@@ -1243,6 +1244,7 @@ when GDB is started."), gdbinit);
c = add_com ("help", class_support, help_command,
_("Print list of commands."));
set_cmd_completer (c, command_completer);
+ set_cmd_async_ok (c);
add_com_alias ("q", "quit", class_support, 1);
add_com_alias ("h", "help", class_support, 1);
@@ -1268,17 +1270,19 @@ Without an argument, history expansion is enabled."),
show_history_expansion_p,
&sethistlist, &showhistlist);
- add_prefix_cmd ("info", class_info, info_command, _("\
+ c = add_prefix_cmd ("info", class_info, info_command, _("\
Generic command for showing things about the program being debugged."),
- &infolist, "info ", 0, &cmdlist);
+ &infolist, "info ", 0, &cmdlist);
+ set_cmd_async_ok (c);
add_com_alias ("i", "info", class_info, 1);
add_com ("complete", class_obscure, complete_command,
_("List the completions for the rest of the line as a command."));
- add_prefix_cmd ("show", class_info, show_command,
- _("Generic command for showing things about the debugger."),
- &showlist, "show ", 0, &cmdlist);
+ c = add_prefix_cmd ("show", class_info, show_command, _("\
+Generic command for showing things about the debugger."),
+ &showlist, "show ", 0, &cmdlist);
+ set_cmd_async_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 65fcdcc..4e68f93 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -105,6 +105,18 @@ get_cmd_context (struct cmd_list_element *cmd)
return cmd->context;
}
+void
+set_cmd_async_ok (struct cmd_list_element *cmd)
+{
+ cmd->flags |= CMD_ASYNC_OK;
+}
+
+int
+get_cmd_async_ok (struct cmd_list_element *cmd)
+{
+ return cmd->flags & CMD_ASYNC_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 59a8239..f133b3d 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -48,6 +48,9 @@ cmd_types;
#define DEPRECATED_WARN_USER 0x2
#define MALLOCED_REPLACEMENT 0x4
+/* This flag is set if the command is allowed during async execution. */
+#define CMD_ASYNC_OK 0x8
+
struct cmd_list_element
{
/* Points to next command in this list. */
@@ -243,6 +246,13 @@ extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
extern void *get_cmd_context (struct cmd_list_element *cmd);
+/* Mark command as async-ready; there is no way to disable this once
+ set. */
+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 *);
+
extern struct cmd_list_element *lookup_cmd (char **,
struct cmd_list_element *, char *,
int, int);
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index f72cbf4..2c30b7e 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -49,6 +49,7 @@
#include "target-descriptions.h"
#include "user-regs.h"
#include "exceptions.h"
+#include "cli/cli-decode.h"
/* Functions exported for general use, in inferior.h: */
@@ -2326,8 +2327,9 @@ You may specify arguments to give to your program, just as with the\n\
\"run\" command."));
set_cmd_completer (c, filename_completer);
- add_com ("interrupt", class_run, interrupt_target_command,
- _("Interrupt the execution of the debugged program."));
+ c = add_com ("interrupt", class_run, interrupt_target_command,
+ _("Interrupt the execution of the debugged program."));
+ set_cmd_async_ok (c);
add_info ("registers", nofp_registers_info, _("\
List of integer registers and their contents, for selected stack frame.\n\
diff --git a/gdb/top.c b/gdb/top.c
index 418ff8e..d9b5ce4 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -458,13 +458,8 @@ execute_command (char *p, int from_tty)
/* If the target is running, we allow only a limited set of
commands. */
- if (target_can_async_p () && target_executing)
- if (strcmp (c->name, "help") != 0
- && strcmp (c->name, "pwd") != 0
- && strcmp (c->name, "show") != 0
- && strcmp (c->name, "info") != 0
- && strcmp (c->name, "interrupt") != 0)
- error (_("Cannot execute this command while the target is running."));
+ if (target_can_async_p () && target_executing && !get_cmd_async_ok (c))
+ error (_("Cannot execute this command while the target is running."));
/* Pass null arg rather than an empty one. */
arg = *p ? p : 0;