Handle var_zuinteger and var_zuinteger_unlimited from Python
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-catch.c
CommitLineData
91985142 1/* MI Command Set - catch commands.
e2882c85 2 Copyright (C) 2012-2018 Free Software Foundation, Inc.
91985142
MG
3
4 Contributed by Intel Corporation.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21#include "defs.h"
22#include "arch-utils.h"
23#include "breakpoint.h"
349774ef 24#include "ada-lang.h"
91985142
MG
25#include "mi-cmds.h"
26#include "mi-getopt.h"
27#include "mi-cmd-break.h"
28
349774ef
JB
29/* Handler for the -catch-assert command. */
30
31void
9f33b8b7 32mi_cmd_catch_assert (const char *cmd, char *argv[], int argc)
349774ef
JB
33{
34 struct gdbarch *gdbarch = get_current_arch();
56ecd069 35 std::string condition;
349774ef
JB
36 int enabled = 1;
37 int temp = 0;
38
39 int oind = 0;
40 char *oarg;
41
42 enum opt
43 {
44 OPT_CONDITION, OPT_DISABLED, OPT_TEMP,
45 };
46 static const struct mi_opt opts[] =
47 {
48 { "c", OPT_CONDITION, 1},
49 { "d", OPT_DISABLED, 0 },
50 { "t", OPT_TEMP, 0 },
51 { 0, 0, 0 }
52 };
53
54 for (;;)
55 {
56 int opt = mi_getopt ("-catch-assert", argc, argv, opts,
57 &oind, &oarg);
58
59 if (opt < 0)
60 break;
61
62 switch ((enum opt) opt)
63 {
64 case OPT_CONDITION:
56ecd069 65 condition.assign (oarg);
349774ef
JB
66 break;
67 case OPT_DISABLED:
68 enabled = 0;
69 break;
70 case OPT_TEMP:
71 temp = 1;
72 break;
73 }
74 }
75
76 /* This command does not accept any argument. Make sure the user
77 did not provide any. */
78 if (oind != argc)
79 error (_("Invalid argument: %s"), argv[oind]);
80
00f675ff 81 scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
349774ef
JB
82 create_ada_exception_catchpoint (gdbarch, ada_catch_assert,
83 NULL, condition, temp, enabled, 0);
84}
85
86/* Handler for the -catch-exception command. */
87
88void
9f33b8b7 89mi_cmd_catch_exception (const char *cmd, char *argv[], int argc)
349774ef
JB
90{
91 struct gdbarch *gdbarch = get_current_arch();
56ecd069 92 std::string condition;
349774ef
JB
93 int enabled = 1;
94 char *exception_name = NULL;
95 int temp = 0;
96 enum ada_exception_catchpoint_kind ex_kind = ada_catch_exception;
97
98 int oind = 0;
99 char *oarg;
100
101 enum opt
102 {
103 OPT_CONDITION, OPT_DISABLED, OPT_EXCEPTION_NAME, OPT_TEMP,
104 OPT_UNHANDLED,
105 };
106 static const struct mi_opt opts[] =
107 {
108 { "c", OPT_CONDITION, 1},
109 { "d", OPT_DISABLED, 0 },
110 { "e", OPT_EXCEPTION_NAME, 1 },
111 { "t", OPT_TEMP, 0 },
112 { "u", OPT_UNHANDLED, 0},
113 { 0, 0, 0 }
114 };
115
116 for (;;)
117 {
118 int opt = mi_getopt ("-catch-exception", argc, argv, opts,
119 &oind, &oarg);
120
121 if (opt < 0)
122 break;
123
124 switch ((enum opt) opt)
125 {
126 case OPT_CONDITION:
56ecd069 127 condition.assign (oarg);
349774ef
JB
128 break;
129 case OPT_DISABLED:
130 enabled = 0;
131 break;
132 case OPT_EXCEPTION_NAME:
133 exception_name = oarg;
134 break;
135 case OPT_TEMP:
136 temp = 1;
137 break;
138 case OPT_UNHANDLED:
139 ex_kind = ada_catch_exception_unhandled;
140 break;
141 }
142 }
143
144 /* This command does not accept any argument. Make sure the user
145 did not provide any. */
146 if (oind != argc)
147 error (_("Invalid argument: %s"), argv[oind]);
148
149 /* Specifying an exception name does not make sense when requesting
150 an unhandled exception breakpoint. */
151 if (ex_kind == ada_catch_exception_unhandled && exception_name != NULL)
152 error (_("\"-e\" and \"-u\" are mutually exclusive"));
153
00f675ff 154 scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
56ecd069
XR
155 /* create_ada_exception_catchpoint needs EXCEPTION_NAME to be
156 xstrdup'ed, and will assume control of its lifetime. */
2df4d1d5
JB
157 if (exception_name != NULL)
158 exception_name = xstrdup (exception_name);
349774ef 159 create_ada_exception_catchpoint (gdbarch, ex_kind,
bea298f9
XR
160 exception_name,
161 condition, temp, enabled, 0);
162}
163
164/* Handler for the -catch-handlers command. */
165
166void
167mi_cmd_catch_handlers (const char *cmd, char *argv[], int argc)
168{
169 struct gdbarch *gdbarch = get_current_arch ();
170 std::string condition;
171 int enabled = 1;
172 char *exception_name = NULL;
173 int temp = 0;
174
175 int oind = 0;
176 char *oarg;
177
178 enum opt
179 {
180 OPT_CONDITION, OPT_DISABLED, OPT_EXCEPTION_NAME, OPT_TEMP
181 };
182 static const struct mi_opt opts[] =
183 {
184 { "c", OPT_CONDITION, 1},
185 { "d", OPT_DISABLED, 0 },
186 { "e", OPT_EXCEPTION_NAME, 1 },
187 { "t", OPT_TEMP, 0 },
188 { 0, 0, 0 }
189 };
190
191 for (;;)
192 {
193 int opt = mi_getopt ("-catch-handlers", argc, argv, opts,
194 &oind, &oarg);
195
196 if (opt < 0)
197 break;
198
199 switch ((enum opt) opt)
200 {
201 case OPT_CONDITION:
202 condition.assign (oarg);
203 break;
204 case OPT_DISABLED:
205 enabled = 0;
206 break;
207 case OPT_EXCEPTION_NAME:
208 exception_name = oarg;
209 break;
210 case OPT_TEMP:
211 temp = 1;
212 break;
213 }
214 }
215
216 /* This command does not accept any argument. Make sure the user
217 did not provide any. */
218 if (oind != argc)
219 error (_("Invalid argument: %s"), argv[oind]);
220
221 scoped_restore restore_breakpoint_reporting
222 = setup_breakpoint_reporting ();
223 /* create_ada_exception_catchpoint needs EXCEPTION_NAME to be
224 xstrdup'ed, and will assume control of its lifetime. */
225 if (exception_name != NULL)
226 exception_name = xstrdup (exception_name);
227 create_ada_exception_catchpoint (gdbarch, ada_catch_handlers,
228 exception_name,
229 condition, temp, enabled, 0);
349774ef 230}
91985142
MG
231
232/* Common path for the -catch-load and -catch-unload. */
233
234static void
235mi_catch_load_unload (int load, char *argv[], int argc)
236{
91985142
MG
237 const char *actual_cmd = load ? "-catch-load" : "-catch-unload";
238 int temp = 0;
239 int enabled = 1;
240 int oind = 0;
241 char *oarg;
242 enum opt
243 {
244 OPT_TEMP,
245 OPT_DISABLED,
246 };
247 static const struct mi_opt opts[] =
248 {
249 { "t", OPT_TEMP, 0 },
250 { "d", OPT_DISABLED, 0 },
251 { 0, 0, 0 }
252 };
253
254 for (;;)
255 {
256 int opt = mi_getopt (actual_cmd, argc, argv, opts,
257 &oind, &oarg);
258
259 if (opt < 0)
260 break;
261
262 switch ((enum opt) opt)
263 {
264 case OPT_TEMP:
265 temp = 1;
266 break;
267 case OPT_DISABLED:
268 enabled = 0;
269 break;
270 }
271 }
272
273 if (oind >= argc)
274 error (_("-catch-load/unload: Missing <library name>"));
275 if (oind < argc -1)
276 error (_("-catch-load/unload: Garbage following the <library name>"));
277
00f675ff 278 scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
91985142 279 add_solib_catchpoint (argv[oind], load, temp, enabled);
91985142
MG
280}
281
282/* Handler for the -catch-load. */
283
284void
9f33b8b7 285mi_cmd_catch_load (const char *cmd, char *argv[], int argc)
91985142
MG
286{
287 mi_catch_load_unload (1, argv, argc);
288}
289
290
291/* Handler for the -catch-unload. */
292
293void
9f33b8b7 294mi_cmd_catch_unload (const char *cmd, char *argv[], int argc)
91985142
MG
295{
296 mi_catch_load_unload (0, argv, argc);
297}
298
This page took 0.48065 seconds and 4 git commands to generate.