1 /* MI Command Set - breakpoint and watchpoint commands.
2 Copyright (C) 2000, Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
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 2 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, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 #include "breakpoint.h"
27 #include "gdb_string.h"
28 #include "mi-getopt.h"
29 #include "gdb-events.h"
31 /* Convenience macro for allocting typesafe memory. */
34 #define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
41 /* Output a single breakpoint. */
44 breakpoint_notify (int b
)
46 gdb_breakpoint_query (b
);
50 struct gdb_events breakpoint_hooks
=
65 /* Insert a breakpoint. The type of breakpoint is specified by the
66 first argument: -break-insert <location> --> insert a regular
67 breakpoint. -break-insert -t <location> --> insert a temporary
68 breakpoint. -break-insert -h <location> --> insert an hardware
69 breakpoint. -break-insert -t -h <location> --> insert a temporary
71 -break-insert -r <regexp> --> insert a bp at functions matching
75 mi_cmd_break_insert (char *command
, char **argv
, int argc
)
78 enum bp_type type
= REG_BP
;
82 char *condition
= NULL
;
84 struct gdb_events
*old_hooks
;
87 HARDWARE_OPT
, TEMP_OPT
/*, REGEXP_OPT */ , CONDITION_OPT
,
88 IGNORE_COUNT_OPT
, THREAD_OPT
90 static struct mi_opt opts
[] =
92 {"h", HARDWARE_OPT
, 0},
94 {"c", CONDITION_OPT
, 1},
95 {"i", IGNORE_COUNT_OPT
, 1},
100 /* Parse arguments. It could be -r or -h or -t, <location> or ``--''
101 to denote the end of the option list. */
106 int opt
= mi_getopt ("mi_cmd_break_insert", argc
, argv
, opts
, &optind
, &optarg
);
109 switch ((enum opt
) opt
)
125 case IGNORE_COUNT_OPT
:
126 ignore_count
= atol (optarg
);
129 thread
= atol (optarg
);
135 error ("mi_cmd_break_insert: Missing <location>");
136 if (optind
< argc
- 1)
137 error ("mi_cmd_break_insert: Garbage following <location>");
138 address
= argv
[optind
];
140 /* Now we have what we need, let's insert the breakpoint! */
141 old_hooks
= set_gdb_event_hooks (&breakpoint_hooks
);
145 rc
= gdb_breakpoint (address
, condition
,
146 0 /*hardwareflag */ , temp_p
,
147 thread
, ignore_count
);
150 rc
= gdb_breakpoint (address
, condition
,
151 1 /*hardwareflag */ , temp_p
,
152 thread
, ignore_count
);
157 error ("mi_cmd_break_insert: Unsupported tempoary regexp breakpoint");
159 rbreak_command_wrapper (address
, FROM_TTY
);
164 internal_error ("mi_cmd_break_insert: Bad switch.");
166 set_gdb_event_hooks (old_hooks
);
168 if (rc
== GDB_RC_FAIL
)
169 return MI_CMD_CAUGHT_ERROR
;
181 /* Insert a watchpoint. The type of watchpoint is specified by the
183 -break-watch <expr> --> insert a regular wp.
184 -break-watch -r <expr> --> insert a read watchpoint.
185 -break-watch -a <expr> --> insert an access wp. */
188 mi_cmd_break_watch (char *command
, char **argv
, int argc
)
191 enum wp_type type
= REG_WP
;
196 static struct mi_opt opts
[] =
199 {"a", ACCESS_OPT
, 0},
203 /* Parse arguments. */
208 int opt
= mi_getopt ("mi_cmd_break_watch", argc
, argv
, opts
, &optind
, &optarg
);
211 switch ((enum opt
) opt
)
222 error ("mi_cmd_break_watch: Missing <expression>");
223 if (optind
< argc
- 1)
224 error ("mi_cmd_break_watch: Garbage following <expression>");
227 /* Now we have what we need, let's insert the watchpoint! */
232 watch_command_wrapper (expr
, FROM_TTY
);
237 rwatch_command_wrapper (expr
, FROM_TTY
);
242 awatch_command_wrapper (expr
, FROM_TTY
);
246 error ("mi_cmd_break_watch: Unknown watchpoint type.");
251 /* Local variables: */
252 /* change-log-default-name: "ChangeLog-mi" */