From: Mark Kettenis Date: Wed, 14 Apr 2004 17:48:38 +0000 (+0000) Subject: * vax-tdep.h (vax_regnum): Add VAX_R0_REGNUM and VAX_R1_REGNUM. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=67b441e1281bb06d579858018050705524f0dcaa;p=binutils-gdb.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8a239e2f13e..a57733b0412 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,18 @@ +2004-04-14 Mark Kettenis + + * 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. + 2004-04-14 Andreas Schwab * ia64-tdep.c (ia64_libunwind_frame_prev_register): Handle null diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index 5d76cd842e6..d43ba679414 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -66,10 +66,13 @@ vax_register_type (struct gdbarch *gdbarch, int regnum) } +/* 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 *regcache, int nargs, 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 *gdbarch, CORE_ADDR func_addr, 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 *gdbarch, struct frame_info *next_frame) } -static void -vax_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) +static enum return_value_convention +vax_return_value (struct gdbarch *gdbarch, struct type *type, + struct regcache *regcache, void *readbuf, + const void *writebuf) { - write_register (1, addr); -} + int len = TYPE_LENGTH (type); + char buf[8]; -static void -vax_extract_return_value (struct type *valtype, char *regbuf, char *valbuf) -{ - memcpy (valbuf, regbuf + DEPRECATED_REGISTER_BYTE (0), TYPE_LENGTH (valtype)); -} + 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_store_return_value (struct type *valtype, char *valbuf) -{ - deprecated_write_register_bytes (0, valbuf, 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); + } + + return RETURN_VALUE_REGISTER_CONVENTION; } @@ -426,9 +438,7 @@ vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 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); diff --git a/gdb/vax-tdep.h b/gdb/vax-tdep.h index d27f1a88eda..444d758059f 100644 --- a/gdb/vax-tdep.h +++ b/gdb/vax-tdep.h @@ -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. */