]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/mi/mi-cmd-info.c
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / mi / mi-cmd-info.c
1 /* MI Command Set - information commands.
2 Copyright (C) 2011-2024 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 (const char *command, const char *const *argv,
29 int argc)
30 {
31 struct ui_out *uiout = current_uiout;
32 struct gdbarch *gdbarch = get_current_arch ();
33 const char *regexp;
34
35 switch (argc)
36 {
37 case 0:
38 regexp = NULL;
39 break;
40 case 1:
41 regexp = argv[0];
42 break;
43 default:
44 error (_("Usage: -info-ada-exceptions [REGEXP]"));
45 break;
46 }
47
48 std::vector<ada_exc_info> exceptions = ada_exceptions_list (regexp);
49
50 ui_out_emit_table table_emitter (uiout, 2,
51 exceptions.size (),
52 "ada-exceptions");
53 uiout->table_header (1, ui_left, "name", "Name");
54 uiout->table_header (1, ui_left, "address", "Address");
55 uiout->table_body ();
56
57 for (const ada_exc_info &info : exceptions)
58 {
59 ui_out_emit_tuple tuple_emitter (uiout, NULL);
60 uiout->field_string ("name", info.name);
61 uiout->field_core_addr ("address", gdbarch, info.addr);
62 }
63 }
64
65 /* Implement the "-info-gdb-mi-command" GDB/MI command. */
66
67 void
68 mi_cmd_info_gdb_mi_command (const char *command, const char *const *argv,
69 int argc)
70 {
71 const char *cmd_name;
72 mi_command *cmd;
73 struct ui_out *uiout = current_uiout;
74
75 /* This command takes exactly one argument. */
76 if (argc != 1)
77 error (_("Usage: -info-gdb-mi-command MI_COMMAND_NAME"));
78 cmd_name = argv[0];
79
80 /* Normally, the command name (aka the "operation" in the GDB/MI
81 grammar), does not include the leading '-' (dash). But for
82 the user's convenience, allow the user to specify the command
83 name to be with or without that leading dash. */
84 if (cmd_name[0] == '-')
85 cmd_name++;
86
87 cmd = mi_cmd_lookup (cmd_name);
88
89 ui_out_emit_tuple tuple_emitter (uiout, "command");
90 uiout->field_string ("exists", cmd != NULL ? "true" : "false");
91 }
92
93 void
94 mi_cmd_info_os (const char *command, const char *const *argv, int argc)
95 {
96 switch (argc)
97 {
98 case 0:
99 info_osdata (NULL);
100 break;
101 case 1:
102 info_osdata (argv[0]);
103 break;
104 default:
105 error (_("Usage: -info-os [INFOTYPE]"));
106 break;
107 }
108 }