public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
To: Tom Tromey <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"aburgess@redhat.com" <aburgess@redhat.com>
Subject: RE: [PATCH v6 1/1] fortran: Fix arrays of variable length strings for FORTRAN
Date: Fri, 12 Jan 2024 18:57:10 +0000	[thread overview]
Message-ID: <SA1PR11MB684658718B8A76CEC2EE6DEBCB6F2@SA1PR11MB6846.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87zfxbpx31.fsf@tromey.com>

Hi Tom,

Thanks for the feedback.

>> +	 The problem here is that, when we create value's from the dynamic

Tom > The apostrophe should be removed here.

Will fix in V7.

Tom > I guess this is due to the approach taken by the Intel compiler.  Is this true for all Fortran compilers, though?  For example, did you try this with gfortran?

I have tested it with ifort/ifx/gfortran. As per DWARF for VLA strings should be encoded like this for all Fortran compiler. After this change GDB  works fine with ifort/ifx. But in case of gfortran it fails though vla-string itself is also encoded using TYPE_CODE_STRING  but there only issue is unexpectedly string is passed as reference to the structure so gdb is not able to handle. I have created following gcc Bugzilla  issue sometime back and XFAIL is used for gfortran in the vla-array.exp newly added test. 

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101826

Tom > I'm sort of meh on this.  Like, there are other warnings from this function, but on the other hand, this is not something a user can do anything about.  I guess it serves to say "you're about to see garbage".

This was added on feedback so just to handle it and notify, given how closely related arrays and strings seem to be. 

Thanks & Best Regards
Abdul Basit

-----Original Message-----
From: Tom Tromey <tom@tromey.com> 
Sent: Thursday, January 11, 2024 7:03 PM
To: Ijaz, Abdul B <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org; aburgess@redhat.com
Subject: Re: [PATCH v6 1/1] fortran: Fix arrays of variable length strings for FORTRAN

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

> From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com> Before this change 
> resolve_dynamic_array_or_string was called for all TYPE_CODE_ARRAY and 
> TYPE_CODE_STRING types, but, in the end, this function always called 
> create_array_type_with_stride, which creates a TYPE_CODE_ARRAY type.

Thank you for the patch.

> +  else if (ary_dim != NULL && ary_dim->code () == TYPE_CODE_STRING)
> +    {
> +      /* The following special case for TYPE_CODE_STRING should not be
> +	 needed, ideally we would defer resolving the dynamic type of the
> +	 array elements until needed later, and indeed, the resolved type
> +	 of each array element might be different, so attempting to resolve
> +	 the type here makes no sense.
> +
> +	 However, in Fortran, for arrays of strings, each element must be
> +	 the same type, as such, the DWARF for the string length relies on
> +	 the object address of the array itself.
> +
> +	 The problem here is that, when we create value's from the dynamic

The apostrophe should be removed here.

> +	 array type, we resolve the data location, and use that as the
> +	 value address, this completely discards the original value
> +	 address, and it is this original value address that is the
> +	 descriptor for the dynamic array, the very address that the DWARF
> +	 needs us to push in order to resolve the dynamic string length.
> +
> +	 What this means then, is that, given the current state of GDB, if
> +	 we don't resolve the string length now, then we will have lost
> +	 access to the address of the dynamic object descriptor, and so we
> +	 will not be able to resolve the dynamic string later.
> +
> +	 For now then, we handle special case TYPE_CODE_STRING on behalf of
> +	 Fortran, and hope that this doesn't cause problems for anyone
> +	 else.  */

I guess this is due to the approach taken by the Intel compiler.  Is this true for all Fortran compilers, though?  For example, did you try this with gfortran?

These DWARF approaches are really unfortunate -- there should be a more standard way to separate the type's meaning and the type's representation, especially for "slice" types -- but I guess we're stuck with it for now.

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

I'm sort of meh on this.  Like, there are other warnings from this function, but on the other hand, this is not something a user can do anything about.  I guess it serves to say "you're about to see garbage".

thanks,
Tom
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

      reply	other threads:[~2024-01-12 18:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05 13:19 [PATCH v6 0/1] " Abdul Basit Ijaz
2024-01-05 13:19 ` [PATCH v6 1/1] fortran: " Abdul Basit Ijaz
2024-01-11 18:02   ` Tom Tromey
2024-01-12 18:57     ` Ijaz, Abdul B [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=SA1PR11MB684658718B8A76CEC2EE6DEBCB6F2@SA1PR11MB6846.namprd11.prod.outlook.com \
    --to=abdul.b.ijaz@intel.com \
    --cc=aburgess@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).