Commit | Line | Data |
---|---|---|
f3e0e960 | 1 | /* MI Command Set - information commands. |
61baf725 | 2 | Copyright (C) 2011-2017 Free Software Foundation, Inc. |
f3e0e960 SS |
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" | |
a7e332c2 JB |
22 | #include "ada-lang.h" |
23 | #include "arch-utils.h" | |
24 | ||
25 | /* Implement the "-info-ada-exceptions" GDB/MI command. */ | |
26 | ||
27 | void | |
9f33b8b7 | 28 | mi_cmd_info_ada_exceptions (const char *command, char **argv, int argc) |
a7e332c2 JB |
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 | ||
54 | make_cleanup_ui_out_table_begin_end | |
55 | (uiout, 2, VEC_length (ada_exc_info, exceptions), "ada-exceptions"); | |
112e8700 SM |
56 | uiout->table_header (1, ui_left, "name", "Name"); |
57 | uiout->table_header (1, ui_left, "address", "Address"); | |
58 | uiout->table_body (); | |
a7e332c2 JB |
59 | |
60 | for (ix = 0; VEC_iterate(ada_exc_info, exceptions, ix, info); ix++) | |
61 | { | |
2e783024 | 62 | ui_out_emit_tuple tuple_emitter (uiout, NULL); |
112e8700 SM |
63 | uiout->field_string ("name", info->name); |
64 | uiout->field_core_addr ("address", gdbarch, info->addr); | |
a7e332c2 JB |
65 | } |
66 | ||
67 | do_cleanups (old_chain); | |
68 | } | |
f3e0e960 | 69 | |
6b7cbff1 JB |
70 | /* Implement the "-info-gdb-mi-command" GDB/MI command. */ |
71 | ||
72 | void | |
9f33b8b7 | 73 | mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc) |
6b7cbff1 JB |
74 | { |
75 | const char *cmd_name; | |
76 | struct mi_cmd *cmd; | |
77 | struct ui_out *uiout = current_uiout; | |
6b7cbff1 JB |
78 | |
79 | /* This command takes exactly one argument. */ | |
80 | if (argc != 1) | |
81 | error (_("Usage: -info-gdb-mi-command MI_COMMAND_NAME")); | |
82 | cmd_name = argv[0]; | |
83 | ||
84 | /* Normally, the command name (aka the "operation" in the GDB/MI | |
85 | grammar), does not include the leading '-' (dash). But for | |
86 | the user's convenience, allow the user to specify the command | |
87 | name to be with or without that leading dash. */ | |
88 | if (cmd_name[0] == '-') | |
89 | cmd_name++; | |
90 | ||
91 | cmd = mi_lookup (cmd_name); | |
92 | ||
2e783024 | 93 | ui_out_emit_tuple tuple_emitter (uiout, "command"); |
112e8700 | 94 | uiout->field_string ("exists", cmd != NULL ? "true" : "false"); |
6b7cbff1 JB |
95 | } |
96 | ||
f3e0e960 | 97 | void |
9f33b8b7 | 98 | mi_cmd_info_os (const char *command, char **argv, int argc) |
f3e0e960 SS |
99 | { |
100 | switch (argc) | |
101 | { | |
102 | case 0: | |
fdf9e36f | 103 | info_osdata (NULL); |
f3e0e960 SS |
104 | break; |
105 | case 1: | |
fdf9e36f | 106 | info_osdata (argv[0]); |
f3e0e960 SS |
107 | break; |
108 | default: | |
109 | error (_("Usage: -info-os [INFOTYPE]")); | |
110 | break; | |
111 | } | |
112 | } |