binutils-gdb/gdb/mi
Joel Brobecker 2ea126fa78 Add "undefined-command" error code at end of ^error result...
... when trying to execute an undefined GDB/MI command. When trying
to execute a GDB/MI command which does not exist, the current error
result record looks like this:

    -unsupported
    ^error,msg="Undefined MI command: unsupported"

The only indication that the command does not exist is the error
message. It would be a little fragile for a consumer to rely solely
on the contents of the error message in order to determine whether
a command exists or not.

This patch improves the situation by adding concept of error
code, starting with one well-defined error code ("undefined-command")
identifying errors due to a non-existant command. Here is the new
output:

    -unsupported
    ^error,msg="Undefined MI command: unsupported",code="undefined-command"

This error code is only displayed when the corresponding error
condition is met. Otherwise, the error record remains unchanged.
For instance:

    -symbol-list-lines foo.adb
    ^error,msg="-symbol-list-lines: Unknown source file name."

For frontends to be able to know whether they can rely on this
variable, a new entry "undefined-command-error-code" has been
added to the "-list-features" command.  Another option would be
to always generate an error="..." variable (for the default case,
we could decide for instance that the error code is the empty string).
But it seems more efficient to provide that info in "-list-features"
and then only add the error code when meaningful.

gdb/ChangeLog:

        (from Pedro Alves  <palves@redhat.com>)
        (from Joel Brobecker  <brobecker@adacore.com>)
        * exceptions.h (enum_errors) <UNDEFINED_COMMAND_ERROR>: New enum.
        * mi/mi-parse.c (mi_parse): Throw UNDEFINED_COMMAND_ERROR instead
        of a regular error when the GDB/MI command does not exist.
        * mi/mi-main.c (mi_cmd_list_features): Add
        "undefined-command-error-code".
        (mi_print_exception): Print an "undefined-command"
        error code if EXCEPTION.ERROR is UNDEFINED_COMMAND_ERROR.
        * NEWS: Add entry documenting the new "code" variable in
        "^error" result records.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Result Records): Fix the syntax of the
        "^error" result record concerning the error message.  Document
        the error code that may also be part of that result record.
        (GDB/MI Miscellaneous Commands): Document the
        "undefined-command-error-code" element in the output of
        the "-list-features" GDB/MI command.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-undefined-cmd.exp: New testcase.
2013-12-03 08:01:01 +04:00
..
ChangeLog-1999-2003
mi-cmd-break.c remove gdb_string.h 2013-11-18 13:29:00 -07:00
mi-cmd-break.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi-cmd-catch.c Dandling memory pointers in Ada catchpoints with GDB/MI. 2013-11-11 19:19:07 +04:00
mi-cmd-disas.c remove gdb_string.h 2013-11-18 13:29:00 -07:00
mi-cmd-env.c remove gdb_stat.h 2013-11-18 13:29:02 -07:00
mi-cmd-file.c gdb/ 2013-02-03 16:13:31 +00:00
mi-cmd-info.c New GDB/MI command "-info-gdb-mi-command" 2013-12-03 07:57:24 +04:00
mi-cmd-stack.c remove gdb_string.h 2013-11-18 13:29:00 -07:00
mi-cmd-target.c Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi-cmd-var.c remove gdb_string.h 2013-11-18 13:29:00 -07:00
mi-cmds.c New GDB/MI command "-info-gdb-mi-command" 2013-12-03 07:57:24 +04:00
mi-cmds.h New GDB/MI command "-info-gdb-mi-command" 2013-12-03 07:57:24 +04:00
mi-common.c Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi-common.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi-console.c remove gdb_string.h 2013-11-18 13:29:00 -07:00
mi-console.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi-getopt.c remove gdb_string.h 2013-11-18 13:29:00 -07:00
mi-getopt.h Add mi_getopt_allow_unknown 2013-08-27 03:04:45 +00:00
mi-interp.c remove gdb_string.h 2013-11-18 13:29:00 -07:00
mi-main.c Add "undefined-command" error code at end of ^error result... 2013-12-03 08:01:01 +04:00
mi-main.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi-out.c Add support for a destructor for ui_out data and use it to 2013-02-12 01:47:49 +00:00
mi-out.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi-parse.c Add "undefined-command" error code at end of ^error result... 2013-12-03 08:01:01 +04:00
mi-parse.h GDB/MI: Add new "--language LANG" command option. 2013-11-14 14:36:18 +04:00
mi-symbol-cmds.c Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00