aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386-tdep.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2004-05-08 23:02:10 +0000
committerMark Kettenis <kettenis@gnu.org>2004-05-08 23:02:10 +0000
commit31db7b6c38e66697f1353f6fbfba62c306d84240 (patch)
tree8837c3b26c49054e0d70bf118a97a36394fa6c88 /gdb/i386-tdep.c
parent0543f3876c21499784e5f3624fd74bee30951874 (diff)
downloadgdb-31db7b6c38e66697f1353f6fbfba62c306d84240.zip
gdb-31db7b6c38e66697f1353f6fbfba62c306d84240.tar.gz
gdb-31db7b6c38e66697f1353f6fbfba62c306d84240.tar.bz2
* defs.h (enum return_value_convention): Add
RETURN_VALUE_ABI_RETURNS_ADDRESS and RETURN_VALUE_ABI_PRESERVES_ADDRESS. * infcmd.c (legacy_return_value): New function. (print_return_value): Rwerite to implement RETURN_VALUE_ABI_RETURNS_ADDRESS. * values.c (using_struct_return): Check for inequality to RETURN_VALUE_REGISTER_CONVENTION instead of equality to RETURN_VALUE_STRUCT_CONVENTION. * i386-tdep.c (i386_return_value): Implement RETURN_VALUE_ABI_RETURNS_ADDRESS.
Diffstat (limited to 'gdb/i386-tdep.c')
-rw-r--r--gdb/i386-tdep.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 8542ef9..5f39529 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1352,7 +1352,28 @@ i386_return_value (struct gdbarch *gdbarch, struct type *type,
if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
&& !i386_reg_struct_return_p (gdbarch, type))
- return RETURN_VALUE_STRUCT_CONVENTION;
+ {
+ /* The System V ABI says that:
+
+ "A function that returns a structure or union also sets %eax
+ to the value of the original address of the caller's area
+ before it returns. Thus when the caller receives control
+ again, the address of the returned object resides in register
+ %eax and can be used to access the object."
+
+ So the ABI guarantees that we can always find the return
+ value just after the function has returned. */
+
+ if (readbuf)
+ {
+ ULONGEST addr;
+
+ regcache_raw_read_unsigned (regcache, I386_EAX_REGNUM, &addr);
+ read_memory (addr, readbuf, TYPE_LENGTH (type));
+ }
+
+ return RETURN_VALUE_ABI_RETURNS_ADDRESS;
+ }
/* This special case is for structures consisting of a single
`float' or `double' member. These structures are returned in