From patchwork Fri Nov 16 13:10:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Wodkowski X-Patchwork-Id: 30166 Received: (qmail 40555 invoked by alias); 16 Nov 2018 13:11:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 40433 invoked by uid 89); 16 Nov 2018 13:11:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_FAIL, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mga12.intel.com Received: from mga12.intel.com (HELO mga12.intel.com) (192.55.52.136) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Nov 2018 13:11:21 +0000 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2018 05:11:20 -0800 Received: from kraken.imu.intel.com ([10.217.246.153]) by fmsmga007.fm.intel.com with ESMTP; 16 Nov 2018 05:11:18 -0800 From: Pawel Wodkowski To: gdb-patches@sourceware.org, murbanski@pl.sii.eu, sbasierski@pl.sii.eu Cc: tim.wiederhake@intel.com, dragos.carciumaru@intel.com, Bernhard Heckel Subject: [PATCH 4/7] Fortran: Ptype, print type extension. Date: Fri, 16 Nov 2018 14:10:01 +0100 Message-Id: <1542373804-76019-4-git-send-email-pwodkowski@pl.sii.eu> In-Reply-To: <1542373804-76019-1-git-send-email-pwodkowski@pl.sii.eu> References: <1542373804-76019-1-git-send-email-pwodkowski@pl.sii.eu> From: Bernhard Heckel Print base-class of an extended type when doing a ptype. 2016-05-24 Bernhard Heckel gdb/Changelog: * gdb/f-typeprint.c (f_type_print_derivation_info): New. (f_type_print_base): Print baseclass info. gdb/Testsuite/Changelog: * gdb.fortran/oop-extend-type.exp: Adapt expected results. --- gdb/f-typeprint.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 3f13c111ac56..133eaf9b9848 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -256,6 +256,25 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, } } +/* If TYPE is an extended type, then print out derivation information. + + A typical output could look like this: + "Type, extends(point) :: waypoint" + " Type point :: point" + " real(kind=4) :: angle" + "End Type waypoint" + */ + +static void +f_type_print_derivation_info (struct type *type, struct ui_file *stream) +{ + /* Fortran doesn't support multiple inheritance. */ + int i = 0; + + if (TYPE_N_BASECLASSES (type) > 0) + fprintf_filtered (stream, ", extends(%s) ::", TYPE_NAME (TYPE_BASECLASS (type, i))); +} + /* Print the name of the type (or the ultimate pointer target, function value or array element), or the description of a structure or union. @@ -372,10 +391,15 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: if (TYPE_CODE (type) == TYPE_CODE_UNION) - fprintfi_filtered (level, stream, "Type, C_Union :: "); + fprintfi_filtered (level, stream, "Type, C_Union ::"); else - fprintfi_filtered (level, stream, "Type "); - fputs_filtered (TYPE_NAME (type), stream); + fprintfi_filtered (level, stream, "Type"); + + if (show > 0) + f_type_print_derivation_info (type, stream); + + fprintf_filtered (stream, " %s", TYPE_NAME (type)); + /* According to the definition, we only print structure elements in case show > 0. */ if (show > 0)