diff options
author | Mark Kettenis <kettenis@gnu.org> | 2005-08-17 18:34:17 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2005-08-17 18:34:17 +0000 |
commit | 1c845060d9711cc8fa09113bdb73c64b0d58dcaf (patch) | |
tree | 375cb93dda0080fa0a99ff3b43ff8fcfcc424abb /gdb/m68k-tdep.c | |
parent | 3b6940c0d1e5be395d19c787d33e65f6edb545b2 (diff) | |
download | gdb-1c845060d9711cc8fa09113bdb73c64b0d58dcaf.zip gdb-1c845060d9711cc8fa09113bdb73c64b0d58dcaf.tar.gz gdb-1c845060d9711cc8fa09113bdb73c64b0d58dcaf.tar.bz2 |
* m68k-tdep.c (m68k_return_value): Properly return contents of
structures passed in memory.
Diffstat (limited to 'gdb/m68k-tdep.c')
-rw-r--r-- | gdb/m68k-tdep.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 31ac09c..ebbe494 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); |