This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Modernize VAX target; return values
- From: Mark Kettenis <kettenis at chello dot nl>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 14 Apr 2004 19:51:11 +0200 (CEST)
- Subject: [PATCH] Modernize VAX target; return values
This revamps the return value support. Writing this also revealed a
bug in the call dummy stuff where I implemented the VAX VMS way of
return structures instead of the VAX Unix way, so this patch fixes
that too.
No deprecated stuff anymore in vax-tdep.c :-).
Committed,
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* vax-tdep.h (vax_regnum): Add VAX_R0_REGNUM and VAX_R1_REGNUM.
* vax-tdep.c (vax_store_arguments): Remove struct_return and
struct_addr arguments. Don't push return value address.
(vax_push_dummy_call): Don't pass STRUCT_RETURN and STRUCT_ADDR as
arguments to vax_store_arguments. Store return value address in
R1.
(vax_store_struct_return, vax_extract_return_value)
(vax_store_return_value): Remove functions.
(vax_return_value): New function.
(vax_gdbarch_init): Set return value. Don't set
deprecated_store_struct_return, deprecated_extract_struct_return
and deprecated_store_return_value.
Index: vax-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/vax-tdep.c,v
retrieving revision 1.73
diff -u -p -r1.73 vax-tdep.c
--- vax-tdep.c 14 Apr 2004 10:58:39 -0000 1.73
+++ vax-tdep.c 14 Apr 2004 17:44:43 -0000
@@ -66,10 +66,13 @@ vax_register_type (struct gdbarch *gdbar
}
+/* The VAX Unix calling convention uses R1 to pass a structure return
+ value address instead of passing it as a first (hidden) argument as
+ the VMS calling convention suggests. */
+
static CORE_ADDR
vax_store_arguments (struct regcache *regcache, int nargs,
- struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
+ struct value **args, CORE_ADDR sp)
{
char buf[4];
int count = 0;
@@ -88,15 +91,6 @@ vax_store_arguments (struct regcache *re
write_memory (sp, VALUE_CONTENTS_ALL (args[i]), len);
}
- /* Push value address. */
- if (struct_return)
- {
- sp -= 4;
- count++;
- store_unsigned_integer (buf, 4, struct_addr);
- write_memory (sp, buf, 4);
- }
-
/* Push argument count. */
sp -= 4;
store_unsigned_integer (buf, 4, count);
@@ -119,8 +113,11 @@ vax_push_dummy_call (struct gdbarch *gdb
char buf[4];
/* Set up the function arguments. */
- sp = vax_store_arguments (regcache, nargs, args, sp,
- struct_return, struct_addr);
+ sp = vax_store_arguments (regcache, nargs, args, sp);
+
+ /* Store return value address. */
+ if (struct_return)
+ regcache_cooked_write_unsigned (regcache, VAX_R1_REGNUM, struct_addr);
/* Store return address in the PC slot. */
sp -= 4;
@@ -164,22 +161,37 @@ vax_unwind_dummy_id (struct gdbarch *gdb
}
-static void
-vax_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
-{
- write_register (1, addr);
-}
+static enum return_value_convention
+vax_return_value (struct gdbarch *gdbarch, struct type *type,
+ struct regcache *regcache, void *readbuf,
+ const void *writebuf)
+{
+ int len = TYPE_LENGTH (type);
+ char buf[8];
+
+ if (TYPE_CODE (type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (type) == TYPE_CODE_ARRAY)
+ return RETURN_VALUE_STRUCT_CONVENTION;
-static void
-vax_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
-{
- memcpy (valbuf, regbuf + DEPRECATED_REGISTER_BYTE (0), TYPE_LENGTH (valtype));
-}
+ if (readbuf)
+ {
+ /* Read the contents of R0 and (if necessary) R1. */
+ regcache_cooked_read (regcache, VAX_R0_REGNUM, buf);
+ if (len > 4)
+ regcache_cooked_read (regcache, VAX_R1_REGNUM, buf + 4);
+ memcpy (readbuf, buf, len);
+ }
+ if (writebuf)
+ {
+ /* Read the contents to R0 and (if necessary) R1. */
+ memcpy (buf, writebuf, len);
+ regcache_cooked_write (regcache, VAX_R0_REGNUM, buf);
+ if (len > 4)
+ regcache_cooked_write (regcache, VAX_R1_REGNUM, buf + 4);
+ }
-static void
-vax_store_return_value (struct type *valtype, char *valbuf)
-{
- deprecated_write_register_bytes (0, valbuf, TYPE_LENGTH (valtype));
+ return RETURN_VALUE_REGISTER_CONVENTION;
}
@@ -426,9 +438,7 @@ vax_gdbarch_init (struct gdbarch_info in
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
/* Return value info */
- set_gdbarch_deprecated_store_struct_return (gdbarch, vax_store_struct_return);
- set_gdbarch_deprecated_extract_return_value (gdbarch, vax_extract_return_value);
- set_gdbarch_deprecated_store_return_value (gdbarch, vax_store_return_value);
+ set_gdbarch_return_value (gdbarch, vax_return_value);
/* Call dummy code. */
set_gdbarch_push_dummy_call (gdbarch, vax_push_dummy_call);
Index: vax-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/vax-tdep.h,v
retrieving revision 1.6
diff -u -p -r1.6 vax-tdep.h
--- vax-tdep.h 12 Apr 2004 16:49:35 -0000 1.6
+++ vax-tdep.h 14 Apr 2004 17:44:43 -0000
@@ -26,6 +26,8 @@
enum vax_regnum
{
+ VAX_R0_REGNUM,
+ VAX_R1_REGNUM,
VAX_AP_REGNUM = 12, /* Argument pointer on user stack. */
VAX_FP_REGNUM, /* Address of executing stack frame. */
VAX_SP_REGNUM, /* Address of top of stack. */