This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: Start Fortran support for variable objects.
- From: Daniel Jacobowitz <drow at false dot org>
- To: Nick Roberts <nickrob at snap dot net dot nz>
- Cc: Wu Zhou <woodzltc at cn dot ibm dot com>, gdb-patches at sources dot redhat dot com
- Date: Sun, 3 Jul 2005 12:17:06 -0400
- Subject: Re: PATCH: Start Fortran support for variable objects.
- References: <17091.4780.953681.620094@farnswood.snap.net.nz> <20050630131809.GB8241@nevyn.them.org> <17092.28833.284587.118362@farnswood.snap.net.nz> <Pine.LNX.4.63.0506300455390.11503@wks190384wss.cn.ibm.com> <17092.51062.559020.560618@farnswood.snap.net.nz>
On Fri, Jul 01, 2005 at 04:32:54PM +1200, Nick Roberts wrote:
> So I should have done:
>
> (top-gdb) p TYPE_LOW_BOUND(var->type->main_type->fields->type)
> $1 = 1
> (top-gdb) p TYPE_HIGH_BOUND(var->type->main_type->fields->type)
> $2 = 4
Right - specifically, TYPE_LOW_BOUND (TYPE_INDEX_TYPE (var->type))
is supposed to be the lower bound for an array. Tricky. It comes from
read_subrange_type in dwarf2read.c for dwarf2.
> > I guess there might be some errors in the process of creating varobj for
> > Fortran array.
>
> No the information seems to be there. So maybe:
>
> for (i = 0; i < var->num_children; i++)
> {
> /* Mark as the end in case we bail out */
> *((*childlist) + i) = NULL;
>
> j = i + TYPE_LOW_BOUND(var->type->main_type->fields->type);
>
> /* check if child exists, if not create */
> name = name_of_child (var, j);
> child = child_exists (var, name);
> if (child == NULL)
> child = create_child (var, j, name);
>
> *((*childlist) + i) = child;
> }
>
> will work in varobj_list_children in a language independent way.
>
> I'll wait to see what Daniel says though, before submitting another patch.
First of all, never reference ->main_type - see above for the right way
to get the low bound. An even better way (it seems) is to call
get_discrete_bounds. Take a look at value_subscript for an example.
I can't tell what f77_get_dynamic_lowerbound is supposed to handle.
But it does a really, really good impression of reading data which is
no longer set anywhere, so I have the feeling that it is dead code.
Sorry for pointing you at it.
So let's use TYPE_LOW_BOUND for now; does that eliminate the need for
the fortran-specific code?
--
Daniel Jacobowitz
CodeSourcery, LLC