From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12187 invoked by alias); 20 Oct 2003 23:27:21 -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 12144 invoked from network); 20 Oct 2003 23:27:19 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 20 Oct 2003 23:27:19 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id B12682B89 for ; Mon, 20 Oct 2003 19:27:18 -0400 (EDT) Message-ID: <3F946F56.2050409@redhat.com> Date: Mon, 20 Oct 2003 23:27:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfa:ppc] Convert PPC to "return_value" Content-Type: multipart/mixed; boundary="------------000902050803020708050005" X-SW-Source: 2003-10/txt/msg00626.txt.bz2 This is a multi-part message in MIME format. --------------000902050803020708050005 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 418 Hello, The attached switches the PPC architectures over to the new "return_value" gdbarch method. Due to a lack of coverage in the testsuite, this change doesn't actually improve the existing test results (ppc64 GNU/Linux and ppc32 NetBSD). Consequently, I wrote some new tests (will post in next few days) that beef up the testsuite and, with them, the results definitly improve! Anyway, ok to commit? Andrew --------------000902050803020708050005 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 15736 2003-10-19 Andrew Cagney * ppc-linux-tdep.c (ppc_linux_init_abi): When 32-bit GNU/Linux, set "return_value" instead of "use_struct_convention". (ppc_linux_use_struct_convention): Delete function. (ppc_linux_return_value): New function. * ppc-sysv-tdep.c (ppc_sysv_abi_return_value): New function. (ppc_sysv_abi_broken_return_value): New function. (do_ppc_sysv_return_value): Add "gdbarch" parameter. (ppc64_sysv_abi_push_dummy_call): Add "gdbarch" parameter, drop static. (ppc_sysv_abi_extract_return_value): Delete function. (ppc_sysv_abi_broken_extract_return_value): Delete function. (ppc_sysv_abi_store_return_value): Delete function. (ppc_sysv_abi_broken_store_return_value): Delete function. (ppc_sysv_abi_use_struct_convention): Delete function. (ppc64_sysv_abi_use_struct_convention): Delete function. (ppc64_sysv_abi_extract_return_value): Delete function. (ppc64_sysv_abi_store_return_value): Delete function. * ppcnbsd-tdep.c (ppcnbsd_return_value): New function. (ppcnbsd_init_abi): Set "return_value", instead of "use_struct_convention", "extract_return_value", and "store_return_value". (ppcnbsd_use_struct_convention): Delete function. * ppc-tdep.h (ppc64_sysv_abi_return_value): Declare. (ppc_sysv_abi_return_value): Declare. (ppc_sysv_abi_broken_return_value): Declare. (ppc_sysv_abi_use_struct_convention): Delete. (ppc_sysv_abi_store_return_value): Delete. (ppc_sysv_abi_extract_return_value): Delete. (ppc_sysv_abi_broken_store_return_value): Delete. (ppc_sysv_abi_broken_extract_return_value): Delete. (ppc64_sysv_abi_use_struct_convention): Delete. (ppc64_sysv_abi_extract_return_value): Delete. (ppc64_sysv_abi_store_return_value): Delete. * rs6000-tdep.c (rs6000_gdbarch_init): For 32-bit and 64-bit SYSV, set "return_value" instead of "extract_return_value", "store_return_value", and "use_struct_convention". Index: ppc-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v retrieving revision 1.42 diff -u -r1.42 ppc-linux-tdep.c --- ppc-linux-tdep.c 3 Oct 2003 20:50:56 -0000 1.42 +++ ppc-linux-tdep.c 20 Oct 2003 23:06:16 -0000 @@ -596,13 +596,17 @@ structures, no matter their size, are put in memory. Vectors, which were added later, do get returned in a register though. */ -static int -ppc_linux_use_struct_convention (int gcc_p, struct type *value_type) +static enum return_value_convention +ppc_linux_return_value (struct gdbarch *gdbarch, struct type *valtype, + struct regcache *regcache, const void *inval, void *outval) { - if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8) - && TYPE_VECTOR (value_type)) - return 0; - return 1; + if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT + || TYPE_CODE (valtype) == TYPE_CODE_UNION) + && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8) + && TYPE_VECTOR (valtype))) + return RETURN_VALUE_STRUCT_CONVENTION; + else + return ppc_sysv_abi_return_value (gdbarch, valtype, regcache, inval, outval); } /* Fetch (and possibly build) an appropriate link_map_offsets @@ -1042,7 +1046,7 @@ (well ignoring vectors that is). When this was corrected, it wasn't fixed for GNU/Linux native platform. Use the PowerOpen struct convention. */ - set_gdbarch_use_struct_convention (gdbarch, ppc_linux_use_struct_convention); + set_gdbarch_return_value (gdbarch, ppc_linux_return_value); /* Note: kevinb/2002-04-12: See note in rs6000_gdbarch_init regarding *_push_arguments(). The same remarks hold for the methods below. */ Index: ppc-sysv-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v retrieving revision 1.17 diff -u -r1.17 ppc-sysv-tdep.c --- ppc-sysv-tdep.c 20 Oct 2003 15:38:02 -0000 1.17 +++ ppc-sysv-tdep.c 20 Oct 2003 23:06:16 -0000 @@ -321,22 +321,22 @@ when returned in general-purpose registers. */ static enum return_value_convention -do_ppc_sysv_return_value (struct type *type, struct regcache *regcache, - const void *inval, void *outval, int broken_gcc) +do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *type, + struct regcache *regcache, const void *inval, + void *outval, int broken_gcc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); gdb_assert (tdep->wordsize == 4); if (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) <= 8 - && ppc_floating_point_unit_p (current_gdbarch)) + && ppc_floating_point_unit_p (gdbarch)) { if (outval) { /* Floats and doubles stored in "f1". Convert the value to the required type. */ char regval[MAX_REGISTER_SIZE]; - struct type *regtype = register_type (current_gdbarch, - FP0_REGNUM + 1); + struct type *regtype = register_type (gdbarch, FP0_REGNUM + 1); regcache_cooked_read (regcache, FP0_REGNUM + 1, regval); convert_typed_floating (regval, regtype, outval, type); } @@ -345,7 +345,7 @@ /* Floats and doubles stored in "f1". Convert the value to the register's "double" type. */ char regval[MAX_REGISTER_SIZE]; - struct type *regtype = register_type (current_gdbarch, FP0_REGNUM); + struct type *regtype = register_type (gdbarch, FP0_REGNUM); convert_typed_floating (inval, type, regval, regtype); regcache_cooked_write (regcache, FP0_REGNUM + 1, regval); } @@ -509,43 +509,19 @@ return RETURN_VALUE_STRUCT_CONVENTION; } -void -ppc_sysv_abi_extract_return_value (struct type *type, - struct regcache *regcache, void *valbuf) -{ - do_ppc_sysv_return_value (type, regcache, NULL, valbuf, 0); -} - -void -ppc_sysv_abi_broken_extract_return_value (struct type *type, - struct regcache *regcache, - void *valbuf) -{ - do_ppc_sysv_return_value (type, regcache, NULL, valbuf, 1); -} - -void -ppc_sysv_abi_store_return_value (struct type *type, struct regcache *regcache, - const void *valbuf) -{ - do_ppc_sysv_return_value (type, regcache, valbuf, NULL, 0); -} - -void -ppc_sysv_abi_broken_store_return_value (struct type *type, - struct regcache *regcache, - const void *valbuf) +enum return_value_convention +ppc_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *valtype, + struct regcache *regcache, const void *inval, void *outval) { - do_ppc_sysv_return_value (type, regcache, valbuf, NULL, 1); + return do_ppc_sysv_return_value (gdbarch, valtype, regcache, inval, outval, 0); } -/* Structures 8 bytes or less long are returned in the r3 & r4 - registers, according to the SYSV ABI. */ -int -ppc_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type) +enum return_value_convention +ppc_sysv_abi_broken_return_value (struct gdbarch *gdbarch, struct type *valtype, + struct regcache *regcache, const void *inval, + void *outval) { - return (do_ppc_sysv_return_value (value_type, NULL, NULL, NULL, 0) - == RETURN_VALUE_STRUCT_CONVENTION); + return do_ppc_sysv_return_value (gdbarch, valtype, regcache, inval, outval, 1); } /* Pass the arguments in either registers, or in the stack. Using the @@ -848,16 +824,17 @@ copy the buffer to the corresponding register return-value location location; when OUTVAL is non-NULL, fill the buffer from the corresponding register return-value location. */ -static enum return_value_convention -ppc64_sysv_abi_return_value (struct type *valtype, struct regcache *regcache, - const void *inval, void *outval) +enum return_value_convention +ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *valtype, + struct regcache *regcache, const void *inval, + void *outval) { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Floats and doubles in F1. */ if (TYPE_CODE (valtype) == TYPE_CODE_FLT && TYPE_LENGTH (valtype) <= 8) { char regval[MAX_REGISTER_SIZE]; - struct type *regtype = register_type (current_gdbarch, FP0_REGNUM); + struct type *regtype = register_type (gdbarch, FP0_REGNUM); if (inval != NULL) { convert_typed_floating (inval, valtype, regval, regtype); @@ -906,7 +883,7 @@ && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype)) == 1) { /* Small character arrays are returned, right justified, in r3. */ - int offset = (register_size (current_gdbarch, tdep->ppc_gp0_regnum + 3) + int offset = (register_size (gdbarch, tdep->ppc_gp0_regnum + 3) - TYPE_LENGTH (valtype)); if (inval != NULL) regcache_cooked_write_part (regcache, tdep->ppc_gp0_regnum + 3, @@ -987,29 +964,4 @@ return RETURN_VALUE_REGISTER_CONVENTION; } return RETURN_VALUE_STRUCT_CONVENTION; -} - -int -ppc64_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type) -{ - return (ppc64_sysv_abi_return_value (value_type, NULL, NULL, NULL) - == RETURN_VALUE_STRUCT_CONVENTION); -} - -void -ppc64_sysv_abi_extract_return_value (struct type *valtype, - struct regcache *regbuf, void *valbuf) -{ - if (ppc64_sysv_abi_return_value (valtype, regbuf, NULL, valbuf) - != RETURN_VALUE_REGISTER_CONVENTION) - error ("Function return value unknown"); -} - -void -ppc64_sysv_abi_store_return_value (struct type *valtype, - struct regcache *regbuf, - const void *valbuf) -{ - if (!ppc64_sysv_abi_return_value (valtype, regbuf, valbuf, NULL)) - error ("Function return value location unknown"); } Index: ppc-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/ppc-tdep.h,v retrieving revision 1.22 diff -u -r1.22 ppc-tdep.h --- ppc-tdep.h 10 Oct 2003 21:32:47 -0000 1.22 +++ ppc-tdep.h 20 Oct 2003 23:06:16 -0000 @@ -34,19 +34,16 @@ int ppc_linux_frameless_function_invocation (struct frame_info *); void ppc_linux_frame_init_saved_regs (struct frame_info *); CORE_ADDR ppc_linux_frame_chain (struct frame_info *); -int ppc_sysv_abi_use_struct_convention (int, struct type *); -void ppc_sysv_abi_store_return_value (struct type *type, - struct regcache *regcache, - const void *valbuf); -void ppc_sysv_abi_extract_return_value (struct type *type, - struct regcache *regcache, - void *valbuf); -void ppc_sysv_abi_broken_store_return_value (struct type *type, - struct regcache *regcache, - const void *valbuf); -void ppc_sysv_abi_broken_extract_return_value (struct type *type, - struct regcache *regcache, - void *valbuf); +enum return_value_convention ppc_sysv_abi_return_value (struct gdbarch *gdbarch, + struct type *valtype, + struct regcache *regcache, + const void *inval, + void *outval); +enum return_value_convention ppc_sysv_abi_broken_return_value (struct gdbarch *gdbarch, + struct type *valtype, + struct regcache *regcache, + const void *inval, + void *outval); CORE_ADDR ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, struct regcache *regcache, @@ -66,14 +63,11 @@ void ppc_linux_supply_gregset (char *buf); void ppc_linux_supply_fpregset (char *buf); -int ppc64_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type); -void ppc64_sysv_abi_extract_return_value (struct type *valtype, - struct regcache *regbuf, - void *valbuf); -void ppc64_sysv_abi_store_return_value (struct type *valtype, - struct regcache *regbuf, - const void *valbuf); - +enum return_value_convention ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, + struct type *valtype, + struct regcache *regcache, + const void *inval, + void *outval); /* From rs6000-tdep.c... */ CORE_ADDR rs6000_frame_saved_pc (struct frame_info *fi); Index: ppcnbsd-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v retrieving revision 1.9 diff -u -r1.9 ppcnbsd-tdep.c --- ppcnbsd-tdep.c 10 Oct 2003 21:32:47 -0000 1.9 +++ ppcnbsd-tdep.c 20 Oct 2003 23:06:16 -0000 @@ -208,17 +208,22 @@ convention but, 1.6 switched to the below broken convention. For the moment use the broken convention. Ulgh!. */ -static int -ppcnbsd_use_struct_convention (int gcc_p, struct type *value_type) -{ - if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8) - && TYPE_VECTOR (value_type)) - return 0; - - return !(TYPE_LENGTH (value_type) == 1 - || TYPE_LENGTH (value_type) == 2 - || TYPE_LENGTH (value_type) == 4 - || TYPE_LENGTH (value_type) == 8); +static enum return_value_convention +ppcnbsd_return_value (struct gdbarch *gdbarch, struct type *valtype, + struct regcache *regcache, const void *inval, void *outval) +{ + if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT + || TYPE_CODE (valtype) == TYPE_CODE_UNION) + && ! ((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8) + && TYPE_VECTOR (valtype)) + && !(TYPE_LENGTH (valtype) == 1 + || TYPE_LENGTH (valtype) == 2 + || TYPE_LENGTH (valtype) == 4 + || TYPE_LENGTH (valtype) == 8)) + return RETURN_VALUE_STRUCT_CONVENTION; + else + return ppc_sysv_abi_broken_return_value (gdbarch, valtype, regcache, + inval, outval); } static void @@ -228,9 +233,7 @@ set_gdbarch_pc_in_sigtramp (gdbarch, ppcnbsd_pc_in_sigtramp); /* For NetBSD, this is an on again, off again thing. Some systems do use the broken struct convention, and some don't. */ - set_gdbarch_use_struct_convention (gdbarch, ppcnbsd_use_struct_convention); - set_gdbarch_extract_return_value (gdbarch, ppc_sysv_abi_broken_extract_return_value); - set_gdbarch_store_return_value (gdbarch, ppc_sysv_abi_broken_store_return_value); + set_gdbarch_return_value (gdbarch, ppcnbsd_return_value); set_solib_svr4_fetch_link_map_offsets (gdbarch, nbsd_ilp32_solib_svr4_fetch_link_map_offsets); } Index: rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.169 diff -u -r1.169 rs6000-tdep.c --- rs6000-tdep.c 10 Oct 2003 21:32:47 -0000 1.169 +++ rs6000-tdep.c 20 Oct 2003 23:06:16 -0000 @@ -2748,15 +2748,9 @@ set_gdbarch_sp_regnum (gdbarch, 1); set_gdbarch_deprecated_fp_regnum (gdbarch, 1); if (sysv_abi && wordsize == 8) - { - set_gdbarch_extract_return_value (gdbarch, ppc64_sysv_abi_extract_return_value); - set_gdbarch_store_return_value (gdbarch, ppc64_sysv_abi_store_return_value); - } + set_gdbarch_return_value (gdbarch, ppc64_sysv_abi_return_value); else if (sysv_abi && wordsize == 4) - { - set_gdbarch_extract_return_value (gdbarch, ppc_sysv_abi_extract_return_value); - set_gdbarch_store_return_value (gdbarch, ppc_sysv_abi_store_return_value); - } + set_gdbarch_return_value (gdbarch, ppc_sysv_abi_return_value); else { set_gdbarch_deprecated_extract_return_value (gdbarch, rs6000_extract_return_value); @@ -2896,12 +2890,7 @@ /* Not sure on this. FIXMEmgo */ set_gdbarch_frame_args_skip (gdbarch, 8); - if (sysv_abi && wordsize == 4) - set_gdbarch_use_struct_convention (gdbarch, - ppc_sysv_abi_use_struct_convention); - else if (sysv_abi && wordsize == 8) - set_gdbarch_use_struct_convention (gdbarch, ppc64_sysv_abi_use_struct_convention); - else + if (!sysv_abi) set_gdbarch_use_struct_convention (gdbarch, rs6000_use_struct_convention); --------------000902050803020708050005--