public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: Tom Tromey <tom@tromey.com>,
	 abdul.b.ijaz@intel.com,
	 "abdul.b.ijaz" <abijaz@ecsmtp.iul.intel.com>,
	 gdb-patches@sourceware.org
Subject: Re: [PATCH 1/1] gdb: Fix arrays of variable length strings for FORTRAN
Date: Fri, 27 Aug 2021 11:02:55 -0600	[thread overview]
Message-ID: <87ilzqom68.fsf@tromey.com> (raw)
In-Reply-To: <20210825085636.GG2581@embecosm.com> (Andrew Burgess's message of "Wed, 25 Aug 2021 09:56:36 +0100")

>> >> case TYPE_CODE_ARRAY:
>> >> +    case TYPE_CODE_STRING:
>> >> c_value_print_array (val, stream, recurse, options);
>> >> break;
>> 
Andrew> I don't understand what part this change plays in this patch.  I can
Andrew> see below how you're now creating values with TYPE_CODE_STRING instead
Andrew> of TYPE_CODE_ARRAY, but then I'd expect these to be covered by the
Andrew> existing handling of TYPE_CODE_STRING in
Andrew> f_language::value_print_inner.

>> I wonder if this should go in generic_value_print instead.

Andrew> generic_val_print_array doesn't print arrays of character type things
Andrew> as a string, so I think having this change in c_value_print_inner
Andrew> makes sense.

In this case, though, the patch is adding new treatment for
TYPE_CODE_STRING.  It seems to me that it would make sense to handle
this in the generic code.

Andrew> I did wonder if we should _also_ change generic_val_print though, as
Andrew> this would catch any language that wasn't Fortran, C, or C++ that
Andrew> called into generic_val_print and didn't already handle
Andrew> TYPE_CODE_STRING.

Yeah.

Andrew> However, that's only Modula2 and Pascal, both of which already handle
Andrew> TYPE_CODE_ARRAY and do something similar to C's print character types
Andrew> as a string, which leads me to think that maybe both of these
Andrew> languages should be handling TYPE_CODE_STRING as an alias for
Andrew> TYPE_CODE_ARRAY.

That would be fine as well.  It's still often useful for the generic
code to handle a case, because users can language-switch and wind up
printing an "unexpected" type via the "wrong" language, like:

(gdb) print value_of_type_code_string
(gdb) set lang c
(gdb) print $

Andrew> I'm also tempted to say that the Modula2 and Pascal changes are
Andrew> optional, as that seems like an edge case (user debugging Fortran code
Andrew> with the language forced to one of those two choices).

This should do something sensible when possible.  It doesn't always --
sometimes the languages have special code to decode things.  But, that
seems like a not very good way to do it to me; better instead to unify
the type system and then the fallback code can do something useful, even
if not fully correct for the current language (which isn't always
possible).

One question for me is, if TYPE_CODE_STRING is a string, can we avoid
language-specific code for it at all?  And just always handle it in the
generic code.

Tom

  reply	other threads:[~2021-08-27 17:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 11:06 [PATCH 0/1] Fix variable length strings array " abdul.b.ijaz
2021-08-20 11:06 ` [PATCH 1/1] gdb: Fix arrays of variable length strings " abdul.b.ijaz
2021-08-20 15:52   ` Andrew Burgess
2021-08-23  8:47     ` Ijaz, Abdul B
2021-08-25  8:36       ` Andrew Burgess
2021-08-27  9:11         ` Ijaz, Abdul B
2021-08-23 20:54     ` Tom Tromey
2021-08-25  8:56       ` Andrew Burgess
2021-08-27 17:02         ` Tom Tromey [this message]
2021-12-29 11:31           ` Ijaz, Abdul B
2022-04-11 14:51             ` Ijaz, Abdul B
2022-04-15 16:33             ` Tom Tromey
2021-08-20 17:02   ` Andrew Burgess

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=87ilzqom68.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=abdul.b.ijaz@intel.com \
    --cc=abijaz@ecsmtp.iul.intel.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).