public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: "Kempke, Nils-Christian via Gdb-patches" <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>,
	 "Kempke, Nils-Christian" <nils-christian.kempke@intel.com>
Subject: Re: [PATCH 2/2] gdb: Resolve dynamic target types of pointers.
Date: Fri, 15 Apr 2022 10:14:04 -0600	[thread overview]
Message-ID: <87ee1y1fzn.fsf@tromey.com> (raw)
In-Reply-To: <CY4PR1101MB2071337FE4A0527C53014E29B8EF9@CY4PR1101MB2071.namprd11.prod.outlook.com> (Nils-Christian via Gdb-patches Kempke's message of "Thu, 14 Apr 2022 10:22:52 +0000")

> Thanks for the feedback. Sorry that it took me so long to reply - the mail
> somehow got lost..

No need to apologize!  I'm constantly months behind and/or dropping email.

>> > +	  if (type->code () == TYPE_CODE_PTR && is_dynamic_type (type))
>> > +	    {
>> > +	      CORE_ADDR addr;
>> > +	      if (nullptr != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
>> > +		addr = value_address (val);
>> > +	      else
>> > +		addr = value_as_address (val);
>> 
>> This seems weird to me.  When does value_as_address fail?

> This if else has been introduced because of the way ifort/icc describe pointers
> vs. gcc/gfortran and icx/ifx.

> <1><AAA> DW_TAG_variable
>     <> DW_AT_type: <BBB>
>     <> DW_AT_location: (location of the pointer)
> <1><BBB> DW_TAG_pointer_type
>     DW_AT_type: <CCC>
> <1><CCC> DW_TAG_array_type
>     <> DW_AT_type: <DDD>
>     <> DW_AT_data_location: (location of the array)
> <2><EEE> DW_TAG_subrange_type

> Fortran:

> <1><AAA> DW_TAG_variable
>     <>   DW_AT_type: <BBB>
>     <>   DW_AT_location: (location of the pointer) 
> <1><BBB> DW_TAG_array_type
>     <> DW_AT_type: <CCC>
>     <> DW_AT_data_location: (location of the array)
> <2><DDD> DW_TAG_subrange_type

> When printing this pointer to array in gfortran/ifx the pointer print function is
> not actually called - since the DWARF does not emit a pointer here.  Instead,
> the normal array print is invoked which will use the DW_AT_data_location.
> So we do not run into this same problem

I still do not understand, sorry.

For me this looks like two different types.  In one situation, the type
is a pointer to an array.  In the second, it's just an array.  So, I
would expect them to print differently.

Are you saying these should print identically?  If so, that's fine --
but then it seems like something to do in the Fortran code, not in
c-valprint.c.

Maybe in the code the check for TYPE_DATA_LOCATION is a proxy for
checking that the pointer is a pointer to a Fortran array?  I guess I
could understand that, but it doesn't seem like a good approach, because
what if some C compiler starts emitting this?

>> I'm curious why the code added here is not also needed in f-valprint.c.

> The reason here is simply that Fortran does not have this implemented for
> Itself.  Instead the fortran f_langugage inherits from language_defn (the all
> languages base class) which simply delegates the value-print to 
> c_value_print / so changing it there suffices.

If Fortran-specific printing is needed, this will have to change.

Tom

  reply	other threads:[~2022-04-15 16:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 13:26 [PATCH 0/2] Resolve dynamic types for pointers Nils-Christian Kempke
2022-01-18 13:26 ` [PATCH 1/2] gdb/types: Resolve dynamic properties of pointer types Nils-Christian Kempke
2022-01-28 18:30   ` Tom Tromey
2022-01-31  8:15     ` Kempke, Nils-Christian
2022-01-18 13:26 ` [PATCH 2/2] gdb: Resolve dynamic target types of pointers Nils-Christian Kempke
2022-02-10 19:47   ` Tom Tromey
2022-04-14 10:22     ` Kempke, Nils-Christian
2022-04-15 16:14       ` Tom Tromey [this message]
2022-04-19  6:59         ` Kempke, Nils-Christian
2022-05-13 14:45           ` Kempke, Nils-Christian

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=87ee1y1fzn.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nils-christian.kempke@intel.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).