From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29031 invoked by alias); 29 Feb 2012 19:30:58 -0000 Received: (qmail 29015 invoked by uid 22791); 29 Feb 2012 19:30:55 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Feb 2012 19:30:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4B77B1C65DF; Wed, 29 Feb 2012 14:30:34 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2AlKHGP3+rig; Wed, 29 Feb 2012 14:30:34 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id DD3FD1C65A8; Wed, 29 Feb 2012 14:30:33 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 676DC145615; Wed, 29 Feb 2012 11:30:27 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [commit/Ada] whatis not printing array type name for value from history Date: Wed, 29 Feb 2012 19:32:00 -0000 Message-Id: <1330543826-25219-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00729.txt.bz2 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. Tested on x86_64-linux. Checked in. --- gdb/ChangeLog | 4 ++ gdb/ada-lang.c | 5 +++ gdb/testsuite/ChangeLog | 4 ++ gdb/testsuite/gdb.ada/whatis_array_val.exp | 44 ++++++++++++++++++++++++ gdb/testsuite/gdb.ada/whatis_array_val/foo.adb | 25 +++++++++++++ gdb/testsuite/gdb.ada/whatis_array_val/pck.adb | 23 ++++++++++++ gdb/testsuite/gdb.ada/whatis_array_val/pck.ads | 19 ++++++++++ 7 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.ada/whatis_array_val.exp create mode 100644 gdb/testsuite/gdb.ada/whatis_array_val/foo.adb create mode 100644 gdb/testsuite/gdb.ada/whatis_array_val/pck.adb create mode 100644 gdb/testsuite/gdb.ada/whatis_array_val/pck.ads diff --git a/gdb/ChangeLog b/gdb/ChangeLog index aebc59f..87567e9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2012-02-29 Joel Brobecker + * ada-lang.c (to_fixed_array_type): Set result's type name. + +2012-02-29 Joel Brobecker + * ada-lang.c (catch_ada_exception_command_split): Add new argument cond_string. Add support for condition at end of "catch exception" commands. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 216f703..7c13910 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -7826,6 +7826,11 @@ to_fixed_array_type (struct type *type0, struct value *dval, error (_("array type with dynamic size is larger than varsize-limit")); } + /* We want to preserve the type name. This can be useful when + trying to get the type name of a value that has already been + printed (for instance, if the user did "print VAR; whatis $". */ + TYPE_NAME (result) = TYPE_NAME (type0); + if (constrained_packed_array_p) { /* So far, the resulting type has been created as if the original diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f8bd318..8a144bc 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-02-29 Joel Brobecker + + * gdb.ada/whatis_array_val: New testcase. + 2012-02-29 Jan Kratochvil Fix disp-step-syscall.exp: fork: single step over fork. 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 0000000..e937f0a --- /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 . + +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 0000000..8fd6d76 --- /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 . + +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 0000000..17f1ff7 --- /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 . + +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 0000000..f99df3d --- /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 . + +with System; +package Pck is + procedure Do_Nothing (A : System.Address); +end Pck; -- 1.7.1