This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/sparc64] internal-error printing return value (Ada array)
> > Hmm, I gueass I should have asked how a gdb `struct type' looks for
> > these Ada arrays? In particular, if main_type->nfields is set and
> > whether main_type->fields is set to something useful.
>
> Ah, I understand now (sorry). Yes, main_type->nfields is 1, and
> main_type->fields contains the bounds.
Ok, that's quite different from what we have for TYPE_CODE_STRUCT and
TYPE_CODE_UNION. This means that adding TYPE_CODE_ARRAY to
sparc64_structure_or_union is the wrong fix.
> In terms of the argument passing, we don't need to worry in our case,
> because arrays are passed by reference. In terms of a return value,
> the ABI says that structs of up to 32 bytes can be returned.
>
> 3.2.3.3. Structure or Union return values
>
> Structure and union return types up to thirty-two bytes in size
> are returned in registers. The registers are assigned as if the
> value was being passed as the first argument to a function with
> a known prototype.
>
> This is why I used the magic number of 32 in this case. I still think
> it is correct, although more comments are certainly required to explain
> the above.
>
> What do you think?
Well, we need to worry about argument passing too; Ada might not pass
arrays directly, but other languages might do that. So I think you should
just add a check for TYPE_CODE_ARRAY to sparc64_extract_return_value() and
sparc64_store_return_value(). You could add it to the same if-block as
the sparc64_structure_of_union() but then you'll need to change the
if (TYPE_CODE (type) != TYPE_CODE_UNION)
check into
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
Mark