1 /* MI Command Set - breakpoint and watchpoint commands.
2 Copyright (C) 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions (a Red Hat company).
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "breakpoint.h"
25 #include "gdb_string.h"
26 #include "mi-getopt.h"
27 #include "gdb-events.h"
35 /* Output a single breakpoint. */
38 breakpoint_notify (int b
)
40 gdb_breakpoint_query (uiout
, b
, NULL
);
44 struct gdb_events breakpoint_hooks
=
59 /* Insert a breakpoint. The type of breakpoint is specified by the
60 first argument: -break-insert <location> --> insert a regular
61 breakpoint. -break-insert -t <location> --> insert a temporary
62 breakpoint. -break-insert -h <location> --> insert an hardware
63 breakpoint. -break-insert -t -h <location> --> insert a temporary
65 -break-insert -r <regexp> --> insert a bp at functions matching
69 mi_cmd_break_insert (char *command
, char **argv
, int argc
)
72 enum bp_type type
= REG_BP
;
76 char *condition
= NULL
;
78 struct gdb_events
*old_hooks
;
81 HARDWARE_OPT
, TEMP_OPT
/*, REGEXP_OPT */ , CONDITION_OPT
,
82 IGNORE_COUNT_OPT
, THREAD_OPT
84 static struct mi_opt opts
[] =
86 {"h", HARDWARE_OPT
, 0},
88 {"c", CONDITION_OPT
, 1},
89 {"i", IGNORE_COUNT_OPT
, 1},
94 /* Parse arguments. It could be -r or -h or -t, <location> or ``--''
95 to denote the end of the option list. */
100 int opt
= mi_getopt ("mi_cmd_break_insert", argc
, argv
, opts
, &optind
, &optarg
);
103 switch ((enum opt
) opt
)
119 case IGNORE_COUNT_OPT
:
120 ignore_count
= atol (optarg
);
123 thread
= atol (optarg
);
129 error (_("mi_cmd_break_insert: Missing <location>"));
130 if (optind
< argc
- 1)
131 error (_("mi_cmd_break_insert: Garbage following <location>"));
132 address
= argv
[optind
];
134 /* Now we have what we need, let's insert the breakpoint! */
135 old_hooks
= deprecated_set_gdb_event_hooks (&breakpoint_hooks
);
139 rc
= gdb_breakpoint (address
, condition
,
140 0 /*hardwareflag */ , temp_p
,
141 thread
, ignore_count
,
145 rc
= gdb_breakpoint (address
, condition
,
146 1 /*hardwareflag */ , temp_p
,
147 thread
, ignore_count
,
153 error (_("mi_cmd_break_insert: Unsupported tempoary regexp breakpoint"));
155 rbreak_command_wrapper (address
, FROM_TTY
);
160 internal_error (__FILE__
, __LINE__
,
161 _("mi_cmd_break_insert: Bad switch."));
163 deprecated_set_gdb_event_hooks (old_hooks
);
165 if (rc
== GDB_RC_FAIL
)
178 /* Insert a watchpoint. The type of watchpoint is specified by the
180 -break-watch <expr> --> insert a regular wp.
181 -break-watch -r <expr> --> insert a read watchpoint.
182 -break-watch -a <expr> --> insert an access wp. */
185 mi_cmd_break_watch (char *command
, char **argv
, int argc
)
188 enum wp_type type
= REG_WP
;
193 static struct mi_opt opts
[] =
196 {"a", ACCESS_OPT
, 0},
200 /* Parse arguments. */
205 int opt
= mi_getopt ("mi_cmd_break_watch", argc
, argv
, opts
, &optind
, &optarg
);
208 switch ((enum opt
) opt
)
219 error (_("mi_cmd_break_watch: Missing <expression>"));
220 if (optind
< argc
- 1)
221 error (_("mi_cmd_break_watch: Garbage following <expression>"));
224 /* Now we have what we need, let's insert the watchpoint! */
228 watch_command_wrapper (expr
, FROM_TTY
);
231 rwatch_command_wrapper (expr
, FROM_TTY
);
234 awatch_command_wrapper (expr
, FROM_TTY
);
237 error (_("mi_cmd_break_watch: Unknown watchpoint type."));