diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f0662ff..4227f31 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -35088,8 +35088,13 @@ default shows this information when you start an interactive session. -info-gdb-mi-command @var{cmd_name} @end smallexample -Query support for the @sc{gdb/mi} command named @var{cmd_name} -(the leading dash (@code{-}) in the command name should be omitted). +Query support for the @sc{gdb/mi} command named @var{cmd_name}. + +Note that the dash (@code{-}) starting all @sc{gdb/mi} commands +is technically not part of the command name (@pxref{GDB/MI Input +Syntax}), and thus should be omitted in @var{cmd_name}. However, +for ease of use, this command also accepts the form with the leading +dash. @subsubheading @value{GDBN} Command @@ -35120,6 +35120,7 @@ Here is an example where the @sc{gdb/mi} command does not exist: ^done,command=@{exists="false"@} @end smallexample +@noindent And here is an example where the @sc{gdb/mi} command is known to the debugger: diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c index 18f4927..0fce25a 100644 --- a/gdb/mi/mi-cmd-info.c +++ b/gdb/mi/mi-cmd-info.c @@ -85,6 +85,14 @@ mi_cmd_info_gdb_mi_command (char *command, char **argv, int argc) 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"); diff --git a/gdb/testsuite/gdb.mi/mi-i-cmd.exp b/gdb/testsuite/gdb.mi/mi-i-cmd.exp index 5285d31..d460559 100644 --- a/gdb/testsuite/gdb.mi/mi-i-cmd.exp +++ b/gdb/testsuite/gdb.mi/mi-i-cmd.exp @@ -31,7 +31,16 @@ mi_gdb_test "-info-gdb-mi-command unsupported-command" \ "\\^done,command=\\\{exists=\"false\"\\\}" \ "-info-gdb-mi-command unsupported-command" +# Same test as above, but including the leading '-' in the command name. +mi_gdb_test "-info-gdb-mi-command -unsupported-command" \ + "\\^done,command=\\\{exists=\"false\"\\\}" \ + "-info-gdb-mi-command -unsupported-command" + mi_gdb_test "-info-gdb-mi-command symbol-list-lines" \ "\\^done,command=\\\{exists=\"true\"\\\}" \ "-info-gdb-mi-command symbol-list-lines" +# Same test as above, but including the leading '-' in the command name. +mi_gdb_test "-info-gdb-mi-command -symbol-list-lines" \ + "\\^done,command=\\\{exists=\"true\"\\\}" \ + "-info-gdb-mi-command -symbol-list-lines"