aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-05-30 14:13:10 -0600
committerTom Tromey <tromey@adacore.com>2019-06-19 06:06:02 -0600
commit680e1beed31da40080f61a35f6ccd626de818056 (patch)
tree75454b722be92a1feb6afc3bda485b7e835d3bde /gdb/testsuite/gdb.ada
parentdcf3792354ddcd6e10e59e32060e34b27246e7da (diff)
downloadgdb-680e1beed31da40080f61a35f6ccd626de818056.zip
gdb-680e1beed31da40080f61a35f6ccd626de818056.tar.gz
gdb-680e1beed31da40080f61a35f6ccd626de818056.tar.bz2
Fix crash when setting breakpoint condition
gdb could crash when setting a breakpoint condition on a breakpoint when using the Ada language. The problem occurred because the ada_evaluate_subexp would try to evaluate the array to compute its attributes, but evaluating can't really be done at this time. This patch fixes the problem by arranging not to try to evaluate in EVAL_AVOID_SIDE_EFFECTS mode when computing an attribute. Tested on x86-64 Fedora 29. Because this is Ada-specific, and because Joel approved it internally, I am checking it in. gdb/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_evaluate_subexp) <case OP_ATR_FIRST>: Handle EVAL_AVOID_SIDE_EFFECTS specially. gdb/testsuite/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * gdb.ada/length_cond.exp: New file. * gdb.ada/length_cond/length_cond.adb: New file. * gdb.ada/length_cond/pck.adb: New file. * gdb.ada/length_cond/pck.ads: New file.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/length_cond.exp44
-rw-r--r--gdb/testsuite/gdb.ada/length_cond/length_cond.adb37
-rw-r--r--gdb/testsuite/gdb.ada/length_cond/pck.adb21
-rw-r--r--gdb/testsuite/gdb.ada/length_cond/pck.ads18
4 files changed, 120 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/length_cond.exp b/gdb/testsuite/gdb.ada/length_cond.exp
new file mode 100644
index 0000000..53e9187
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/length_cond.exp
@@ -0,0 +1,44 @@
+# Copyright 2019 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/>.
+
+load_lib "ada.exp"
+
+standard_ada_testfile length_cond
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "BREAKPOINT" ${testdir}/length_cond.adb]
+gdb_breakpoint length_cond.adb:$bp_location message
+
+# Resolving the conditional expression would cause a crash, so it's
+# enough to just set the conditions.
+
+foreach var {loc enum_val int_val} {
+ foreach attr {first last} {
+ gdb_test_no_output "cond 1 $var'$attr > 15"
+ }
+}
+
+gdb_test_no_output "cond 1 loc'length > 15"
+
+foreach attr {first last length} {
+ foreach val {1 2} {
+ gdb_test_no_output "cond 1 my_array'${attr}($val) > 15"
+ }
+}
diff --git a/gdb/testsuite/gdb.ada/length_cond/length_cond.adb b/gdb/testsuite/gdb.ada/length_cond/length_cond.adb
new file mode 100644
index 0000000..7b563c3
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/length_cond/length_cond.adb
@@ -0,0 +1,37 @@
+-- Copyright 2019 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/>.
+
+with Pck;
+
+procedure Length_Cond is
+ type Enum is (One, Two, Three);
+ Enum_Val : Enum := Three;
+
+ type My_Int is range -23 .. 23;
+ Int_Val : My_Int := 0;
+
+ type My_Array is array (0..1, 0..1) of Boolean;
+ Array_Val : My_Array := ((True, False), (False, True));
+
+ procedure p (s : String) is
+ loc : String := s & ".";
+ begin
+ Pck.Do_Nothing (loc); -- BREAKPOINT
+ end p;
+begin
+ for I in 1 .. 25 loop
+ p ((1 .. I => 'X'));
+ end loop;
+end Length_Cond;
diff --git a/gdb/testsuite/gdb.ada/length_cond/pck.adb b/gdb/testsuite/gdb.ada/length_cond/pck.adb
new file mode 100644
index 0000000..79bbe59
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/length_cond/pck.adb
@@ -0,0 +1,21 @@
+-- Copyright 2019 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/>.
+
+package body Pck is
+ procedure Do_Nothing (A : String) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/length_cond/pck.ads b/gdb/testsuite/gdb.ada/length_cond/pck.ads
new file mode 100644
index 0000000..433b389
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/length_cond/pck.ads
@@ -0,0 +1,18 @@
+-- Copyright 2019 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/>.
+
+package Pck is
+ procedure Do_Nothing (A : String);
+end Pck;