This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/sparc64] internal-error printing return value (Ada array)


Hello,

When working on GDB for sparc64-sun-solaris, I noticed that GDB
reports an internal error when trying to print the return value
of a function returning an Ada (fixed-size) array. I noticed this
in gdb.ada/array_return.exp:

    FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small
    FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Large

Here is what happens. First the transcript:

    (gdb) b pck.adb:5
    Breakpoint 1 at 0x100009e84: file pck.adb, line 5.
    (gdb) run
    Starting program: /[...]/p 
    
    Breakpoint 1, pck.create_small () at pck.adb:5
    5             return (others => 1);
    (gdb) fin
    Run till exit from #0  pck.create_small () at pck.adb:5
    0x0000000100009fd0 in p () at p.adb:7
    7          Small := Create_Small;
    sparc64-tdep.c:1092: internal-error: sparc64_extract_return_value: Assertion `sp
    arc64_integral_or_pointer_p (type)' failed.

The type in question is a TYPE_CODE_ARRAY. It seems that this case
is not handled yet by the function that extracts the return value:

        sparc64-tdep.c:sparc64_extract_return_value

I am not sure yet whether this case is specific to Ada or if we can
reproduce the same with C, I will double-check. In any case, these
array objects are returned the same way as struct objects: Up to 32 bytes,
they are passed by register, otherwise %o0 contains the address of the
returned object.

I think the best fix for this is to update sparc64_structure_or_union_p
to accept arrays of 32 bytes or less. The name would become slightly
misleading for its actual implementation, and I wouldn't mind changing
it if felt necessary.

I don't know if the same issue applies to 32bit GDB or not. I tried,
but "fin" doesn't stop at the function return, so I never get the
returned value printed by GDB. I'll have a look at this another time.

I also noticed that the same problem happens for arrays larger than
32bytes. In fact, this is not specific to arrays, but to structures
as well. Support for structures larger than 32 bytes seems to be
missing. I can add that too, but let's make this another patch.

2006-11-10  Joel Brobecker  <brobecker@adacore.com>

        * sparc64-tdep.c (sparc64_structure_or_union_p): Accept array
        types if the type length is 32 bytes or less.

Fixes the two FAILs above, no regression.
OK to apply?

Thanks,
-- 
Joel

Attachment: sparc64-tdep.c.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]