aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2013-11-12 14:51:30 +0400
committerJoel Brobecker <brobecker@adacore.com>2013-12-03 07:57:24 +0400
commit6b7cbff192a5335b96fdcf887b32fc6e0100b6ef (patch)
tree6e8f221ca966fa25c1cdb91156283229bb73268a /gdb/mi
parent310bf259c3524c29542f01514bae4be2f21d903e (diff)
downloadgdb-6b7cbff192a5335b96fdcf887b32fc6e0100b6ef.zip
gdb-6b7cbff192a5335b96fdcf887b32fc6e0100b6ef.tar.gz
gdb-6b7cbff192a5335b96fdcf887b32fc6e0100b6ef.tar.bz2
New GDB/MI command "-info-gdb-mi-command"
This patch adds a new GDB/MI command meant for graphical frontends trying to determine whether a given GDB/MI command exists or not. Examples: -info-gdb-mi-command unsupported-command ^done,command={exists="false"} (gdb) -info-gdb-mi-command symbol-list-lines ^done,command={exists="true"} (gdb) At the moment, this is the only piece of information that this command returns. Eventually, and if needed, we can extend it to provide command-specific pieces of information, such as updates to the command's syntax since inception. This could become, for instance: -info-gdb-mi-command symbol-list-lines ^done,command={exists="true",features=[]} (gdb) -info-gdb-mi-command catch-assert ^done,command={exists="true",features=["conditions"]} In the first case, it would mean that no extra features, while in the second, it announces that the -catch-assert command in this version of the debugger supports a feature called "condition" - exact semantics to be documented with combined with the rest of the queried command's documentation. But for now, we start small, and only worry about existance. And to bootstrap the process, I have added an entry in the output of the -list-features command as well ("info-gdb-mi-command"), allowing the graphical frontends to go through the following process: 1. Send -list-features, collect info from there as before; 2. Check if the output contains "info-gdb-mi-command". If it does, then support for various commands can be queried though -info-gdb-mi-command. Newer commands will be expected to always be checked via this new -info-gdb-mi-command. gdb/ChangeLog: * mi/mi-cmds.h (mi_cmd_info_gdb_mi_command): Declare. * mi/mi-cmd-info.c (mi_cmd_info_gdb_mi_command): New function. * mi/mi-cmds.c (mi_cmds): Add -info-gdb-mi-command command. * mi/mi-main.c (mi_cmd_list_features): Add "info-gdb-mi-command" field to output of "-list-features". * NEWS: Add entry for new -info-gdb-mi-command. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new -info-gdb-mi-command GDB/MI command. Document the meaning of "-info-gdb-mi-command" in the output of -list-features. gdb/testsuite/ChangeLog: * gdb.mi/mi-i-cmd.exp: New file.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-info.c29
-rw-r--r--gdb/mi/mi-cmds.c1
-rw-r--r--gdb/mi/mi-cmds.h1
-rw-r--r--gdb/mi/mi-main.c1
4 files changed, 32 insertions, 0 deletions
diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c
index aa4d210..0fce25a 100644
--- a/gdb/mi/mi-cmd-info.c
+++ b/gdb/mi/mi-cmd-info.c
@@ -71,6 +71,35 @@ mi_cmd_info_ada_exceptions (char *command, char **argv, int argc)
do_cleanups (old_chain);
}
+/* Implement the "-info-gdb-mi-command" GDB/MI command. */
+
+void
+mi_cmd_info_gdb_mi_command (char *command, char **argv, int argc)
+{
+ const char *cmd_name;
+ struct mi_cmd *cmd;
+ struct ui_out *uiout = current_uiout;
+ struct cleanup *old_chain;
+
+ /* This command takes exactly one argument. */
+ if (argc != 1)
+ error (_("Usage: -info-gdb-mi-command MI_COMMAND_NAME"));
+ cmd_name = argv[0];
+
+ /* Normally, the command name (aka the "operation" in the GDB/MI
+ grammar), does not include the leading '-' (dash). But for
+ the user's convenience, allow the user to specify the command
+ name to be with or without that leading dash. */
+ if (cmd_name[0] == '-')
+ cmd_name++;
+
+ cmd = mi_lookup (cmd_name);
+
+ old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "command");
+ ui_out_field_string (uiout, "exists", cmd != NULL ? "true" : "false");
+ do_cleanups (old_chain);
+}
+
void
mi_cmd_info_os (char *command, char **argv, int argc)
{
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index c536d8a..58a8b89 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -125,6 +125,7 @@ static struct mi_cmd mi_cmds[] =
DEF_MI_CMD_MI ("inferior-tty-set", mi_cmd_inferior_tty_set),
DEF_MI_CMD_MI ("inferior-tty-show", mi_cmd_inferior_tty_show),
DEF_MI_CMD_MI ("info-ada-exceptions", mi_cmd_info_ada_exceptions),
+ DEF_MI_CMD_MI ("info-gdb-mi-command", mi_cmd_info_gdb_mi_command),
DEF_MI_CMD_MI ("info-os", mi_cmd_info_os),
DEF_MI_CMD_MI ("interpreter-exec", mi_cmd_interpreter_exec),
DEF_MI_CMD_MI ("list-features", mi_cmd_list_features),
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index cb8aac1..4ea95fa 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -74,6 +74,7 @@ extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
extern mi_cmd_argv_ftype mi_cmd_inferior_tty_set;
extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show;
extern mi_cmd_argv_ftype mi_cmd_info_ada_exceptions;
+extern mi_cmd_argv_ftype mi_cmd_info_gdb_mi_command;
extern mi_cmd_argv_ftype mi_cmd_info_os;
extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
extern mi_cmd_argv_ftype mi_cmd_list_features;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 793204d..48c8d09 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1817,6 +1817,7 @@ mi_cmd_list_features (char *command, char **argv, int argc)
ui_out_field_string (uiout, NULL, "ada-task-info");
ui_out_field_string (uiout, NULL, "ada-exceptions");
ui_out_field_string (uiout, NULL, "language-option");
+ ui_out_field_string (uiout, NULL, "info-gdb-mi-command");
#if HAVE_PYTHON
if (gdb_python_initialized)