public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/fortran: Handle dynamic string types when printing types
Date: Wed, 15 Jul 2020 08:52:43 +0100	[thread overview]
Message-ID: <20200715075243.GD2737@embecosm.com> (raw)
In-Reply-To: <36dd4104-74b7-90ad-7aba-ce6d09d36c5c@polymtl.ca>

* Simon Marchi <simon.marchi@polymtl.ca> [2020-07-14 22:10:58 -0400]:

> On 2020-07-14 6:03 a.m., Andrew Burgess wrote:
> > After commit:
> > 
> >   commit 8c2e4e0689ea244d0ed979171a3d09c9176b8175
> >   Date:   Sun Jul 12 22:58:51 2020 -0400
> > 
> >       gdb: add accessors to struct dynamic_prop
> > 
> > An existing bug was exposed in the Fortran type printing code.  When
> > GDB is asked to print the type of a function that takes a dynamic
> > string argument GDB will try to read the upper bound of the string.
> > 
> > The read of the upper bound is written as:
> > 
> >     if (type->bounds ()->high.kind () == PROP_UNDEFINED)
> >       // Treat the upper bound as unknown.
> >     else
> >       // Treat the upper bound as known and constant.
> > 
> > However, this is not good enough.  When printing a function type the
> > dynamic argument types will not have been resolved.  As a result the
> > dynamic property is not PROP_UNDEFINED, but nor is it constant.
> > 
> > By rewriting this code to specifically check for the PROP_CONST case,
> > and treating all other cases as the upper bound being unknown we avoid
> > incorrectly treating the dynamic property as being constant.
> > 
> > gdb/ChangeLog:
> > 
> > 	* f-typeprint.c (f_type_print_base): Allow for dynamic types not
> > 	being resolved.
> > 
> > gdb/testsuite/ChangeLog:
> > 
> > 	* gdb.fortran/ptype-on-functions.exp: Add more tests.
> > 	* gdb.fortran/ptype-on-functions.f90: Likewise.
> 
> Thanks, FWIW this LGTM.

Thanks.

> 
> Just wondering, if there were no existing test that caught this, how did you
> find it?  In an external testsuite?

No, I was writing tests for another patch that's still WIP.  Honestly
I was surprised that this wasn't already covered.

Thanks,
Andrew

  reply	other threads:[~2020-07-15  7:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 10:03 Andrew Burgess
2020-07-15  2:10 ` Simon Marchi
2020-07-15  7:52   ` Andrew Burgess [this message]
2020-07-15 13:03 ` Tom de Vries
2020-07-15 15:11   ` 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=20200715075243.GD2737@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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).