33#include "gdbsupport/gdb_obstack.h"
61 catch (
const gdb_exception &ex)
82scoped_restore_tmpl<int>
107 for (i = 0; i < strlen (argv[0]); i++)
139 if (isprint (argv[0][i]))
140 result += argv[0][i];
145 xsnprintf (tmp,
sizeof (tmp),
"\\%o",
146 (
unsigned char) argv[0][i]);
155 for (i = 1; i < argc; i++)
171 const char *address = NULL;
176 char *condition = NULL;
185 std::unique_ptr<explicit_location_spec> explicit_loc
187 std::string extra_string;
188 bool force_condition =
false;
192 HARDWARE_OPT, TEMP_OPT, CONDITION_OPT,
193 IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT,
197 EXPLICIT_SOURCE_OPT, EXPLICIT_FUNC_OPT,
198 EXPLICIT_LABEL_OPT, EXPLICIT_LINE_OPT
200 static const struct mi_opt opts[] =
202 {
"h", HARDWARE_OPT, 0},
204 {
"c", CONDITION_OPT, 1},
205 {
"i", IGNORE_COUNT_OPT, 1},
206 {
"p", THREAD_OPT, 1},
207 {
"f", PENDING_OPT, 0},
208 {
"d", DISABLE_OPT, 0},
209 {
"a", TRACEPOINT_OPT, 0},
210 {
"-force-condition", FORCE_CONDITION_OPT, 0},
211 {
"-qualified", QUALIFIED_OPT, 0},
212 {
"-source" , EXPLICIT_SOURCE_OPT, 1},
213 {
"-function", EXPLICIT_FUNC_OPT, 1},
214 {
"-label", EXPLICIT_LABEL_OPT, 1},
215 {
"-line", EXPLICIT_LINE_OPT, 1},
226 int opt =
mi_getopt (
"-break-insert", argc, argv,
230 switch ((
enum opt) opt)
241 case IGNORE_COUNT_OPT:
242 ignore_count = atol (oarg);
245 thread = atol (oarg);
259 case EXPLICIT_SOURCE_OPT:
261 explicit_loc->source_filename = xstrdup (oarg);
263 case EXPLICIT_FUNC_OPT:
265 explicit_loc->function_name = xstrdup (oarg);
267 case EXPLICIT_LABEL_OPT:
269 explicit_loc->label_name = xstrdup (oarg);
271 case EXPLICIT_LINE_OPT:
275 case FORCE_CONDITION_OPT:
276 force_condition =
true;
281 if (oind >= argc && !is_explicit)
282 error (_(
"-%s-insert: Missing <location>"),
283 dprintf ?
"dprintf" :
"break");
286 int format_num = is_explicit ? oind : oind + 1;
289 error (_(
"-dprintf-insert: does not support -h or -a"));
290 if (format_num >= argc)
291 error (_(
"-dprintf-insert: Missing <format>"));
294 address = argv[oind];
301 error (_(
"-break-insert: Garbage following explicit location"));
306 error (_(
"-break-insert: Garbage following <location>"));
307 address = argv[oind];
341 if (explicit_loc->source_filename != NULL
342 && explicit_loc->function_name == NULL
343 && explicit_loc->label_name == NULL
345 error (_(
"-%s-insert: --source option requires --function, --label,"
346 " or --line"), dprintf ?
"dprintf" :
"break");
348 explicit_loc->func_name_match_type = match_type;
350 locspec = std::move (explicit_loc);
357 error (_(
"Garbage '%s' at end of location"), address);
361 extra_string.c_str (),
367 ops, 0, enabled, 0, 0);
399 static const struct mi_opt opts[] =
401 {
"-force", FORCE_CONDITION_OPT, 0},
408 bool force_condition =
false;
412 int opt =
mi_getopt (
"-break-condition", argc, argv,
419 case FORCE_CONDITION_OPT:
420 force_condition =
true;
427 error (_(
"-break-condition: Missing the <number> argument"));
429 int bpnum = atoi (argv[oind]);
432 std::string
expr =
"";
433 for (
int i = oind + 1; i < argc; ++i)
459 error (_(
"Usage: tracepoint-number passcount"));
472 error (_(
"Could not find tracepoint %d"), n);
491 static const struct mi_opt opts[] =
494 {
"a", ACCESS_OPT, 0},
504 int opt =
mi_getopt (
"-break-watch", argc, argv,
509 switch ((
enum opt) opt)
520 error (_(
"-break-watch: Missing <expression>"));
522 error (_(
"-break-watch: Garbage following <expression>"));
538 error (_(
"-break-watch: Unknown watchpoint type."));
551 error (_(
"USAGE: %s <BKPT> [<COMMAND> [<COMMAND>...]]"), command);
553 bnum = strtol (argv[0], &endptr, 0);
554 if (endptr == argv[0])
555 error (_(
"breakpoint number argument \"%s\" is not a number."),
557 else if (*endptr !=
'\0')
558 error (_(
"junk at the end of breakpoint number argument \"%s\"."),
563 error (_(
"breakpoint %d not found."), bnum);
567 = [&] (std::string &buffer)
569 const char *result =
nullptr;
571 result = argv[count++];
577 [=] (
const char *line)
struct gdbarch * get_current_arch(void)
struct breakpoint * get_breakpoint(int num)
void watch_command_wrapper(const char *arg, int from_tty, bool internal)
void rwatch_command_wrapper(const char *arg, int from_tty, bool internal)
const struct breakpoint_ops code_breakpoint_ops
int create_breakpoint(struct gdbarch *gdbarch, location_spec *locspec, const char *cond_string, int thread, const char *extra_string, bool force_condition, int parse_extra, int tempflag, enum bptype type_wanted, int ignore_count, enum auto_boolean pending_break_support, const struct breakpoint_ops *ops, int from_tty, int enabled, int internal, unsigned flags)
void break_command(const char *arg, int from_tty)
void awatch_command_wrapper(const char *arg, int from_tty, bool internal)
void breakpoint_set_commands(struct breakpoint *b, counted_command_line &&commands)
struct tracepoint * get_tracepoint(int num)
void set_breakpoint_condition(struct breakpoint *b, const char *exp, int from_tty, bool force)
void print_breakpoint(breakpoint *b)
bool is_tracepoint(const struct breakpoint *b)
const struct breakpoint_ops * breakpoint_ops_for_location_spec(const location_spec *locspec, bool is_tracepoint)
counted_command_line read_command_lines_1(read_next_line_ftype read_next_line_func, int parse_commands, gdb::function_view< void(const char *)> validator)
std::shared_ptr< command_line > counted_command_line
void exception_print(struct ui_file *file, const struct gdb_exception &e)
const struct language_defn * current_language
struct line_offset linespec_parse_line_offset(const char *string)
location_spec_up string_to_location_spec_basic(const char **stringp, const struct language_defn *language, symbol_name_match_type match_type)
std::unique_ptr< location_spec > location_spec_up
static std::string mi_argv_to_format(char **argv, int argc)
static int mi_can_breakpoint_notify
static int mi_breakpoint_observers_installed
scoped_restore_tmpl< int > setup_breakpoint_reporting(void)
static void breakpoint_notify(struct breakpoint *b)
static void mi_cmd_break_insert_1(int dprintf, const char *command, char **argv, int argc)
mi_cmd_argv_ftype mi_cmd_break_condition
mi_cmd_argv_ftype mi_cmd_break_commands
mi_cmd_argv_ftype mi_cmd_dprintf_insert
mi_cmd_argv_ftype mi_cmd_break_insert
mi_cmd_argv_ftype mi_cmd_break_passcount
mi_cmd_argv_ftype mi_cmd_break_watch
int mi_getopt(const char *prefix, int argc, char **argv, const struct mi_opt *opts, int *oind, char **oarg)
observable< struct breakpoint * > breakpoint_created
observable< struct breakpoint * > breakpoint_modified
void validate_actionline(const char *line, struct breakpoint *b)