[PATCH] gdb/fortran: Handle dynamic string types when printing types
Andrew Burgess
andrew.burgess@embecosm.com
Wed Jul 15 07:52:43 GMT 2020
* 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
More information about the Gdb-patches
mailing list