PATCH: Start Fortran support for variable objects.
Nick Roberts
nickrob@snap.net.nz
Fri Jul 1 05:04:00 GMT 2005
> I have two comments below, hope that they might be helpful. Thanks.
>
> On Fri, 1 Jul 2005, Nick Roberts wrote:
>
> > As in the patch below? I don't understand the extra cases it appears to
> > cover, but it worked for the tests I tried.
>
> Maybe it is also helpful to test against such arrays definition as:
>
> integer array(0:5), integer array(-1:4)
>
> or even
>
> integer array(0:5,-1:4)
>
> (if variable object does support multi-dimension array. I don't know much
> about variable object, and MI as a whole.)
Ah! I see now. I've not used such arrays in Fortran. Using
INTEGER ARRAY1(0:5), ARRAY2(-1:4)
INTEGER ARRAY3(0:2,-1:1)
DATA ARRAY1/1,2,3,4,5,6/
DATA ARRAY2/1,2,3,4,5,6/
DATA ARRAY3/11,21,31,12,22,32,13,23,33/
the latest patch seems to work (see attached image below). I am sure
that my original patch would have failed for these cases.
> The second comment is about the following text in a former mail Nick sent:
>
> > Fortran:
> >
> > (top-gdb) p TYPE_LOW_BOUND(var->type)
> > $3 = 0
...
>
> For Fortran array such as DIMENSION I(4), the lower bound should be 1 by
> default. The following session on my box shows this:
>
> <top-gdb> p type->main_type->fields->type->main_type->fields[0].loc.bitpos
> $3 = 1
> <top-gdb> p type->main_type->fields->type->main_type->fields[1].loc.bitpos
> $4 = 4
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
> 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.
Nick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fortran1.png
Type: image/png
Size: 7841 bytes
Desc: fortran watch window
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20050701/6aa11fa9/attachment.png>
More information about the Gdb-patches
mailing list