+2021-04-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * breakpoint.h (create_breakpoint): Add a new parameter,
+ 'force_condition'.
+ * breakpoint.c (create_breakpoint): Use the 'force_condition'
+ argument when 'parse_extra' is false to check if the condition
+ is invalid at all of the breakpoint locations.
+ Update the users below.
+ (break_command_1)
+ (dprintf_command)
+ (trace_command)
+ (ftrace_command)
+ (strace_command)
+ (create_tracepoint_from_upload): Update.
+ * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Update.
+ * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Update.
+ * python/py-breakpoint.c (bppy_init): Update.
+ * python/py-finishbreakpoint.c (bpfinishpy_init): Update.
+
2021-04-21 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* breakpoint.c (print_one_breakpoint_location): Display "N" for
struct event_location *location,
const char *cond_string,
int thread, const char *extra_string,
- int parse_extra,
+ bool force_condition, int parse_extra,
int tempflag, enum bptype type_wanted,
int ignore_count,
enum auto_boolean pending_break_support,
&& extra_string != NULL && *extra_string != '\0')
error (_("Garbage '%s' at end of location"), extra_string);
+ /* Check the validity of the condition. We should error out
+ if the condition is invalid at all of the locations and
+ if it is not forced. In the PARSE_EXTRA case above, this
+ check is done when parsing the EXTRA_STRING. */
+ if (cond_string != nullptr && !force_condition)
+ {
+ int num_failures = 0;
+ const linespec_sals &lsal = canonical.lsals[0];
+ for (const auto &sal : lsal.sals)
+ {
+ const char *cond = cond_string;
+ try
+ {
+ parse_exp_1 (&cond, sal.pc, block_for_pc (sal.pc), 0);
+ /* One success is sufficient to keep going. */
+ break;
+ }
+ catch (const gdb_exception_error &)
+ {
+ num_failures++;
+ /* If this is the last sal, error out. */
+ if (num_failures == lsal.sals.size ())
+ throw;
+ }
+ }
+ }
+
/* Create a private copy of condition string. */
if (cond_string)
cond_string_copy.reset (xstrdup (cond_string));
create_breakpoint (get_current_arch (),
location.get (),
- NULL, 0, arg, 1 /* parse arg */,
+ NULL, 0, arg, false, 1 /* parse arg */,
tempflag, type_wanted,
0 /* Ignore count */,
pending_break_support,
create_breakpoint (get_current_arch (),
location.get (),
- NULL, 0, arg, 1 /* parse arg */,
+ NULL, 0, arg, false, 1 /* parse arg */,
0, bp_dprintf,
0 /* Ignore count */,
pending_break_support,
create_breakpoint (get_current_arch (),
location.get (),
- NULL, 0, arg, 1 /* parse arg */,
+ NULL, 0, arg, false, 1 /* parse arg */,
0 /* tempflag */,
bp_tracepoint /* type_wanted */,
0 /* Ignore count */,
current_language);
create_breakpoint (get_current_arch (),
location.get (),
- NULL, 0, arg, 1 /* parse arg */,
+ NULL, 0, arg, false, 1 /* parse arg */,
0 /* tempflag */,
bp_fast_tracepoint /* type_wanted */,
0 /* Ignore count */,
create_breakpoint (get_current_arch (),
location.get (),
- NULL, 0, arg, 1 /* parse arg */,
+ NULL, 0, arg, false, 1 /* parse arg */,
0 /* tempflag */,
bp_static_tracepoint /* type_wanted */,
0 /* Ignore count */,
if (!create_breakpoint (get_current_arch (),
location.get (),
utp->cond_string.get (), -1, addr_str,
+ false /* force_condition */,
0 /* parse cond/thread */,
0 /* tempflag */,
utp->type /* type_wanted */,
the condition, thread, and extra string from EXTRA_STRING, ignoring
the similarly named parameters.
+ If FORCE_CONDITION is true, the condition is accepted even when it is
+ invalid at all of the locations. However, if PARSE_EXTRA is non-zero,
+ the FORCE_CONDITION parameter is ignored and the corresponding argument
+ is parsed from EXTRA_STRING.
+
If INTERNAL is non-zero, the breakpoint number will be allocated
from the internal breakpoint count.
struct event_location *location,
const char *cond_string, int thread,
const char *extra_string,
+ bool force_condition,
int parse_extra,
int tempflag, enum bptype wanted_type,
int ignore_count,
mi_gdb_test "-break-insert -c i==4 \"callme if i < 4\"" \
".*\\^error,msg=\"Garbage 'if i < 4' at end of location\"" \
"conditional breakpoint with garbage after location"
+
+ # Try using an invalid condition.
+ mi_gdb_test "-break-insert -c bad callme" \
+ ".*\\^error,msg=\"No symbol \\\\\"bad\\\\\" in current context.\"" \
+ "breakpoint with bad condition"
+
+ mi_gdb_test "-dprintf-insert -c bad callme \"Hello\"" \
+ ".*\\^error,msg=\"No symbol \\\\\"bad\\\\\" in current context.\"" \
+ "dprintf with bad condition"
+
+ mi_gdb_test "-break-condition 5 bad" \
+ ".*\\^error,msg=\"No symbol \\\\\"bad\\\\\" in current context.\"" \
+ "invalid condition"
}
proc_with_prefix test_disabled_creation {} {