aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2014-02-06 23:44:20 -0500
committerJoel Brobecker <brobecker@adacore.com>2014-02-10 13:15:43 +0400
commitaa4fb036e90f5c976f57cd08f2c024cb0fe24897 (patch)
tree60e0046ff631e59ebd0bef7cd86a68956fe4d617 /gdb/testsuite/gdb.ada
parent9dee8cc6aa668228309de7d0e23e1775beb7d12f (diff)
downloadfsf-binutils-gdb-aa4fb036e90f5c976f57cd08f2c024cb0fe24897.zip
fsf-binutils-gdb-aa4fb036e90f5c976f57cd08f2c024cb0fe24897.tar.gz
fsf-binutils-gdb-aa4fb036e90f5c976f57cd08f2c024cb0fe24897.tar.bz2
Wrong type for 'Length result.
Consider the following code: type Color is (Black, Red, Green, Blue, White); type Primary_Table is array (Color range Red .. Blue) of Boolean; Prim : Primary_Table := (True, False, False); GDB prints the length of arrays in a fairly odd way: (gdb) p prim'length $2 = blue The length returned should be an integer, not the array index type, and this patch fixes this. gdb/ChangeLog: * ada-lang.c (ada_evaluate_subexp): Set the type of the value returned by the 'Length attribute to integer. testsuite/ChangeLog: * gdb.ada/tick_length_array_enum_idx: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp41
-rw-r--r--gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb28
-rw-r--r--gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.adb34
-rw-r--r--gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads28
4 files changed, 131 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp
new file mode 100644
index 0000000..86a9c20
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp
@@ -0,0 +1,41 @@
+# Copyright 2014 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_n207_004
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo_n207_004.adb]
+runto "foo_n207_004.adb:$bp_location"
+
+gdb_test "print full'length" "= 5"
+gdb_test "print prim'length" "= 3"
+gdb_test "print cold'length" "= 3"
+gdb_test "print vars'length" "= 2"
+
+gdb_test "ptype full'length" "type = <$decimal-byte integer>"
+gdb_test "ptype prim'length" "type = <$decimal-byte integer>"
+gdb_test "ptype cold'length" "type = <$decimal-byte integer>"
+gdb_test "ptype vars'length" "type = <$decimal-byte integer>"
+
+gdb_test "ptype full_table'length" "type = <$decimal-byte integer>"
+gdb_test "ptype primary_table'length" "type = <$decimal-byte integer>"
+gdb_test "ptype variable_table'length" "type = <$decimal-byte integer>"
diff --git a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb
new file mode 100644
index 0000000..51f3c55
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb
@@ -0,0 +1,28 @@
+-- Copyright 2014 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; use Pck;
+
+procedure Foo_n207_004 is
+ Full : Full_Table := (False, True, False, True, False);
+ Prim : Primary_Table := (True, False, False);
+ Cold : Variable_Table := (Green => False, Blue => True, White => True);
+ Vars : Variable_Table := New_Variable_Table (Low => Red, High => Green);
+begin
+ Do_Nothing (Full'Address); -- STOP
+ Do_Nothing (Prim'Address);
+ Do_Nothing (Cold'Address);
+ Do_Nothing (Vars'Address);
+end Foo_n207_004;
diff --git a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.adb b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.adb
new file mode 100644
index 0000000..cf145fd
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.adb
@@ -0,0 +1,34 @@
+-- Copyright 2014 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
+
+ function New_Variable_Table (Low: Color; High: Color) return Variable_Table
+ is
+ Result : Variable_Table (Low .. High);
+ begin
+ for J in Low .. High loop
+ Result (J) := (J = Black or J = Green or J = White);
+ end loop;
+ return Result;
+ end New_Variable_Table;
+
+ procedure Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
+
+
diff --git a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads
new file mode 100644
index 0000000..b9a42ca
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads
@@ -0,0 +1,28 @@
+-- Copyright 2014 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
+ type Color is (Black, Red, Green, Blue, White);
+
+ type Full_Table is array (Color) of Boolean;
+ type Primary_Table is array (Color range Red .. Blue) of Boolean;
+ type Variable_Table is array (Color range <>) of Boolean;
+
+ function New_Variable_Table (Low: Color; High: Color) return Variable_Table;
+
+ procedure Do_Nothing (A : System.Address);
+end Pck;
+