1 /* MI Command Set - catch commands.
2 Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 Contributed by Intel Corporation.
6 This file is part of GDB.
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.
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.
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/>. */
22 #include "arch-utils.h"
23 #include "breakpoint.h"
25 #include "libiberty.h"
28 #include "mi-getopt.h"
29 #include "mi-cmd-break.h"
31 /* Handler for the -catch-assert command. */
34 mi_cmd_catch_assert (char *cmd
, char *argv
[], int argc
)
36 struct gdbarch
*gdbarch
= get_current_arch();
37 char *condition
= NULL
;
46 OPT_CONDITION
, OPT_DISABLED
, OPT_TEMP
,
48 static const struct mi_opt opts
[] =
50 { "c", OPT_CONDITION
, 1},
51 { "d", OPT_DISABLED
, 0 },
58 int opt
= mi_getopt ("-catch-assert", argc
, argv
, opts
,
64 switch ((enum opt
) opt
)
78 /* This command does not accept any argument. Make sure the user
79 did not provide any. */
81 error (_("Invalid argument: %s"), argv
[oind
]);
83 setup_breakpoint_reporting ();
84 create_ada_exception_catchpoint (gdbarch
, ada_catch_assert
,
85 NULL
, condition
, temp
, enabled
, 0);
88 /* Handler for the -catch-exception command. */
91 mi_cmd_catch_exception (char *cmd
, char *argv
[], int argc
)
93 struct gdbarch
*gdbarch
= get_current_arch();
94 char *condition
= NULL
;
96 char *exception_name
= NULL
;
98 enum ada_exception_catchpoint_kind ex_kind
= ada_catch_exception
;
105 OPT_CONDITION
, OPT_DISABLED
, OPT_EXCEPTION_NAME
, OPT_TEMP
,
108 static const struct mi_opt opts
[] =
110 { "c", OPT_CONDITION
, 1},
111 { "d", OPT_DISABLED
, 0 },
112 { "e", OPT_EXCEPTION_NAME
, 1 },
113 { "t", OPT_TEMP
, 0 },
114 { "u", OPT_UNHANDLED
, 0},
120 int opt
= mi_getopt ("-catch-exception", argc
, argv
, opts
,
126 switch ((enum opt
) opt
)
134 case OPT_EXCEPTION_NAME
:
135 exception_name
= oarg
;
141 ex_kind
= ada_catch_exception_unhandled
;
146 /* This command does not accept any argument. Make sure the user
147 did not provide any. */
149 error (_("Invalid argument: %s"), argv
[oind
]);
151 /* Specifying an exception name does not make sense when requesting
152 an unhandled exception breakpoint. */
153 if (ex_kind
== ada_catch_exception_unhandled
&& exception_name
!= NULL
)
154 error (_("\"-e\" and \"-u\" are mutually exclusive"));
156 setup_breakpoint_reporting ();
157 create_ada_exception_catchpoint (gdbarch
, ex_kind
,
158 exception_name
, condition
,
162 /* Common path for the -catch-load and -catch-unload. */
165 mi_catch_load_unload (int load
, char *argv
[], int argc
)
167 struct cleanup
*back_to
;
168 const char *actual_cmd
= load
? "-catch-load" : "-catch-unload";
178 static const struct mi_opt opts
[] =
180 { "t", OPT_TEMP
, 0 },
181 { "d", OPT_DISABLED
, 0 },
187 int opt
= mi_getopt (actual_cmd
, argc
, argv
, opts
,
193 switch ((enum opt
) opt
)
205 error (_("-catch-load/unload: Missing <library name>"));
207 error (_("-catch-load/unload: Garbage following the <library name>"));
209 back_to
= setup_breakpoint_reporting ();
211 add_solib_catchpoint (argv
[oind
], load
, temp
, enabled
);
213 do_cleanups (back_to
);
216 /* Handler for the -catch-load. */
219 mi_cmd_catch_load (char *cmd
, char *argv
[], int argc
)
221 mi_catch_load_unload (1, argv
, argc
);
225 /* Handler for the -catch-unload. */
228 mi_cmd_catch_unload (char *cmd
, char *argv
[], int argc
)
230 mi_catch_load_unload (0, argv
, argc
);