GDB (xrefs)
mi-cmd-info.c
Go to the documentation of this file.
1 /* MI Command Set - information commands.
2  Copyright (C) 2011-2015 Free Software Foundation, Inc.
3 
4  This file is part of GDB.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 
19 #include "defs.h"
20 #include "osdata.h"
21 #include "mi-cmds.h"
22 #include "ada-lang.h"
23 #include "arch-utils.h"
24 
25 /* Implement the "-info-ada-exceptions" GDB/MI command. */
26 
27 void
28 mi_cmd_info_ada_exceptions (char *command, char **argv, int argc)
29 {
30  struct ui_out *uiout = current_uiout;
31  struct gdbarch *gdbarch = get_current_arch ();
32  char *regexp;
33  struct cleanup *old_chain;
34  VEC(ada_exc_info) *exceptions;
35  int ix;
36  struct ada_exc_info *info;
37 
38  switch (argc)
39  {
40  case 0:
41  regexp = NULL;
42  break;
43  case 1:
44  regexp = argv[0];
45  break;
46  default:
47  error (_("Usage: -info-ada-exceptions [REGEXP]"));
48  break;
49  }
50 
51  exceptions = ada_exceptions_list (regexp);
52  old_chain = make_cleanup (VEC_cleanup (ada_exc_info), &exceptions);
53 
55  (uiout, 2, VEC_length (ada_exc_info, exceptions), "ada-exceptions");
56  ui_out_table_header (uiout, 1, ui_left, "name", "Name");
57  ui_out_table_header (uiout, 1, ui_left, "address", "Address");
58  ui_out_table_body (uiout);
59 
60  for (ix = 0; VEC_iterate(ada_exc_info, exceptions, ix, info); ix++)
61  {
62  struct cleanup *sub_chain;
63 
64  sub_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
65  ui_out_field_string (uiout, "name", info->name);
66  ui_out_field_core_addr (uiout, "address", gdbarch, info->addr);
67 
68  do_cleanups (sub_chain);
69  }
70 
71  do_cleanups (old_chain);
72 }
73 
74 /* Implement the "-info-gdb-mi-command" GDB/MI command. */
75 
76 void
77 mi_cmd_info_gdb_mi_command (char *command, char **argv, int argc)
78 {
79  const char *cmd_name;
80  struct mi_cmd *cmd;
81  struct ui_out *uiout = current_uiout;
82  struct cleanup *old_chain;
83 
84  /* This command takes exactly one argument. */
85  if (argc != 1)
86  error (_("Usage: -info-gdb-mi-command MI_COMMAND_NAME"));
87  cmd_name = argv[0];
88 
89  /* Normally, the command name (aka the "operation" in the GDB/MI
90  grammar), does not include the leading '-' (dash). But for
91  the user's convenience, allow the user to specify the command
92  name to be with or without that leading dash. */
93  if (cmd_name[0] == '-')
94  cmd_name++;
95 
96  cmd = mi_lookup (cmd_name);
97 
98  old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "command");
99  ui_out_field_string (uiout, "exists", cmd != NULL ? "true" : "false");
100  do_cleanups (old_chain);
101 }
102 
103 void
104 mi_cmd_info_os (char *command, char **argv, int argc)
105 {
106  switch (argc)
107  {
108  case 0:
109  info_osdata_command ("", 0);
110  break;
111  case 1:
112  info_osdata_command (argv[0], 0);
113  break;
114  default:
115  error (_("Usage: -info-os [INFOTYPE]"));
116  break;
117  }
118 }
void mi_cmd_info_ada_exceptions(char *command, char **argv, int argc)
Definition: mi-cmd-info.c:28
const char * name
Definition: ada-lang.h:395
struct cleanup * make_cleanup_ui_out_table_begin_end(struct ui_out *ui_out, int nr_cols, int nr_rows, const char *tblid)
Definition: ui-out.c:369
CORE_ADDR addr
Definition: ada-lang.h:398
void mi_cmd_info_os(char *command, char **argv, int argc)
Definition: mi-cmd-info.c:104
#define VEC(T)
Definition: vec.h:398
#define _(String)
Definition: gdb_locale.h:40
Definition: ui-out.h:40
Definition: ui-out.c:99
#define VEC_iterate(T, V, I, P)
Definition: vec.h:165
struct cleanup * make_cleanup_ui_out_tuple_begin_end(struct ui_out *uiout, const char *id)
Definition: ui-out.c:451
#define VEC_length(T, V)
Definition: vec.h:124
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:117
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:781
struct mi_cmd * mi_lookup(const char *command)
Definition: mi-cmds.c:194
void mi_cmd_info_gdb_mi_command(char *command, char **argv, int argc)
Definition: mi-cmd-info.c:77
void ui_out_table_header(struct ui_out *uiout, int width, enum ui_align alignment, const char *col_name, const char *colhdr)
Definition: ui-out.c:346
void ui_out_field_core_addr(struct ui_out *uiout, const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address)
Definition: ui-out.c:499
#define VEC_cleanup(T)
Definition: vec.h:187
void info_osdata_command(char *type, int from_tty)
Definition: osdata.c:289
void ui_out_field_string(struct ui_out *uiout, const char *fldname, const char *string)
Definition: ui-out.c:541
void ui_out_table_body(struct ui_out *uiout)
Definition: ui-out.c:309
struct ui_out * current_uiout
Definition: ui-out.c:233
void error(const char *fmt,...)
Definition: errors.c:38
void do_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:175