mi/mi-cmd-break.c: Use xsnprintf instead of sprintf (ARI fix)
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-catch.c
1 /* MI Command Set - catch commands.
2 Copyright (C) 2012-2013 Free Software Foundation, Inc.
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"
24 #include "gdb.h"
25 #include "libiberty.h"
26 #include "mi-cmds.h"
27 #include "mi-getopt.h"
28 #include "mi-cmd-break.h"
29
30
31 /* Common path for the -catch-load and -catch-unload. */
32
33 static void
34 mi_catch_load_unload (int load, char *argv[], int argc)
35 {
36 struct cleanup *back_to;
37 const char *actual_cmd = load ? "-catch-load" : "-catch-unload";
38 int temp = 0;
39 int enabled = 1;
40 int oind = 0;
41 char *oarg;
42 enum opt
43 {
44 OPT_TEMP,
45 OPT_DISABLED,
46 };
47 static const struct mi_opt opts[] =
48 {
49 { "t", OPT_TEMP, 0 },
50 { "d", OPT_DISABLED, 0 },
51 { 0, 0, 0 }
52 };
53
54 for (;;)
55 {
56 int opt = mi_getopt (actual_cmd, argc, argv, opts,
57 &oind, &oarg);
58
59 if (opt < 0)
60 break;
61
62 switch ((enum opt) opt)
63 {
64 case OPT_TEMP:
65 temp = 1;
66 break;
67 case OPT_DISABLED:
68 enabled = 0;
69 break;
70 }
71 }
72
73 if (oind >= argc)
74 error (_("-catch-load/unload: Missing <library name>"));
75 if (oind < argc -1)
76 error (_("-catch-load/unload: Garbage following the <library name>"));
77
78 back_to = setup_breakpoint_reporting ();
79
80 add_solib_catchpoint (argv[oind], load, temp, enabled);
81
82 do_cleanups (back_to);
83 }
84
85 /* Handler for the -catch-load. */
86
87 void
88 mi_cmd_catch_load (char *cmd, char *argv[], int argc)
89 {
90 mi_catch_load_unload (1, argv, argc);
91 }
92
93
94 /* Handler for the -catch-unload. */
95
96 void
97 mi_cmd_catch_unload (char *cmd, char *argv[], int argc)
98 {
99 mi_catch_load_unload (0, argv, argc);
100 }
101
This page took 0.081687 seconds and 4 git commands to generate.