aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-03-13 08:40:25 -0600
committerTom Tromey <tromey@adacore.com>2019-03-18 06:45:16 -0600
commitbff8c71fd8dece639e69b399883f90b3404a2a48 (patch)
tree63f669a3e2568e89797dce78b3a2cf55098dcd35 /gdb/testsuite
parentaf60449c260235478f9b1f9db39a587fe4c75290 (diff)
downloadgdb-bff8c71fd8dece639e69b399883f90b3404a2a48.zip
gdb-bff8c71fd8dece639e69b399883f90b3404a2a48.tar.gz
gdb-bff8c71fd8dece639e69b399883f90b3404a2a48.tar.bz2
Fix Ada "ptype" bug with array types
Using ptype on an array type in Ada can sometimes show an incorrect high bound. This happens because ada_evaluate_subexp will create an array with an incorrect upper bound in the EVAL_AVOID_SIDE_EFFECTS case. This patch fixes the problem by arranging to always create such an array with valid bounds. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-03-18 Tom Tromey <tromey@adacore.com> * ada-lang.c (empty_array): Add "high" parameter. (ada_evaluate_subexp): Update. gdb/testsuite/ChangeLog 2019-03-18 Joel Brobecker <brobecker@adacore.com> Tom Tromey <tromey@adacore.com> * gdb.ada/ptype_array/pck.adb: New file. * gdb.ada/ptype_array/pck.ads: New file. * gdb.ada/ptype_array/foo.adb: New file. * gdb.ada/ptype_array.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog8
-rw-r--r--gdb/testsuite/gdb.ada/ptype_array.exp34
-rw-r--r--gdb/testsuite/gdb.ada/ptype_array/foo.adb21
-rw-r--r--gdb/testsuite/gdb.ada/ptype_array/pck.adb23
-rw-r--r--gdb/testsuite/gdb.ada/ptype_array/pck.ads30
5 files changed, 116 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 523013b..e0bed87 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2019-03-18 Joel Brobecker <brobecker@adacore.com>
+ Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/ptype_array/pck.adb: New file.
+ * gdb.ada/ptype_array/pck.ads: New file.
+ * gdb.ada/ptype_array/foo.adb: New file.
+ * gdb.ada/ptype_array.exp: New file.
+
2019-03-14 Tom Tromey <tromey@adacore.com>
* gdb.base/style.exp: Add "set style sources" test.
diff --git a/gdb/testsuite/gdb.ada/ptype_array.exp b/gdb/testsuite/gdb.ada/ptype_array.exp
new file mode 100644
index 0000000..ec75d14
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptype_array.exp
@@ -0,0 +1,34 @@
+# 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 foo
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnat05 ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+runto_main
+
+gdb_test "ptype pck.W.G(1,5).m(2 .. 5)" \
+ "type = array \\(2 \\.\\. 5\\) of character" \
+ "ptype 2..5"
+
+gdb_test "ptype pck.W.G(1,5).m(3 .. 5)" \
+ "type = array \\(3 \\.\\. 5\\) of character" \
+ "ptype 3..5"
diff --git a/gdb/testsuite/gdb.ada/ptype_array/foo.adb b/gdb/testsuite/gdb.ada/ptype_array/foo.adb
new file mode 100644
index 0000000..c1688cb
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptype_array/foo.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/>.
+
+with Pck;
+
+procedure Foo is
+begin
+ Pck.Do_Nothing (Pck.W.G'Address);
+end Foo;
diff --git a/gdb/testsuite/gdb.ada/ptype_array/pck.adb b/gdb/testsuite/gdb.ada/ptype_array/pck.adb
new file mode 100644
index 0000000..5a2019a
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptype_array/pck.adb
@@ -0,0 +1,23 @@
+-- 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 : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
+
+
diff --git a/gdb/testsuite/gdb.ada/ptype_array/pck.ads b/gdb/testsuite/gdb.ada/ptype_array/pck.ads
new file mode 100644
index 0000000..7b81930
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptype_array/pck.ads
@@ -0,0 +1,30 @@
+-- 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 System;
+
+package Pck is
+ package W is
+ type P is record
+ M : String (2 .. 5);
+ end record;
+
+ type R is array (1 .. 10, 1 .. 20) of P;
+
+ G : R;
+ end W;
+
+ procedure Do_Nothing (A : System.Address);
+end Pck;