summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-07-01 18:26:21 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-07-01 18:26:21 +0000
commit2cf4d0554c8db2fecd52f1af1326c5d7843dfd95 (patch)
tree4d0ee9f01ba1e565c4607e7525a1974722cd97ca
parent36c03aaf0dc3b0bb75b1e4427839a8ae588b4979 (diff)
downloadgdb-2cf4d0554c8db2fecd52f1af1326c5d7843dfd95.tar.gz
missing type description for typedef to pointer value
If we evaluate an expression that results in a value that is a typedef to pointer, then the debugger fails to print the type description before printing the actual value: (gdb) print e.plan(1) $1 = 0x0 The expected output is: (gdb) print e.plan(1) $1 = (access integer) 0x0 gdb/ChangeLog: * ada-valprint.c (ada_value_print): Handle typedefs. gdb/testsuite/ChangeLog: * gdb.ada/ptr_typedef: New testcase.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/ada-valprint.c2
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.ada/ptr_typedef.exp35
-rw-r--r--gdb/testsuite/gdb.ada/ptr_typedef/foo.adb30
-rw-r--r--gdb/testsuite/gdb.ada/ptr_typedef/pck.adb21
-rw-r--r--gdb/testsuite/gdb.ada/ptr_typedef/pck.ads19
7 files changed, 114 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 21b7b2ec9e7..c1e776933dc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2011-07-01 Joel Brobecker <brobecker@adacore.com>
+ * ada-valprint.c (ada_value_print): Handle typedefs.
+
+2011-07-01 Joel Brobecker <brobecker@adacore.com>
+
* ada-lang.c (ada_evaluate_subexp): Add missing word in comment.
2011-07-01 Eric Botcazou <ebotcazou@adacore.com>
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 09266ceb6be..f0901a8c137 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -956,7 +956,7 @@ ada_value_print (struct value *val0, struct ui_file *stream,
{
struct value *val = ada_to_fixed_value (val0);
CORE_ADDR address = value_address (val);
- struct type *type = value_type (val);
+ struct type *type = ada_check_typedef (value_type (val));
struct value_print_options opts;
/* If it is a pointer, indicate what it points to. */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 1dc763d6eec..ecf28d326fd 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2011-07-01 Joel Brobecker <brobecker@adacore.com>
+ * gdb.ada/ptr_typedef: New testcase.
+
+2011-07-01 Joel Brobecker <brobecker@adacore.com>
+
* gdb.ada/arrayptr.exp: Add ptype test.
2011-07-01 Joel Brobecker <brobecker@adacore.com>
diff --git a/gdb/testsuite/gdb.ada/ptr_typedef.exp b/gdb/testsuite/gdb.ada/ptr_typedef.exp
new file mode 100644
index 00000000000..624df1838ba
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptr_typedef.exp
@@ -0,0 +1,35 @@
+# Copyright 2011 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 "ptr_typedef"
+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]
+runto "foo.adb:$bp_location"
+
+gdb_test "print my_blob.bees(1)" "= \\(access boolean\\) 0x0"
+
+
diff --git a/gdb/testsuite/gdb.ada/ptr_typedef/foo.adb b/gdb/testsuite/gdb.ada/ptr_typedef/foo.adb
new file mode 100644
index 00000000000..a24bac3d296
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptr_typedef/foo.adb
@@ -0,0 +1,30 @@
+-- Copyright 2011 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 BA is access all Boolean;
+ type BAs is array (1 .. 1) of BA;
+
+ type Blob is record
+ Val : Integer;
+ Bees : BAs;
+ end record;
+
+ My_Blob : Blob := (Val => 1, Bees => (1 => null));
+begin
+ Do_Nothing (My_Blob'Address); -- STOP
+end Foo;
diff --git a/gdb/testsuite/gdb.ada/ptr_typedef/pck.adb b/gdb/testsuite/gdb.ada/ptr_typedef/pck.adb
new file mode 100644
index 00000000000..114fe03b366
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptr_typedef/pck.adb
@@ -0,0 +1,21 @@
+-- Copyright 2011 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/ptr_typedef/pck.ads b/gdb/testsuite/gdb.ada/ptr_typedef/pck.ads
new file mode 100644
index 00000000000..f8a4ed52eaf
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/ptr_typedef/pck.ads
@@ -0,0 +1,19 @@
+-- Copyright 2011 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;