public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org,  aburgess@redhat.com,  tom@tromey.com
Subject: Re: [PATCH v7 1/1] fortran: Fix arrays of variable length strings for FORTRAN
Date: Thu, 17 Oct 2024 17:39:43 -0600	[thread overview]
Message-ID: <87v7xq1eps.fsf@tromey.com> (raw)
In-Reply-To: <20241010210112.781-2-abdul.b.ijaz@intel.com> (Abdul Basit Ijaz's message of "Thu, 10 Oct 2024 23:01:12 +0200")

>>>>> "Abdul" == Abdul Basit Ijaz <abdul.b.ijaz@intel.com> writes:

Abdul> Before this change resolve_dynamic_array_or_string was called for
Abdul> all TYPE_CODE_ARRAY and TYPE_CODE_STRING types, but, in the end,
Abdul> this function always called create_array_type_with_stride, which
Abdul> creates a TYPE_CODE_ARRAY type.

This part makes sense to me but I have some other questions & comments.

Abdul> Lastly, in gdb.opt/fortran-string.exp and gdb.fortran/string-types.exp
Abdul> tests it expects type of character array in 'character (3)' format but now
Abdul> after this change we get 'character*3', so tests are updated accordingly.

I don't know Fortran but I gather this is the result of the
array->string change.

Abdul> --- a/gdb/c-valprint.c
Abdul> +++ b/gdb/c-valprint.c
Abdul> @@ -427,6 +427,7 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
Abdul>    switch (type->code ())
Abdul>      {
Abdul>      case TYPE_CODE_ARRAY:
Abdul> +    case TYPE_CODE_STRING:
Abdul>        c_value_print_array (val, stream, recurse, options);

I think it would be better to put this in generic_value_print instead.

The normal rule (not extremely well enforced maybe) is that a language's
value-printer should defer to this for any types it doesn't understand.

Abdul> +	 The problem here is that, when we create values from the dynamic
Abdul> +	 array type, we resolve the data location, and use that as the
Abdul> +	 value address, this completely discards the original value
Abdul> +	 address

I don't think I understand why this happens.
Maybe some DWARF snippet is missing from either this comment or from the
explanatory text in the commit.

Abdul> +  if (prop != nullptr && type->code () == TYPE_CODE_STRING)
Abdul> +    {
Abdul> +       prop = nullptr;
Abdul> +       warning (_("byte stride property ignored on string type"));
Abdul> +    }

Seems weird to warn in this low-level code.

IMO this could be silently ignored and/or enforced by the debuginfo
readers.

Given this new code, is f77_get_dynamic_length_of_aggregate still
necessary?  If so, why?  Since it seems like now there are two different
ways of doing the same thing.  (Note this isn't necessarily bad -- Ada
has to do this since there are different debuginfo representations that
wind up as different internal representations in gdb.)

Tom

  reply	other threads:[~2024-10-17 23:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 21:01 [PATCH v7 0/1] " Abdul Basit Ijaz
2024-10-10 21:01 ` [PATCH v7 1/1] fortran: " Abdul Basit Ijaz
2024-10-17 23:39   ` Tom Tromey [this message]
2024-10-24 13:31     ` Ijaz, Abdul B

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=87v7xq1eps.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=abdul.b.ijaz@intel.com \
    --cc=aburgess@redhat.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).