aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2021-05-06 10:13:06 +0200
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2021-05-06 10:46:40 +0200
commit79aabb7308cd572fff21da5c93952a1bb0dc5b26 (patch)
tree9d210659cd58e30967e664791578974a06c64625 /gdb/mi
parent10e578d7e00d74033ded0443422ffc509390a912 (diff)
downloadfsf-binutils-gdb-79aabb7308cd572fff21da5c93952a1bb0dc5b26.zip
fsf-binutils-gdb-79aabb7308cd572fff21da5c93952a1bb0dc5b26.tar.gz
fsf-binutils-gdb-79aabb7308cd572fff21da5c93952a1bb0dc5b26.tar.bz2
gdb/mi: add a '--force' flag to the '-break-condition' command
Add a '--force' flag to the '-break-condition' command to be able to force conditions. gdb/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * mi/mi-cmd-break.c (mi_cmd_break_condition): New function. * mi/mi-cmds.c: Change the binding of "-break-condition" to mi_cmd_break_condition. * mi/mi-cmds.h (mi_cmd_break_condition): Declare. * breakpoint.h (set_breakpoint_condition): Declare a new overload. * breakpoint.c (set_breakpoint_condition): New overloaded function extracted out from ... (condition_command): ... this. * NEWS: Mention the change. gdb/testsuite/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.mi/mi-break.exp (test_forced_conditions): Add a test for the -break-condition command's "--force" flag. gdb/doc/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.texinfo (GDB/MI Breakpoint Commands): Mention the '--force' flag of the '-break-condition' command.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-break.c57
-rw-r--r--gdb/mi/mi-cmds.c4
-rw-r--r--gdb/mi/mi-cmds.h1
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;