This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/Ada] 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.

Tested on x86_64-linux.  Checked in.

---
 gdb/ChangeLog                             |    4 +++
 gdb/ada-valprint.c                        |    2 +-
 gdb/testsuite/ChangeLog                   |    4 +++
 gdb/testsuite/gdb.ada/ptr_typedef.exp     |   35 +++++++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/ptr_typedef/foo.adb |   30 ++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/ptr_typedef/pck.adb |   21 +++++++++++++++++
 gdb/testsuite/gdb.ada/ptr_typedef/pck.ads |   19 +++++++++++++++
 7 files changed, 114 insertions(+), 1 deletions(-)
 create mode 100644 gdb/testsuite/gdb.ada/ptr_typedef.exp
 create mode 100644 gdb/testsuite/gdb.ada/ptr_typedef/foo.adb
 create mode 100644 gdb/testsuite/gdb.ada/ptr_typedef/pck.adb
 create mode 100644 gdb/testsuite/gdb.ada/ptr_typedef/pck.ads

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 21b7b2e..c1e7769 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 09266ce..f0901a8 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 1dc763d..ecf28d3 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 0000000..624df18
--- /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 0000000..a24bac3
--- /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 0000000..114fe03
--- /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 0000000..f8a4ed5
--- /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;
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]