+2020-07-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * breakpoint.c (set_breakpoint_condition): Update the
+ condition string after parsing the new condition successfully.
+
2020-07-30 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* proc-api.c (_STRUCTURED_PROC): Don't define.
set_breakpoint_condition (struct breakpoint *b, const char *exp,
int from_tty)
{
- xfree (b->cond_string);
- b->cond_string = NULL;
-
if (is_watchpoint (b))
{
struct watchpoint *w = (struct watchpoint *) b;
if (*exp == 0)
{
+ xfree (b->cond_string);
+ b->cond_string = nullptr;
+
if (from_tty)
printf_filtered (_("Breakpoint %d now unconditional.\n"), b->number);
}
{
const char *arg = exp;
- /* I don't know if it matters whether this is the string the user
- typed in or the decompiled expression. */
- b->cond_string = xstrdup (arg);
- b->condition_not_parsed = 0;
-
if (is_watchpoint (b))
{
struct watchpoint *w = (struct watchpoint *) b;
error (_("Junk at end of expression"));
}
}
+
+ /* We know that the new condition parsed successfully. The
+ condition string of the breakpoint can be safely updated. */
+ xfree (b->cond_string);
+ b->cond_string = xstrdup (exp);
+ b->condition_not_parsed = 0;
}
mark_breakpoint_modified (b);
+2020-07-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * gdb.base/condbreak-bad.c: New test.
+ * gdb.base/condbreak-bad.exp: New file.
+
2020-07-30 Tom de Vries <tdevries@suse.de>
* lib/sym-info-cmds.exp (GDBInfoModuleSymbols::check_entry_1): Factor
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main ()
+{
+ int a = 10;
+ a = a + 1; /* break-here */
+ return 0;
+}
--- /dev/null
+# Copyright 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test defining bad conditions for breakpoints.
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
+ return
+}
+
+set bp_location [gdb_get_line_number "break-here"]
+gdb_breakpoint "$bp_location"
+set bpnum [get_integer_valueof "\$bpnum" 0 "get bpnum"]
+
+# Define a 'bad' condition. The breakpoint should stay unconditional.
+gdb_test "cond $bpnum gibberish" \
+ "No symbol \"gibberish\" in current context." \
+ "attempt a bad condition"
+
+set fill "\[^\r\n\]*"
+
+gdb_test "info break" \
+ [multi_line \
+ "Num${fill}What" \
+ "${decimal}${fill}breakpoint${fill}keep y${fill}:${bp_location}"] \
+ "breakpoint is unconditional"
+