2012-05-24 00:33:47 +00:00
|
|
|
/* MI Command Set - information commands.
|
2013-01-01 06:33:28 +00:00
|
|
|
Copyright (C) 2011-2013 Free Software Foundation, Inc.
|
2012-05-24 00:33:47 +00:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "osdata.h"
|
|
|
|
#include "mi-cmds.h"
|
Implement GDB/MI equivalent of "info exceptions" CLI command.
This patch implements a new GDB/MI command implementing the equivalent
of the "info exceptions" CLI command. The command syntax is:
-info-ada-exceptions [REGEXP]
Here is an example of usage (slightly formatted by hand to make it
easier to read):
-info-ada-exceptions ions\.a_
^done,ada-exceptions=
{nr_rows="2",nr_cols="2",
hdr=[{width="1",alignment="-1",col_name="name",colhdr="Name"},
{width="1",alignment="-1",col_name="address",colhdr="Address"}],
body=[{name="global_exceptions.a_global_exception",
address="0x0000000000613a80"},
{name="global_exceptions.a_private_exception",
address="0x0000000000613ac0"}]}
Also, in order to allow graphical frontends to easily determine
whether this command is available or not, the output of the
"-list-features" command has been augmented to contain
"info-ada-exceptions".
gdb/Changelog:
* mi/mi-cmds.h (mi_cmd_info_ada_exceptions): Add declaration.
* mi/mi-cmds.c (mi_cmds): Add entry for -info-ada-exceptions
command.
* mi/mi-cmd-info.c: #include "ada-lang.c" and "arch-utils.c".
(mi_cmd_info_ada_exceptions): New function.
* mi/mi-main.c (mi_cmd_list_features): Add "info-ada-exceptions".
gdb/testsuite/ChangeLog:
* gdb.ada/mi_exc_info: New testcase.
2013-11-07 13:15:46 +00:00
|
|
|
#include "ada-lang.h"
|
|
|
|
#include "arch-utils.h"
|
|
|
|
|
|
|
|
/* Implement the "-info-ada-exceptions" GDB/MI command. */
|
|
|
|
|
|
|
|
void
|
|
|
|
mi_cmd_info_ada_exceptions (char *command, char **argv, int argc)
|
|
|
|
{
|
|
|
|
struct ui_out *uiout = current_uiout;
|
|
|
|
struct gdbarch *gdbarch = get_current_arch ();
|
|
|
|
char *regexp;
|
|
|
|
struct cleanup *old_chain;
|
|
|
|
VEC(ada_exc_info) *exceptions;
|
|
|
|
int ix;
|
|
|
|
struct ada_exc_info *info;
|
|
|
|
|
|
|
|
switch (argc)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
regexp = NULL;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
regexp = argv[0];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error (_("Usage: -info-ada-exceptions [REGEXP]"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
exceptions = ada_exceptions_list (regexp);
|
|
|
|
old_chain = make_cleanup (VEC_cleanup (ada_exc_info), &exceptions);
|
|
|
|
|
|
|
|
make_cleanup_ui_out_table_begin_end
|
|
|
|
(uiout, 2, VEC_length (ada_exc_info, exceptions), "ada-exceptions");
|
|
|
|
ui_out_table_header (uiout, 1, ui_left, "name", "Name");
|
|
|
|
ui_out_table_header (uiout, 1, ui_left, "address", "Address");
|
|
|
|
ui_out_table_body (uiout);
|
|
|
|
|
|
|
|
for (ix = 0; VEC_iterate(ada_exc_info, exceptions, ix, info); ix++)
|
|
|
|
{
|
|
|
|
struct cleanup *sub_chain;
|
|
|
|
|
|
|
|
sub_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
|
|
|
|
ui_out_field_string (uiout, "name", info->name);
|
|
|
|
ui_out_field_core_addr (uiout, "address", gdbarch, info->addr);
|
|
|
|
|
|
|
|
do_cleanups (sub_chain);
|
|
|
|
}
|
|
|
|
|
|
|
|
do_cleanups (old_chain);
|
|
|
|
}
|
2012-05-24 00:33:47 +00:00
|
|
|
|
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.
2013-11-12 10:51:30 +00:00
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
2012-05-24 00:33:47 +00:00
|
|
|
void
|
|
|
|
mi_cmd_info_os (char *command, char **argv, int argc)
|
|
|
|
{
|
|
|
|
switch (argc)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
info_osdata_command ("", 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
info_osdata_command (argv[0], 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error (_("Usage: -info-os [INFOTYPE]"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|