From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112446 invoked by alias); 13 Jul 2016 10:17:47 -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 112430 invoked by uid 89); 13 Jul 2016 10:17:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f47.google.com Received: from mail-wm0-f47.google.com (HELO mail-wm0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 13 Jul 2016 10:17:35 +0000 Received: by mail-wm0-f47.google.com with SMTP id o80so61250003wme.1 for ; Wed, 13 Jul 2016 03:17:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pytKnOljbjx/zTDRHkHhhmQb0CKt7GbfMnue2TCBEW8=; b=ScmxxmHLNlXTMkwC97q91mQTfL/ntXokYDR+JScxHB6OtuOnY61fODlkqhrb4QFQ+w bV5OCVPxOEps2jkXifvJH4cTCMW7DQA0ADj9uENxtWE2YPEksMfVfKEXLrp3a9KboKpZ Bz3RFUGWPEP9BWGovPBtU6zVMA01XXtIqRi02mngLpUTiKWq+jBqWbnmI0GpxXYzXKkA Kac1xaa69n+/aZZJQAjNf60/w1EdXpHtqMOQeEJB+3ubdHW9HwteThEf146UhYwoMKdR usbxD8L+MfZKmdDaSIhtuLb+YXk7tSzj6C5Fi2rl1mGvIRE94ezFqdoSULY6V4E+5nBv pzeA== X-Gm-Message-State: ALyK8tI/Xamn0gaM6gioe2hzA/Tm6QEyqTxkHMkpXPChojQOlbGGSSR5we0p2Hw3Rgz+EQ== X-Received: by 10.28.126.195 with SMTP id z186mr27378351wmc.95.1468405049985; Wed, 13 Jul 2016 03:17:29 -0700 (PDT) Received: from localhost (TK158115.telekabel.at. [195.34.158.115]) by smtp.gmail.com with ESMTPSA id o10sm111117wjz.25.2016.07.13.03.17.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jul 2016 03:17:29 -0700 (PDT) Date: Wed, 13 Jul 2016 10:17:00 -0000 From: Andrew Burgess To: Christoph Weinmann Cc: qiyaoltc@gmail.com, gdb-patches@sourceware.org, jan.kratochvil@redhat.com Subject: Re: [PATCH] fortran: Print logical values as either .FALSE. or .TRUE. Message-ID: <20160713101722.GJ32021@embecosm.com> References: <1468396596-19212-1-git-send-email-christoph.t.weinmann@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1468396596-19212-1-git-send-email-christoph.t.weinmann@intel.com> X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.6.1 (2016-04-27) X-IsSubscribed: yes X-SW-Source: 2016-07/txt/msg00142.txt.bz2 * Christoph Weinmann [2016-07-13 09:56:36 +0200]: > A Logical value in Fortran may be either .FALSE. or .TRUE. > When converting from integer, a subset of compilers evaluate > the whole value, while others only check if the least significant > bit is set. This patch unifies the printing output by evaluating > only the lsb. > > 2014-03-25 Christoph Weinmann > > * f-valprint.c (f_val_print): Print .FALSE. when the lsb > is '0'. Print .TRUE. in all other cases. > > > Signed-off-by: Christoph Weinmann > --- > gdb/f-valprint.c | 15 ++++++++++++++- > 1 files changed, 14 insertions(+), 1 deletions(-) > > diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c > index b6d1ab9..06154d1 100644 > --- a/gdb/f-valprint.c > +++ b/gdb/f-valprint.c > @@ -350,6 +350,20 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, > fprintf_filtered (stream, " )"); > break; > > + case TYPE_CODE_BOOL: > + { > + int val = unpack_long (type, valaddr + embedded_offset); > + /* As a superset of compilers treat logical values > + differently (e.g. .TRUE. can be "-1" or "1", the > + common baseline is to evaluate if the least > + significant bit is set or not. */ > + if ((val & 1) == 0) > + fputs_filtered (f_decorations.false_name, stream); > + else > + fputs_filtered (f_decorations.true_name, stream); > + } > + break; > + Comparing this code to valprint.c:generic_val_print_bool then I see that we loose the ability to force scalar formatting, so I guess: p/d some_bool_variable will no longer work with your patch. I would suggest creating fortran_val_print_bool as a copy of generic_val_print_bool, and then modify only as needed. I agree with Jan that checking the producer string would be the best solution, but failing that I'd write the check of val as: if (val == 0) fputs_filtered ( ... false ... ); else fputs_filtered ( ... true ... ); but I guess that's just a C background, where I'd consider anything non-zero, even if the LSB _was_ zero as true. Thanks, Andrew