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