From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17609 invoked by alias); 12 Jun 2004 19:28:33 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 17597 invoked from network); 12 Jun 2004 19:28:33 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 12 Jun 2004 19:28:33 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i5CJSXi7006718 for ; Sat, 12 Jun 2004 15:28:33 -0400 Received: from localhost.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i5CJST015535; Sat, 12 Jun 2004 15:28:30 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 7ED462B9D; Sat, 12 Jun 2004 15:28:16 -0400 (EDT) Message-ID: <40CB5950.9060902@gnu.org> Date: Sat, 12 Jun 2004 19:28:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com, Stephane Carrez Subject: [patch/rfc; rfa:m68hc11] Delete RETURN_VALUE_ON_STACK Content-Type: multipart/mixed; boundary="------------050003080102050201020300" X-SW-Source: 2004-06/txt/msg00292.txt.bz2 This is a multi-part message in MIME format. --------------050003080102050201020300 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 362 Hello, This converts the m68hc11 to the return_value architecture method allowing us to delete RETURN_VALUE_ON_STACK. In doing this I assumed that m68hc11 ABI didn't guarentee that a struct-return address wasn't preserved across a function call and, hence, deleted the EXTRACT_STRUCT_VALUE_ADDRESS logic. Stephane, does the m68hc11 change look ok? Andrew --------------050003080102050201020300 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 14692 2004-06-12 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-12 Andrew Cagney * gdbint.texinfo (Target Architecture Definition): Delete description of RETURN_VALUE_ON_STACK. Index: arch-utils.c =================================================================== RCS file: /cvs/src/src/gdb/arch-utils.c,v retrieving revision 1.118 diff -p -u -r1.118 arch-utils.c --- arch-utils.c 9 Jun 2004 21:26:48 -0000 1.118 +++ arch-utils.c 12 Jun 2004 19:21:58 -0000 @@ -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) { Index: arch-utils.h =================================================================== RCS file: /cvs/src/src/gdb/arch-utils.h,v retrieving revision 1.71 diff -p -u -r1.71 arch-utils.h --- arch-utils.h 9 Jun 2004 21:26:48 -0000 1.71 +++ arch-utils.h 12 Jun 2004 19:21:58 -0000 @@ -43,11 +43,6 @@ extern gdbarch_store_return_value_ftype 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; Index: gdbarch.c =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.c,v retrieving revision 1.294 diff -p -u -r1.294 gdbarch.c --- gdbarch.c 10 Jun 2004 13:22:05 -0000 1.294 +++ gdbarch.c 12 Jun 2004 19:21:59 -0000 @@ -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 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_ /* 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_gd 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->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) { Index: gdbarch.h =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.h,v retrieving revision 1.256 diff -p -u -r1.256 gdbarch.h --- gdbarch.h 10 Jun 2004 13:22:06 -0000 1.256 +++ gdbarch.h 12 Jun 2004 19:22:02 -0000 @@ -1155,19 +1155,8 @@ typedef enum return_value_convention (gd 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); Index: gdbarch.sh =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.sh,v retrieving revision 1.321 diff -p -u -r1.321 gdbarch.sh --- gdbarch.sh 10 Jun 2004 13:22:06 -0000 1.321 +++ gdbarch.sh 12 Jun 2004 19:22:02 -0000 @@ -562,11 +562,9 @@ F:2:DEPRECATED_STORE_STRUCT_RETURN:void: 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 Index: m68hc11-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/m68hc11-tdep.c,v retrieving revision 1.102 diff -p -u -r1.102 m68hc11-tdep.c --- m68hc11-tdep.c 7 Jun 2004 02:02:51 -0000 1.102 +++ m68hc11-tdep.c 12 Jun 2004 19:22:03 -0000 @@ -1332,31 +1332,24 @@ m68hc11_extract_return_value (struct typ } } -/* 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) -{ - 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); +enum return_value_convention +m68hc11_return_value (struct gdbarch *gdbarch, struct type *valtype, + struct regcache *regcache, void *readbuf, + const void *writebuf) +{ + 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_inf 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); Index: values.c =================================================================== RCS file: /cvs/src/src/gdb/values.c,v retrieving revision 1.66 diff -p -u -r1.66 values.c --- values.c 12 Jun 2004 18:02:30 -0000 1.66 +++ values.c 12 Jun 2004 19:22:05 -0000 @@ -1254,8 +1254,7 @@ using_struct_return (struct type *value_ "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; Index: doc/gdbint.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v retrieving revision 1.207 diff -p -u -r1.207 gdbint.texinfo --- doc/gdbint.texinfo 9 Jun 2004 13:33:54 -0000 1.207 +++ doc/gdbint.texinfo 12 Jun 2004 19:22:20 -0000 @@ -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 --------------050003080102050201020300--