void
set_breakpoint_condition (struct breakpoint *b, const char *exp,
- int from_tty)
+ int from_tty, bool force)
{
if (*exp == 0)
{
catch (const gdb_exception_error &e)
{
/* Condition string is invalid. If this happens to
- be the last loc, abandon. */
- if (loc->next == nullptr)
+ be the last loc, abandon (if not forced) or continue
+ (if forced). */
+ if (loc->next == nullptr && !force)
throw;
}
}
error_no_arg (_("breakpoint number"));
p = arg;
+
+ /* Check if the "-force" flag was passed. */
+ bool force = false;
+ const char *tok = skip_spaces (p);
+ const char *end_tok = skip_to_space (tok);
+ int toklen = end_tok - tok;
+ if (toklen >= 1 && strncmp (tok, "-force", toklen) == 0)
+ {
+ force = true;
+ p = end_tok + 1;
+ }
+
bnum = get_number (&p);
if (bnum == 0)
error (_("Bad breakpoint argument: '%s'"), arg);
" a %s stop condition defined for this breakpoint."),
ext_lang_capitalized_name (extlang));
}
- set_breakpoint_condition (b, p, from_tty);
+ set_breakpoint_condition (b, p, from_tty, force);
if (is_breakpoint (b))
update_global_location_list (UGLL_MAY_INSERT);
*thread = -1;
*task = 0;
*rest = NULL;
+ bool force = false;
while (tok && *tok)
{
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
{
tok = cond_start = end_tok + 1;
- parse_exp_1 (&tok, pc, block_for_pc (pc), 0);
+ try
+ {
+ parse_exp_1 (&tok, pc, block_for_pc (pc), 0);
+ }
+ catch (const gdb_exception_error &)
+ {
+ if (!force)
+ throw;
+ else
+ tok = tok + strlen (tok);
+ }
cond_end = tok;
*cond_string = savestring (cond_start, cond_end - cond_start);
}
+ else if (toklen >= 1 && strncmp (tok, "-force-condition", toklen) == 0)
+ {
+ tok = cond_start = end_tok + 1;
+ force = true;
+ }
else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
{
const char *tmptok;
command. */
#define BREAK_ARGS_HELP(command) \
-command" [PROBE_MODIFIER] [LOCATION] [thread THREADNUM] [if CONDITION]\n\
+command" [PROBE_MODIFIER] [LOCATION] [thread THREADNUM]\n\
+\t[-force-condition] [if CONDITION]\n\
PROBE_MODIFIER shall be present if the command is to be placed in a\n\
probe point. Accepted values are `-probe' (for a generic, automatically\n\
guessed probe type), `-probe-stap' (for a SystemTap probe) or \n\
\n\
THREADNUM is the number from \"info threads\".\n\
CONDITION is a boolean expression.\n\
+\n\
+With the \"-force-condition\" flag, the condition is defined even when\n\
+it is invalid for all current locations.\n\
\n" LOCATION_HELP_STRING "\n\n\
Multiple breakpoints at one place are permitted, and useful if their\n\
conditions are different.\n\
c = add_com ("condition", class_breakpoint, condition_command, _("\
Specify breakpoint number N to break only if COND is true.\n\
-Usage is `condition N COND', where N is an integer and COND is an\n\
-expression to be evaluated whenever breakpoint N is reached."));
+Usage is `condition [-force] N COND', where N is an integer and COND\n\
+is an expression to be evaluated whenever breakpoint N is reached.\n\
+With the \"-force\" flag, the condition is defined even when it is\n\
+invalid for all current locations."));
set_cmd_completer (c, condition_completer);
c = add_com ("tbreak", class_breakpoint, tbreak_command, _("\