Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, AlokKumar.Sharma@amd.com
Subject: Re: [PATCHv2] gdb/fortran: Fix printing of logical true values for Flang
Date: Tue, 03 Mar 2020 17:24:00 -0000	[thread overview]
Message-ID: <20200303172416.GW3317@embecosm.com> (raw)
In-Reply-To: <87pndtcsck.fsf@tromey.com>

* Tom Tromey <tom@tromey.com> [2020-03-03 09:31:55 -0700]:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> 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


      reply	other threads:[~2020-03-03 17:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 17:00 [PATCH] gdb/fortran Fixed " Sharma, Alok Kumar
2020-03-02 18:21 ` [PATCHv2] gdb/fortran: Fix " Andrew Burgess
2020-03-03  4:47   ` Sharma, Alok Kumar
2020-03-03 18:21     ` Andrew Burgess
2020-03-04  8:48       ` [gdb/testsuite] Fix missing uint8_t in gdb.fortran/logical.exp Tom de Vries
2020-03-11 10:24         ` Andrew Burgess
2020-03-11 12:00           ` Tom de Vries
2020-03-03 16:32   ` [PATCHv2] gdb/fortran: Fix printing of logical true values for Flang Tom Tromey
2020-03-03 17:24     ` Andrew Burgess [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200303172416.GW3317@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=AlokKumar.Sharma@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox