[commit] Wrong return convention for arrays (mips-irix)

Joel Brobecker brobecker@adacore.com
Sat Jan 9 05:00:00 GMT 2010


Consider the following function returning an array whose size is
128 bits or smaller:  
 
    type Data_Small is array (1 .. 2) of Integer;
    function Create_Small return Data_Small;

GDB claims that the return value cannot be printed at the end of
a "finish":

    (gdb) break create_small
    Breakpoint 1 at 0x10002954: file pck.adb, line 5. 
    (gdb) run
    Starting program: /[...]/p

    Breakpoint 1, pck.create_small () at pck.adb:5
    5             return (others => 1);
    (gdb) finish
    Run till exit from #0  pck.create_small () at pck.adb:5
    0x10002bdc in p () at p.adb:8
    8          Small := Create_Small;
    Value returned has type: pck__data_small. Cannot determine contents

The problem comes from mips-tdep.c:mips_n32n64_return_value which
considers that arrays are always returned using the
RETURN_VALUE_STRUCT_CONVENTION.  But in fact, this is not entirely
correct. Looking at the ABI, all composite types that are 128bits
or smaller are returned via $2 and $3 (except for the special case
of a struct containing one or two floats).

This patch modifies the logic accordingly.

gdb/ChangeLog:

        Wrong return convention for arrays (mips-irix).
        * mips-tdep.c (mips_n32n64_return_value): Arrays whose size is
        128 bits or smaller are returned the same way as structs
        and unions of the the same size.

-- 
Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0009-Wrong-return-convention-for-arrays-mips-irix.patch
Type: text/x-diff
Size: 1990 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20100109/9dc5fb98/attachment.bin>


More information about the Gdb-patches mailing list