From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41250 invoked by alias); 10 May 2016 14:16:26 -0000 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 Received: (qmail 41227 invoked by uid 89); 10 May 2016 14:16:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2955 X-HELO: mga04.intel.com Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 May 2016 14:16:15 +0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 10 May 2016 07:16:14 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga004.fm.intel.com with ESMTP; 10 May 2016 07:16:13 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u4AEGCtC001789; Tue, 10 May 2016 15:16:12 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id u4AEGC1Q030649; Tue, 10 May 2016 16:16:12 +0200 Received: (from heckel@localhost) by ulvlx001.iul.intel.com with œ id u4AEGBAh030645; Tue, 10 May 2016 16:16:12 +0200 From: Bernhard Heckel To: qiyaoltc@gmail.com Cc: gdb-patches@sourceware.org, Bernhard Heckel Subject: [PATCH 2/4] Fortran, typeprint: Take level of details into account when printing elements of a structure. Date: Tue, 10 May 2016 14:16:00 -0000 Message-Id: <1462889739-30359-3-git-send-email-bernhard.heckel@intel.com> In-Reply-To: <1462889739-30359-1-git-send-email-bernhard.heckel@intel.com> References: <1462889739-30359-1-git-send-email-bernhard.heckel@intel.com> X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00168.txt.bz2 According to the typeprint's description, elements of a structure should not be printed when show is <= -1. This variable is also used to distinguish the level of details between "ptype" and "whatis" expressions. Before: (gdb) whatis t1v type = Type t1 integer(kind=4) :: t1_i real(kind=4) :: t1_r End Type t1 After: (gdb) whatis t1v type = Type t1 2016-05-09 Bernhard Heckel gdb/Changelog: * f-typeprint.c (f_type_print_base): Don't print structure fields when show is <= -1. gdb/testsuite/Changelog: * gdb.fortran/whatis_type.exp: Adapt expected output. --- gdb/f-typeprint.c | 27 ++++++++++++++++----------- gdb/testsuite/gdb.fortran/whatis_type.exp | 13 ++----------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 1990e1b..49f374a 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -364,19 +364,24 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, else fprintfi_filtered (level, stream, "Type "); fputs_filtered (TYPE_TAG_NAME (type), stream); - fputs_filtered ("\n", stream); - for (index = 0; index < TYPE_NFIELDS (type); index++) + /* According to the definition, + we only print structure elements in case show >= 0. */ + if (show >= 0) { - f_type_print_base (TYPE_FIELD_TYPE (type, index), stream, show, - level + 4); - fputs_filtered (" :: ", stream); - fputs_filtered (TYPE_FIELD_NAME (type, index), stream); - f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index), - stream, 0, 0, 0, 0); fputs_filtered ("\n", stream); - } - fprintfi_filtered (level, stream, "End Type "); - fputs_filtered (TYPE_TAG_NAME (type), stream); + for (index = 0; index < TYPE_NFIELDS (type); index++) + { + f_type_print_base (TYPE_FIELD_TYPE (type, index), stream, show - 1, + level + 4); + fputs_filtered (" :: ", stream); + fputs_filtered (TYPE_FIELD_NAME (type, index), stream); + f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index), + stream, 0, 0, 0, 0); + fputs_filtered ("\n", stream); + } + fprintfi_filtered (level, stream, "End Type "); + fputs_filtered (TYPE_TAG_NAME (type), stream); + } break; case TYPE_CODE_MODULE: diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp index edaf4fd..2caebe6 100644 --- a/gdb/testsuite/gdb.fortran/whatis_type.exp +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp @@ -38,17 +38,8 @@ gdb_continue_to_breakpoint "bp1" set t1_i "$int :: t1_i" set t1_r "$real :: t1_r" -gdb_test "whatis t1" \ - [multi_line "type = Type t1" \ - " $t1_i" \ - " $t1_r" \ - "End Type t1"] - -gdb_test "whatis t1v" \ - [multi_line "type = Type t1" \ - " $t1_i" \ - " $t1_r" \ - "End Type t1"] +gdb_test "whatis t1" "type = Type t1" +gdb_test "whatis t1v" "type = Type t1" gdb_test "ptype t1" \ [multi_line "type = Type t1" \ -- 2.7.1.339.g0233b80