summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-02-29 19:29:11 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-02-29 19:29:11 +0000
commite31b2b38a5a60f27bf688f3e05caa880535ee8d1 (patch)
tree343abfc5251410e4bc6a77acb0f742e10d9ee4eb /gdb/testsuite/gdb.ada
parent1ece286fdb1b5c413cf9b1f5d9ebc55e5068c417 (diff)
downloadgdb-e31b2b38a5a60f27bf688f3e05caa880535ee8d1.tar.gz
[Ada] whatis not printing array type name for value from history
Consider the following declaration: type Full_Table is array (Color) of Integer; Full : Full_Table := (144, 233, 377, 610, 987); The debugger correctly prints the type name of variable "full": (gdb) whatis full type = pck.full_table But is unable to do so when using the value history: (gdb) print full $1 = (144, 233, 377, 610, 987) (gdb) whatis $ !!! -> type = array (black .. white) of integer This is because the evaluation creates a "fixed" version of the array type, and that "fixed" version is missing a type name. As a result, whatis falls back to describing the type (a la ptype) instead of printing the type name. gdb/ChangeLog: * ada-lang.c (to_fixed_array_type): Set result's type name. gdb/testsuite/ChangeLog: * gdb.ada/whatis_array_val: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/whatis_array_val.exp44
-rw-r--r--gdb/testsuite/gdb.ada/whatis_array_val/foo.adb25
-rw-r--r--gdb/testsuite/gdb.ada/whatis_array_val/pck.adb23
-rw-r--r--gdb/testsuite/gdb.ada/whatis_array_val/pck.ads19
4 files changed, 111 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/whatis_array_val.exp b/gdb/testsuite/gdb.ada/whatis_array_val.exp
new file mode 100644
index 00000000000..e937f0a5745
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/whatis_array_val.exp
@@ -0,0 +1,44 @@
+# 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"
+
+set testdir "whatis_array_val"
+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 [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
+if ![runto "foo.adb:$bp_location" ] then {
+ perror "Couldn't run ${testfile}"
+ return
+}
+
+gdb_test "whatis full" \
+ "type = foo\\.full_table"
+
+gdb_test "print full" \
+ " = \\(144, 233, 377, 610, 987\\)"
+
+gdb_test "whatis $" \
+ "type = foo\\.full_table"
+
diff --git a/gdb/testsuite/gdb.ada/whatis_array_val/foo.adb b/gdb/testsuite/gdb.ada/whatis_array_val/foo.adb
new file mode 100644
index 00000000000..8fd6d76c8f5
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/whatis_array_val/foo.adb
@@ -0,0 +1,25 @@
+-- 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/>.
+
+with Pck; use Pck;
+
+procedure Foo is
+ type Color is (Black, Red, Green, Blue, White);
+ type Full_Table is array (Color) of Integer;
+ Full : Full_Table := (144, 233, 377, 610, 987);
+begin
+ Do_Nothing (Full'Address); -- STOP
+end Foo;
+
diff --git a/gdb/testsuite/gdb.ada/whatis_array_val/pck.adb b/gdb/testsuite/gdb.ada/whatis_array_val/pck.adb
new file mode 100644
index 00000000000..17f1ff754b6
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/whatis_array_val/pck.adb
@@ -0,0 +1,23 @@
+-- Copyright 2011-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/>.
+
+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/whatis_array_val/pck.ads b/gdb/testsuite/gdb.ada/whatis_array_val/pck.ads
new file mode 100644
index 00000000000..f99df3d19b7
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/whatis_array_val/pck.ads
@@ -0,0 +1,19 @@
+-- Copyright 2011-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/>.
+
+with System;
+package Pck is
+ procedure Do_Nothing (A : System.Address);
+end Pck;