aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-01-25 07:38:21 -0700
committerTom Tromey <tromey@adacore.com>2021-01-25 07:38:21 -0700
commitacd6125f01dc9ba76423b7062c26ca16562943cf (patch)
tree508bad8ab5fcde8390e597e264254f55e345c2d9
parent9e42b97628f96d8c7f59890e368ddf3a0bd8c811 (diff)
downloadbinutils-acd6125f01dc9ba76423b7062c26ca16562943cf.zip
binutils-acd6125f01dc9ba76423b7062c26ca16562943cf.tar.gz
binutils-acd6125f01dc9ba76423b7062c26ca16562943cf.tar.bz2
Add test case for symbol menu for local enumerators
Ada will normally present a menu to the user to allow manual disambiguation of symbols. The AdaCore internal GDB had a bug that prevented this from happening. Although this bug is not in the FSF GDB, it seemed worthwhile to write a test case to ensure this. gdb/testsuite/ChangeLog 2021-01-25 Tom Tromey <tromey@adacore.com> * gdb.ada/local-enum.exp: New file. * gdb.ada/local-enum/local.adb: New file.
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.ada/local-enum.exp83
-rw-r--r--gdb/testsuite/gdb.ada/local-enum/local.adb28
3 files changed, 116 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index cb3913c..5789500 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-01-25 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/local-enum.exp: New file.
+ * gdb.ada/local-enum/local.adb: New file.
+
2021-01-23 Tom Tromey <tom@tromey.com>
* lib/gdb.exp (default_gdb_init): Set INPUTRC to a cached file.
diff --git a/gdb/testsuite/gdb.ada/local-enum.exp b/gdb/testsuite/gdb.ada/local-enum.exp
new file mode 100644
index 0000000..32daf9a
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/local-enum.exp
@@ -0,0 +1,83 @@
+# Copyright 2021 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"
+
+if { [skip_ada_tests] } { return -1 }
+
+standard_ada_testfile local
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/local.adb]
+if ![runto "local.adb:$bp_location" ] then {
+ perror "Couldn't run ${testfile}"
+ return
+}
+
+# The test has two constants named 'three', with different values.
+# This prints one of them and checks the value. WHICH_ENUM is the
+# name of the enum, either "e1" or "e2".
+proc print_three {which_enum value} {
+ # We don't know which in order gdb will print the constants, so
+ # adapt to either.
+ set menu1 [multi_line \
+ "Multiple matches for three" \
+ "\\\[0\\\] cancel" \
+ "\\\[1\\\] local\\.e2'\\(three\\) \\(enumeral\\)" \
+ "\\\[2\\\] local\\.e1'\\(three\\) \\(enumeral\\)" \
+ "> $"]
+ set menu2 [multi_line \
+ "Multiple matches for three" \
+ "\\\[0\\\] cancel" \
+ "\\\[1\\\] local\\.e1'\\(three\\) \\(enumeral\\)" \
+ "\\\[2\\\] local\\.e2'\\(three\\) \\(enumeral\\)" \
+ "> $"]
+
+ set index -1
+ set test_name "menu for test index $which_enum"
+ gdb_test_multiple "print/d three" $test_name {
+ -re $menu1 {
+ pass $test_name
+ if {$which_enum == "e1"} {
+ set index 2
+ } else {
+ set index 1
+ }
+ }
+ -re $menu2 {
+ pass $test_name
+ if {$which_enum == "e1"} {
+ set index 1
+ } else {
+ set index 2
+ }
+ }
+ default {
+ fail $test_name
+ }
+ }
+
+ if {$index != -1} {
+ gdb_test $index " = $value"
+ }
+}
+
+print_three e2 0
+print_three e1 2
diff --git a/gdb/testsuite/gdb.ada/local-enum/local.adb b/gdb/testsuite/gdb.ada/local-enum/local.adb
new file mode 100644
index 0000000..9fafbb1
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/local-enum/local.adb
@@ -0,0 +1,28 @@
+-- Copyright 2021 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/>.
+
+procedure Local is
+ type E1 is (one, two, three);
+ type E2 is (three, four, five);
+
+ type A1 is array (E1) of Integer;
+ type A2 is array (E2) of Integer;
+
+ V1 : A1 := (0, 1, 2);
+ V2 : A2 := (3, 4, 5);
+
+begin
+ null; -- STOP
+end Local;