From: Mark Kettenis Date: Wed, 17 Aug 2005 18:34:17 +0000 (+0000) Subject: * m68k-tdep.c (m68k_return_value): Properly return contents of X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=fdae7ab2819939c90535ca577801c37a097de57a;p=pf3gnuchains%2Fpf3gnuchains3x.git * m68k-tdep.c (m68k_return_value): Properly return contents of structures passed in memory. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8ea18b3656..914910e20f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,8 @@ 2005-08-17 Mark Kettenis + * m68k-tdep.c (m68k_return_value): Properly return contents of + structures passed in memory. + * infcmd.c (print_return_value): Move CHECK_TYPEDEF up. Deal with RETURN_VALUE_ABI_PRESERVED_ADDRESS. diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 31ac09cb4b..ebbe4944c4 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -333,13 +333,25 @@ m68k_return_value (struct gdbarch *gdbarch, struct type *type, { enum type_code code = TYPE_CODE (type); - if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION) - && !m68k_reg_struct_return_p (gdbarch, type)) - return RETURN_VALUE_STRUCT_CONVENTION; + /* GCC returns a `long double' in memory too. */ + if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION) + && !m68k_reg_struct_return_p (gdbarch, type)) + || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12)) + { + /* The default on m68k is to return structures in static memory. + Consequently a function must return the address where we can + find the return value. */ + + if (readbuf) + { + ULONGEST addr; + + regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr); + read_memory (addr, readbuf, TYPE_LENGTH (type)); + } - /* GCC returns a `long double' in memory. */ - if (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12) - return RETURN_VALUE_STRUCT_CONVENTION; + return RETURN_VALUE_ABI_RETURNS_ADDRESS; + } if (readbuf) m68k_extract_return_value (type, regcache, readbuf);