aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-06-17 07:41:37 -0600
committerTom Tromey <tromey@adacore.com>2022-07-18 09:57:04 -0600
commit6a40c6e4374a660eab5cdc2f8a777ccbd7a81951 (patch)
tree58413fbd5fbe095288fc93c6474a0b84dbe6f757 /gdb/testsuite
parent083aca0c8333fc24c6a65a03fca765bc13ee37c0 (diff)
downloadgdb-6a40c6e4374a660eab5cdc2f8a777ccbd7a81951.zip
gdb-6a40c6e4374a660eab5cdc2f8a777ccbd7a81951.tar.gz
gdb-6a40c6e4374a660eab5cdc2f8a777ccbd7a81951.tar.bz2
Remove array typedef assumption for Ada
Currently the Ada code assumes that it can distinguish between a multi-dimensional array and an array of arrays by looking for an intervening typedef -- that is, for an array of arrays, there will be a typedef wrapping the innermost array type. A recent compiler change removes this typedef, which causes a gdb failure in the internal AdaCore test suite. This patch handles this case by checking whether the array type in question has a name.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.ada/multiarray.exp48
-rw-r--r--gdb/testsuite/gdb.ada/multiarray/p.adb46
-rw-r--r--gdb/testsuite/gdb.ada/multiarray/pack.ads34
3 files changed, 128 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/multiarray.exp b/gdb/testsuite/gdb.ada/multiarray.exp
new file mode 100644
index 0000000..bac16f2
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/multiarray.exp
@@ -0,0 +1,48 @@
+# Copyright 2022 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 p
+
+foreach_with_prefix scenario {all minimal} {
+ set flags [list debug additional_flags=-fgnat-encodings=$scenario]
+
+ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+ return -1
+ }
+
+ clean_restart ${testfile}
+
+ set bp_location [gdb_get_line_number "START" ${testdir}/p.adb]
+ runto "p.adb:$bp_location"
+
+ gdb_test "ptype simple_type" \
+ [string_to_regexp "type = array (<>, <>) of integer"]
+ gdb_test "ptype nested_type" \
+ [string_to_regexp "type = array (<>, <>) of pack.ca_simple_type"]
+
+ gdb_test "ptype simple" \
+ [string_to_regexp "type = array (1 .. 3, 5 .. 6) of integer"]
+ gdb_test "ptype nested" \
+ [string_to_regexp "type = array (1 .. 3, 5 .. 6) of pack.ca_simple_type"]
+
+ gdb_test "print simple" \
+ [string_to_regexp " = ((5 => 1, 2), (5 => 3, 4), (5 => 5, 6))"]
+ gdb_test "print nested" \
+ [string_to_regexp " = ((5 => (1, 2), (3, 4)), (5 => (5, 6), (7, 8)), (5 => (9, 10), (11, 12)))"]
+}
diff --git a/gdb/testsuite/gdb.ada/multiarray/p.adb b/gdb/testsuite/gdb.ada/multiarray/p.adb
new file mode 100644
index 0000000..eacc406
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/multiarray/p.adb
@@ -0,0 +1,46 @@
+-- Copyright 2022 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 Pack; use Pack;
+
+procedure P is
+
+ procedure Nop is
+ begin
+ null;
+ end Nop;
+
+ procedure Discard
+ (Arg_Simple : Simple_Type;
+ Arg_Nested : Nested_Type) is
+ begin
+ null;
+ end Discard;
+
+ Simple : Simple_Type :=
+ (1 => (5 => 1, 6 => 2),
+ 2 => (5 => 3, 6 => 4),
+ 3 => (5 => 5, 6 => 6));
+ Nested : Nested_Type :=
+ (1 => (5 => (1, 2), 6 => (3, 4)),
+ 2 => (5 => (5, 6), 6 => (7, 8)),
+ 3 => (5 => (9, 10), 6 => (11, 12)));
+
+begin
+ Nop; -- START
+
+ Discard (Simple, Nested);
+
+end P;
diff --git a/gdb/testsuite/gdb.ada/multiarray/pack.ads b/gdb/testsuite/gdb.ada/multiarray/pack.ads
new file mode 100644
index 0000000..06091de
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/multiarray/pack.ads
@@ -0,0 +1,34 @@
+-- Copyright 2022 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 Pack is
+
+ type Index_Type_1 is new Natural;
+ type Index_Type_2 is new Natural;
+ type Index_Type_3 is new Natural;
+
+ type CA_Simple_Type is array (Index_Type_1 range 1 .. 2) of Integer;
+
+ -- Array types we test
+
+ type Simple_Type is
+ array (Index_Type_1 range <>, Index_Type_2 range <>)
+ of Integer;
+
+ type Nested_Type is
+ array (Index_Type_1 range <>, Index_Type_2 range <>)
+ of CA_Simple_Type;
+
+end Pack;