aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada/enum_idx_packed.exp
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-02-29 19:34:40 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-02-29 19:34:40 +0000
commit99b1c762c990c8488c70ad537412f1209b5610bd (patch)
tree602c84fc117b6d1842ac67c07dca089dce8fcb46 /gdb/testsuite/gdb.ada/enum_idx_packed.exp
parent2d4a02ee9526f370ccd9bdc3f30510f03ee59d19 (diff)
downloadgdb-99b1c762c990c8488c70ad537412f1209b5610bd.zip
gdb-99b1c762c990c8488c70ad537412f1209b5610bd.tar.gz
gdb-99b1c762c990c8488c70ad537412f1209b5610bd.tar.bz2
[Ada] print packed arrays indexed by enumerated type
Consider the following declarations (a packed array indexed by an enumerated type): type Color is (Black, Red, Green, Blue, White); type Full_Table is array (Color) of Boolean; pragma Pack (Full_Table); Full : Full_Table := (False, True, False, True, False); GDB is unable to print the index values correctly. It prints the enumeration's underlying value instead of the enumeration name: (gdb) p full $1 = (0 => false, true, false, true, false) (gdb) p full'first $2 = 0 And yet, it is capable of printing the correct type description: (gdb) ptype full type = array (black .. white) of boolean <packed: 1-bit elements> To get to the real index type, one has to follow the parallel XA type. We already do this for normal arrays. We can do it for this packed array as well. gdb/ChangeLog: * ada-lang.c (constrained_packed_array_type): If there is a parallel XA type, use it to determine the array index type. gdb/testsuite/ChangeLog: * gdb.ada/arrayidx.exp: Adjust expected output for p_one_two_three. * gdb.ada/enum_idx_packed: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada/enum_idx_packed.exp')
-rw-r--r--gdb/testsuite/gdb.ada/enum_idx_packed.exp38
1 files changed, 38 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/enum_idx_packed.exp b/gdb/testsuite/gdb.ada/enum_idx_packed.exp
new file mode 100644
index 0000000..61284bb2
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/enum_idx_packed.exp
@@ -0,0 +1,38 @@
+# Copyright 2012 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 }
+
+set testdir "enum_idx_packed"
+set testfile "${testdir}/foo"
+set srcfile ${srcdir}/${subdir}/${testfile}.adb
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
+runto "foo.adb:$bp_location"
+
+gdb_test "print full" " = \\(false, true, false, true, false\\)"
+
+gdb_test "print full'first" " = black"
+