GDB (xrefs)
Loading...
Searching...
No Matches
mi-cmd-info.c
Go to the documentation of this file.
1/* MI Command Set - information commands.
2 Copyright (C) 2011-2023 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
27void
28mi_cmd_info_ada_exceptions (const 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
34 switch (argc)
35 {
36 case 0:
37 regexp = NULL;
38 break;
39 case 1:
40 regexp = argv[0];
41 break;
42 default:
43 error (_("Usage: -info-ada-exceptions [REGEXP]"));
44 break;
45 }
46
47 std::vector<ada_exc_info> exceptions = ada_exceptions_list (regexp);
48
49 ui_out_emit_table table_emitter (uiout, 2,
50 exceptions.size (),
51 "ada-exceptions");
52 uiout->table_header (1, ui_left, "name", "Name");
53 uiout->table_header (1, ui_left, "address", "Address");
54 uiout->table_body ();
55
56 for (const ada_exc_info &info : exceptions)
57 {
58 ui_out_emit_tuple tuple_emitter (uiout, NULL);
59 uiout->field_string ("name", info.name);
60 uiout->field_core_addr ("address", gdbarch, info.addr);
61 }
62}
63
64/* Implement the "-info-gdb-mi-command" GDB/MI command. */
65
66void
67mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc)
68{
69 const char *cmd_name;
70 mi_command *cmd;
71 struct ui_out *uiout = current_uiout;
72
73 /* This command takes exactly one argument. */
74 if (argc != 1)
75 error (_("Usage: -info-gdb-mi-command MI_COMMAND_NAME"));
76 cmd_name = argv[0];
77
78 /* Normally, the command name (aka the "operation" in the GDB/MI
79 grammar), does not include the leading '-' (dash). But for
80 the user's convenience, allow the user to specify the command
81 name to be with or without that leading dash. */
82 if (cmd_name[0] == '-')
83 cmd_name++;
84
85 cmd = mi_cmd_lookup (cmd_name);
86
87 ui_out_emit_tuple tuple_emitter (uiout, "command");
88 uiout->field_string ("exists", cmd != NULL ? "true" : "false");
89}
90
91void
92mi_cmd_info_os (const char *command, char **argv, int argc)
93{
94 switch (argc)
95 {
96 case 0:
97 info_osdata (NULL);
98 break;
99 case 1:
100 info_osdata (argv[0]);
101 break;
102 default:
103 error (_("Usage: -info-os [INFOTYPE]"));
104 break;
105 }
106}
std::vector< ada_exc_info > ada_exceptions_list(const char *regexp)
Definition: ada-lang.c:13231
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:846
Definition: ui-out.h:160
void field_core_addr(const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address)
Definition: ui-out.c:478
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
Definition: ui-out.c:511
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
Definition: ui-out.c:363
void table_body()
Definition: ui-out.c:376
mi_command * mi_cmd_lookup(const char *command)
Definition: mi-cmds.c:364
mi_cmd_argv_ftype mi_cmd_info_os
mi_cmd_argv_ftype mi_cmd_info_ada_exceptions
mi_cmd_argv_ftype mi_cmd_info_gdb_mi_command
def info(c)
Definition: gdbarch.py:184
void info_osdata(const char *type)
Definition: osdata.c:197
@ ui_left
Definition: ui-out.h:45
#define current_uiout
Definition: ui-out.h:40