diff options
Diffstat (limited to 'gdb/mi')
-rw-r--r-- | gdb/mi/mi-cmd-break.c | 57 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.c | 4 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.h | 1 |
3 files changed, 60 insertions, 2 deletions
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index c73548c..5439937 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -386,6 +386,63 @@ mi_cmd_dprintf_insert (const char *command, char **argv, int argc) mi_cmd_break_insert_1 (1, command, argv, argc); } +/* Implements the -break-condition command. + See the MI manual for the list of options. */ + +void +mi_cmd_break_condition (const char *command, char **argv, int argc) +{ + enum option + { + FORCE_CONDITION_OPT, + }; + + static const struct mi_opt opts[] = + { + {"-force", FORCE_CONDITION_OPT, 0}, + { 0, 0, 0 } + }; + + /* Parse arguments. */ + int oind = 0; + char *oarg; + bool force_condition = false; + + while (true) + { + int opt = mi_getopt ("-break-condition", argc, argv, + opts, &oind, &oarg); + if (opt < 0) + break; + + switch (opt) + { + case FORCE_CONDITION_OPT: + force_condition = true; + break; + } + } + + /* There must be at least two more args: a bpnum and a condition + expression. */ + if (oind + 1 >= argc) + error (_("-break-condition: Missing the <number> and/or <expr> " + "argument")); + + int bpnum = atoi (argv[oind]); + + /* The rest form the condition expr. */ + std::string expr (argv[oind + 1]); + for (int i = oind + 2; i < argc; ++i) + { + expr += " "; + expr += argv[i]; + } + + set_breakpoint_condition (bpnum, expr.c_str (), 0 /* from_tty */, + force_condition); +} + enum wp_type { REG_WP, diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index df4290a..1ed8b6f 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -45,8 +45,8 @@ static struct mi_cmd mi_cmds[] = DEF_MI_CMD_MI ("add-inferior", mi_cmd_add_inferior), DEF_MI_CMD_CLI_1 ("break-after", "ignore", 1, &mi_suppress_notification.breakpoint), - DEF_MI_CMD_CLI_1 ("break-condition","cond", 1, - &mi_suppress_notification.breakpoint), + DEF_MI_CMD_MI_1 ("break-condition", mi_cmd_break_condition, + &mi_suppress_notification.breakpoint), DEF_MI_CMD_MI_1 ("break-commands", mi_cmd_break_commands, &mi_suppress_notification.breakpoint), DEF_MI_CMD_CLI_1 ("break-delete", "delete breakpoint", 1, diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index 4c05a47..8da2e39 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -36,6 +36,7 @@ extern mi_cmd_argv_ftype mi_cmd_ada_task_info; extern mi_cmd_argv_ftype mi_cmd_add_inferior; extern mi_cmd_argv_ftype mi_cmd_break_insert; extern mi_cmd_argv_ftype mi_cmd_dprintf_insert; +extern mi_cmd_argv_ftype mi_cmd_break_condition; extern mi_cmd_argv_ftype mi_cmd_break_commands; extern mi_cmd_argv_ftype mi_cmd_break_passcount; extern mi_cmd_argv_ftype mi_cmd_break_watch; |