From 97092415597fbfb41f2c028e95b895966d52996f Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sun, 13 Jun 2004 13:42:33 +0000 Subject: [PATCH] Index: ChangeLog 2004-06-13 Andrew Cagney * gdbarch.sh (RETURN_VALUE_ON_STACK): Delete method. * gdbarch.h, gdbarch.c: Re-generate. * m68hc11-tdep.c (m68hc11_return_value_on_stack): Delete function. (m68hc11_use_struct_convention): Delete function. (m68hc11_extract_struct_value_address): Delete function. (m68hc11_return_value): New function. (m68hc11_gdbarch_init): Instead of store_return_value, extract_return_value, return_value_on_stack, deprecated_extract_struct_value_address and use_struct_convention, set return_value. * values.c (using_struct_return): Do not call RETURN_VALUE_ON_STACK. * arch-utils.h (generic_return_value_on_stack_not): Delete declaration. * arch-utils.c (generic_return_value_on_stack_not): Delete function. Index: doc/ChangeLog 2004-06-13 Andrew Cagney * gdbint.texinfo (Target Architecture Definition): Delete description of RETURN_VALUE_ON_STACK. --- gdb/ChangeLog | 19 +++++++++++++++++++ gdb/arch-utils.c | 6 ------ gdb/arch-utils.h | 5 ----- gdb/doc/ChangeLog | 5 +++++ gdb/doc/gdbint.texinfo | 37 ------------------------------------- gdb/gdbarch.c | 31 ------------------------------- gdb/gdbarch.h | 15 ++------------- gdb/gdbarch.sh | 6 ++---- gdb/m68hc11-tdep.c | 48 ++++++++++++++++++------------------------------ gdb/values.c | 3 +-- 10 files changed, 47 insertions(+), 128 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 74179f7..79e0e0e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +2004-06-13 Andrew Cagney + + * gdbarch.sh (RETURN_VALUE_ON_STACK): Delete method. + * gdbarch.h, gdbarch.c: Re-generate. + * m68hc11-tdep.c (m68hc11_return_value_on_stack): Delete function. + (m68hc11_use_struct_convention): Delete function. + (m68hc11_extract_struct_value_address): Delete function. + (m68hc11_return_value): New function. + (m68hc11_gdbarch_init): Instead of store_return_value, + extract_return_value, return_value_on_stack, + deprecated_extract_struct_value_address and use_struct_convention, + set return_value. + * values.c (using_struct_return): Do not call + RETURN_VALUE_ON_STACK. + * arch-utils.h (generic_return_value_on_stack_not): Delete + declaration. + * arch-utils.c (generic_return_value_on_stack_not): Delete + function. + 2004-06-12 Andrew Cagney * values.c (register_value_being_returned): Delete function. diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index ccafd2b..2ec0674 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -84,12 +84,6 @@ legacy_register_sim_regno (int regnum) return LEGACY_SIM_REGNO_IGNORE; } -int -generic_return_value_on_stack_not (struct type *type) -{ - return 0; -} - CORE_ADDR generic_skip_trampoline_code (CORE_ADDR pc) { diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index f427424..df6f0a6 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -43,11 +43,6 @@ extern gdbarch_store_return_value_ftype legacy_store_return_value; address passed as an invisible first argument to the function. */ extern gdbarch_use_struct_convention_ftype always_use_struct_convention; -/* Only structures, unions, and arrays are returned using the struct - convention. Note that arrays are never passed by value in the C - language family, so that case is irrelevant for C. */ -extern gdbarch_return_value_on_stack_ftype generic_return_value_on_stack_not; - /* Typical remote_translate_xfer_address */ extern gdbarch_remote_translate_xfer_address_ftype generic_remote_translate_xfer_address; diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index c97de03..7eb2a6c 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2004-06-13 Andrew Cagney + + * gdbint.texinfo (Target Architecture Definition): Delete + description of RETURN_VALUE_ON_STACK. + 2004-06-09 Andrew Cagney * gdbint.texinfo (Native Debugging): Restore "@table @code" diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 047b801..e85a2c7 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -3503,43 +3503,6 @@ form. Return the appropriate register set for a core file section with name @var{sect_name} and size @var{sect_size}. - -@item RETURN_VALUE_ON_STACK(@var{type}) -@findex RETURN_VALUE_ON_STACK -@cindex returning structures by value -@cindex structures, returning by value - -Return non-zero if values of type TYPE are returned on the stack, using -the ``struct convention'' (i.e., the caller provides a pointer to a -buffer in which the callee should store the return value). This -controls how the @samp{finish} command finds a function's return value, -and whether an inferior function call reserves space on the stack for -the return value. - -The full logic @value{GDBN} uses here is kind of odd. - -@itemize @bullet -@item -If the type being returned by value is not a structure, union, or array, -and @code{RETURN_VALUE_ON_STACK} returns zero, then @value{GDBN} -concludes the value is not returned using the struct convention. - -@item -Otherwise, @value{GDBN} calls @code{USE_STRUCT_CONVENTION} (see below). -If that returns non-zero, @value{GDBN} assumes the struct convention is -in use. -@end itemize - -In other words, to indicate that a given type is returned by value using -the struct convention, that type must be either a struct, union, array, -or something @code{RETURN_VALUE_ON_STACK} likes, @emph{and} something -that @code{USE_STRUCT_CONVENTION} likes. - -Note that, in C and C@t{++}, arrays are never returned by value. In those -languages, these predicates will always see a pointer type, never an -array type. All the references above to arrays being returned by value -apply only to other languages. - @item SOFTWARE_SINGLE_STEP_P() @findex SOFTWARE_SINGLE_STEP_P Define this as 1 if the target does not have a hardware single-step diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 156f9c1..b101db8 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -184,7 +184,6 @@ struct gdbarch gdbarch_deprecated_pop_frame_ftype *deprecated_pop_frame; gdbarch_deprecated_store_struct_return_ftype *deprecated_store_struct_return; gdbarch_return_value_ftype *return_value; - gdbarch_return_value_on_stack_ftype *return_value_on_stack; gdbarch_extract_return_value_ftype *extract_return_value; gdbarch_store_return_value_ftype *store_return_value; gdbarch_deprecated_extract_return_value_ftype *deprecated_extract_return_value; @@ -333,7 +332,6 @@ struct gdbarch startup_gdbarch = 0, /* deprecated_pop_frame */ 0, /* deprecated_store_struct_return */ 0, /* return_value */ - 0, /* return_value_on_stack */ 0, /* extract_return_value */ 0, /* store_return_value */ 0, /* deprecated_extract_return_value */ @@ -463,7 +461,6 @@ gdbarch_alloc (const struct gdbarch_info *info, current_gdbarch->convert_register_p = generic_convert_register_p; current_gdbarch->pointer_to_address = unsigned_pointer_to_address; current_gdbarch->address_to_pointer = unsigned_address_to_pointer; - current_gdbarch->return_value_on_stack = generic_return_value_on_stack_not; current_gdbarch->extract_return_value = legacy_extract_return_value; current_gdbarch->store_return_value = legacy_store_return_value; current_gdbarch->use_struct_convention = generic_use_struct_convention; @@ -611,7 +608,6 @@ verify_gdbarch (struct gdbarch *current_gdbarch) /* Skip verify of deprecated_pop_frame, has predicate */ /* Skip verify of deprecated_store_struct_return, has predicate */ /* Skip verify of return_value, has predicate */ - /* Skip verify of return_value_on_stack, invalid_p == 0 */ /* Skip verify of extract_return_value, invalid_p == 0 */ /* Skip verify of store_return_value, invalid_p == 0 */ /* Skip verify of use_struct_convention, invalid_p == 0 */ @@ -1809,16 +1805,6 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: remote_translate_xfer_address = 0x%08lx\n", (long) current_gdbarch->remote_translate_xfer_address); -#ifdef RETURN_VALUE_ON_STACK - fprintf_unfiltered (file, - "gdbarch_dump: %s # %s\n", - "RETURN_VALUE_ON_STACK(type)", - XSTRING (RETURN_VALUE_ON_STACK (type))); - fprintf_unfiltered (file, - "gdbarch_dump: RETURN_VALUE_ON_STACK = <0x%08lx>\n", - (long) current_gdbarch->return_value_on_stack - /*RETURN_VALUE_ON_STACK ()*/); -#endif #ifdef SDB_REG_TO_REGNUM fprintf_unfiltered (file, "gdbarch_dump: %s # %s\n", @@ -3576,23 +3562,6 @@ set_gdbarch_return_value (struct gdbarch *gdbarch, gdbarch->return_value = return_value; } -int -gdbarch_return_value_on_stack (struct gdbarch *gdbarch, struct type *type) -{ - gdb_assert (gdbarch != NULL); - gdb_assert (gdbarch->return_value_on_stack != NULL); - if (gdbarch_debug >= 2) - fprintf_unfiltered (gdb_stdlog, "gdbarch_return_value_on_stack called\n"); - return gdbarch->return_value_on_stack (type); -} - -void -set_gdbarch_return_value_on_stack (struct gdbarch *gdbarch, - gdbarch_return_value_on_stack_ftype return_value_on_stack) -{ - gdbarch->return_value_on_stack = return_value_on_stack; -} - void gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, void *valbuf) { diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 6a0dbaa..6e05cab 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -1155,19 +1155,8 @@ typedef enum return_value_convention (gdbarch_return_value_ftype) (struct gdbarc extern enum return_value_convention gdbarch_return_value (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, void *readbuf, const void *writebuf); extern void set_gdbarch_return_value (struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value); -/* The deprecated methods RETURN_VALUE_ON_STACK, EXTRACT_RETURN_VALUE, - STORE_RETURN_VALUE and USE_STRUCT_CONVENTION have all been folded - into RETURN_VALUE. */ - -typedef int (gdbarch_return_value_on_stack_ftype) (struct type *type); -extern int gdbarch_return_value_on_stack (struct gdbarch *gdbarch, struct type *type); -extern void set_gdbarch_return_value_on_stack (struct gdbarch *gdbarch, gdbarch_return_value_on_stack_ftype *return_value_on_stack); -#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (RETURN_VALUE_ON_STACK) -#error "Non multi-arch definition of RETURN_VALUE_ON_STACK" -#endif -#if !defined (RETURN_VALUE_ON_STACK) -#define RETURN_VALUE_ON_STACK(type) (gdbarch_return_value_on_stack (current_gdbarch, type)) -#endif +/* The deprecated methods EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE and + USE_STRUCT_CONVENTION have all been folded into RETURN_VALUE. */ typedef void (gdbarch_extract_return_value_ftype) (struct type *type, struct regcache *regcache, void *valbuf); extern void gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, void *valbuf); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 666d449..7ee06de 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -562,11 +562,9 @@ F:2:DEPRECATED_STORE_STRUCT_RETURN:void:deprecated_store_struct_return:CORE_ADDR M:::enum return_value_convention:return_value:struct type *valtype, struct regcache *regcache, void *readbuf, const void *writebuf:valtype, regcache, readbuf, writebuf -# The deprecated methods RETURN_VALUE_ON_STACK, EXTRACT_RETURN_VALUE, -# STORE_RETURN_VALUE and USE_STRUCT_CONVENTION have all been folded -# into RETURN_VALUE. +# The deprecated methods EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE and +# USE_STRUCT_CONVENTION have all been folded into RETURN_VALUE. -f:2:RETURN_VALUE_ON_STACK:int:return_value_on_stack:struct type *type:type:::generic_return_value_on_stack_not::0 f:2:EXTRACT_RETURN_VALUE:void:extract_return_value:struct type *type, struct regcache *regcache, void *valbuf:type, regcache, valbuf:::legacy_extract_return_value::0 f:2:STORE_RETURN_VALUE:void:store_return_value:struct type *type, struct regcache *regcache, const void *valbuf:type, regcache, valbuf:::legacy_store_return_value::0 f:2:DEPRECATED_EXTRACT_RETURN_VALUE:void:deprecated_extract_return_value:struct type *type, char *regbuf, char *valbuf:type, regbuf, valbuf diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index 80480a6..43fce35 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -1332,31 +1332,24 @@ m68hc11_extract_return_value (struct type *type, struct regcache *regcache, } } -/* Should call_function allocate stack space for a struct return? */ -static int -m68hc11_use_struct_convention (int gcc_p, struct type *type) -{ - return (TYPE_CODE (type) == TYPE_CODE_STRUCT - || TYPE_CODE (type) == TYPE_CODE_UNION - || TYPE_LENGTH (type) > 4); -} - -static int -m68hc11_return_value_on_stack (struct type *type) +enum return_value_convention +m68hc11_return_value (struct gdbarch *gdbarch, struct type *valtype, + struct regcache *regcache, void *readbuf, + const void *writebuf) { - return TYPE_LENGTH (type) > 4; -} - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ -static CORE_ADDR -m68hc11_extract_struct_value_address (struct regcache *regcache) -{ - char buf[M68HC11_REG_SIZE]; - - regcache_cooked_read (regcache, HARD_D_REGNUM, buf); - return extract_unsigned_integer (buf, M68HC11_REG_SIZE); + if (TYPE_CODE (valtype) == TYPE_CODE_STRUCT + || TYPE_CODE (valtype) == TYPE_CODE_UNION + || TYPE_CODE (valtype) == TYPE_CODE_ARRAY + || TYPE_LENGTH (valtype) > 4) + return RETURN_VALUE_STRUCT_CONVENTION; + else + { + if (readbuf != NULL) + m68hc11_extract_return_value (valtype, regcache, readbuf); + if (writebuf != NULL) + m68hc11_store_return_value (valtype, regcache, writebuf); + return RETURN_VALUE_REGISTER_CONVENTION; + } } /* Test whether the ELF symbol corresponds to a function using rtc or @@ -1539,12 +1532,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info, set_gdbarch_push_dummy_call (gdbarch, m68hc11_push_dummy_call); - set_gdbarch_extract_return_value (gdbarch, m68hc11_extract_return_value); - set_gdbarch_return_value_on_stack (gdbarch, m68hc11_return_value_on_stack); - - set_gdbarch_store_return_value (gdbarch, m68hc11_store_return_value); - set_gdbarch_deprecated_extract_struct_value_address (gdbarch, m68hc11_extract_struct_value_address); - set_gdbarch_use_struct_convention (gdbarch, m68hc11_use_struct_convention); + set_gdbarch_return_value (gdbarch, m68hc11_return_value); set_gdbarch_skip_prologue (gdbarch, m68hc11_skip_prologue); set_gdbarch_inner_than (gdbarch, core_addr_lessthan); set_gdbarch_breakpoint_from_pc (gdbarch, m68hc11_breakpoint_from_pc); diff --git a/gdb/values.c b/gdb/values.c index 5ed10b5..98631af 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -1254,8 +1254,7 @@ using_struct_return (struct type *value_type, int gcc_p) "struct return" vs "register return" conventions. */ if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION - || code == TYPE_CODE_ARRAY - || RETURN_VALUE_ON_STACK (value_type)) + || code == TYPE_CODE_ARRAY) return USE_STRUCT_CONVENTION (gcc_p, value_type); else return 0; -- 2.7.4