From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70739 invoked by alias); 3 Mar 2020 17:24:24 -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 70618 invoked by uid 89); 3 Mar 2020 17:24:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-wr1-f50.google.com Received: from mail-wr1-f50.google.com (HELO mail-wr1-f50.google.com) (209.85.221.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Mar 2020 17:24:21 +0000 Received: by mail-wr1-f50.google.com with SMTP id y17so5402633wrn.6 for ; Tue, 03 Mar 2020 09:24:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XxHv6EvXBzj/lBnUYWX/22mrdhB90Nnt7piRDdMveg0=; b=a2rPc5CoK44zWpC81TVQOTkHyPo37XbIrOG2d4Hp0j4c+HCJirM44VbAWJKwpO5FEp zIxxjecfeY350GBRV6yaY2ufu3KB8/OSZ7UGlYNH3OROSBxshGM7AeKwnRANA65e2lz/ tTvjt+CMlpX4EJ7WEBRmi+tM+Fca7rFBi/IPU9HebmjWxm90mBTGt9xayeAN1ucYu/oo RhcmvTOko4y8TdTSbvPWIYngKd1SofRkORPtS3oJ75FfoTzLQr1SJnQWB1DIt4U8wNK3 sx1sKqvvOe897njhpe9aXq4f9W/yBNk2FsW+xAWFTvcsmStlctHzmWRTGSuCPIpdqxOk wWHQ== Return-Path: Received: from localhost ([212.69.42.53]) by smtp.gmail.com with ESMTPSA id m16sm3153241wrs.67.2020.03.03.09.24.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Mar 2020 09:24:17 -0800 (PST) Date: Tue, 03 Mar 2020 17:24:00 -0000 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org, AlokKumar.Sharma@amd.com Subject: Re: [PATCHv2] gdb/fortran: Fix printing of logical true values for Flang Message-ID: <20200303172416.GW3317@embecosm.com> References: <20200302182152.12819-1-andrew.burgess@embecosm.com> <87pndtcsck.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pndtcsck.fsf@tromey.com> X-Fortune: It is better to give than to lend, and it costs about the same. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2020-03/txt/msg00061.txt * Tom Tromey [2020-03-03 09:31:55 -0700]: > >>>>> "Andrew" == Andrew Burgess writes: > > Andrew> Thanks for looking into this. I think that the best solution right > Andrew> now will be to handle TYPE_CODE_BOOL in f_val_print rather than > Andrew> modifying generic_val_print_bool. > > Agreed. > > Andrew> The other possibility would be, I think, to add a new field to 'struct > Andrew> language_defn' and use this in generic_val_print_bool instead of > Andrew> comparing the value of current_lanuage directly, however, this isn't > Andrew> the common approach, so I'd prefer to handle this case just like other > Andrew> TYPE_CODE_* are handled for now. > > It would be nice if we could get away from having separate printing code > for each language. I don't know how practical this is though. I am slowly working on converting the language structure into a true class, my thinking is that this would make it much easier to add more per-language functions, and specialise as needed. In this case we would then remove the special handling for Fortran and make the common code be something like: .... const gdb_byte *valaddr = value_contents_for_printing (original_value); val = unpack_long (type, valaddr + embedded_offset * unit_size); if (current_language->is_logical_false (val)) fputs_filtered (decorations->false_name, stream); else if (current_language->is_logical_true (val)) fputs_filtered (decorations->true_name, stream); else print_longest (stream, 'd', 0, val); .... I think there's lots of places in the value printing (and maybe evaluation) code where we copy blocks of code just to allow for small specialisations, I'd hope we could start to recombine some of this stuff... Thanks, Andrew > > Andrew> I know that in places within GDB we do compare the value of > Andrew> current_lanuage to the know language structures, but I'd like to move > Andrew> us away from doing this. > > Also agreed. > > Tom