gdb/mi/mi-cmd-info.c - gdb

Functions defined

Source code

  1. /* MI Command Set - information commands.
  2.    Copyright (C) 2011-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "osdata.h"
  16. #include "mi-cmds.h"
  17. #include "ada-lang.h"
  18. #include "arch-utils.h"

  19. /* Implement the "-info-ada-exceptions" GDB/MI command.  */

  20. void
  21. mi_cmd_info_ada_exceptions (char *command, char **argv, int argc)
  22. {
  23.   struct ui_out *uiout = current_uiout;
  24.   struct gdbarch *gdbarch = get_current_arch ();
  25.   char *regexp;
  26.   struct cleanup *old_chain;
  27.   VEC(ada_exc_info) *exceptions;
  28.   int ix;
  29.   struct ada_exc_info *info;

  30.   switch (argc)
  31.     {
  32.     case 0:
  33.       regexp = NULL;
  34.       break;
  35.     case 1:
  36.       regexp = argv[0];
  37.       break;
  38.     default:
  39.       error (_("Usage: -info-ada-exceptions [REGEXP]"));
  40.       break;
  41.     }

  42.   exceptions = ada_exceptions_list (regexp);
  43.   old_chain = make_cleanup (VEC_cleanup (ada_exc_info), &exceptions);

  44.   make_cleanup_ui_out_table_begin_end
  45.     (uiout, 2, VEC_length (ada_exc_info, exceptions), "ada-exceptions");
  46.   ui_out_table_header (uiout, 1, ui_left, "name", "Name");
  47.   ui_out_table_header (uiout, 1, ui_left, "address", "Address");
  48.   ui_out_table_body (uiout);

  49.   for (ix = 0; VEC_iterate(ada_exc_info, exceptions, ix, info); ix++)
  50.     {
  51.       struct cleanup *sub_chain;

  52.       sub_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
  53.       ui_out_field_string (uiout, "name", info->name);
  54.       ui_out_field_core_addr (uiout, "address", gdbarch, info->addr);

  55.       do_cleanups (sub_chain);
  56.     }

  57.   do_cleanups (old_chain);
  58. }

  59. /* Implement the "-info-gdb-mi-command" GDB/MI command.  */

  60. void
  61. mi_cmd_info_gdb_mi_command (char *command, char **argv, int argc)
  62. {
  63.   const char *cmd_name;
  64.   struct mi_cmd *cmd;
  65.   struct ui_out *uiout = current_uiout;
  66.   struct cleanup *old_chain;

  67.   /* This command takes exactly one argument.  */
  68.   if (argc != 1)
  69.     error (_("Usage: -info-gdb-mi-command MI_COMMAND_NAME"));
  70.   cmd_name = argv[0];

  71.   /* Normally, the command name (aka the "operation" in the GDB/MI
  72.      grammar), does not include the leading '-' (dash).  But for
  73.      the user's convenience, allow the user to specify the command
  74.      name to be with or without that leading dash.  */
  75.   if (cmd_name[0] == '-')
  76.     cmd_name++;

  77.   cmd = mi_lookup (cmd_name);

  78.   old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "command");
  79.   ui_out_field_string (uiout, "exists", cmd != NULL ? "true" : "false");
  80.   do_cleanups (old_chain);
  81. }

  82. void
  83. mi_cmd_info_os (char *command, char **argv, int argc)
  84. {
  85.   switch (argc)
  86.     {
  87.     case 0:
  88.       info_osdata_command ("", 0);
  89.       break;
  90.     case 1:
  91.       info_osdata_command (argv[0], 0);
  92.       break;
  93.     default:
  94.       error (_("Usage: -info-os [INFOTYPE]"));
  95.       break;
  96.     }
  97. }