From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26014 invoked by alias); 31 Aug 2008 18:15:35 -0000 Received: (qmail 25958 invoked by uid 22791); 31 Aug 2008 18:15:34 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.29.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 31 Aug 2008 18:14:51 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpeD1287346 for ; Sun, 31 Aug 2008 17:51:40 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7VHpdb13100772 for ; Sun, 31 Aug 2008 19:51:39 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m7VHpa4u020241 for ; Sun, 31 Aug 2008 19:51:36 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m7VHpanJ020238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:36 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (localhost.localdomain [127.0.0.1]) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpZ6Q003026 for ; Sun, 31 Aug 2008 19:51:35 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpZWd003025 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:35 +0200 Message-Id: <20080831175135.489007000@de.ibm.com> References: <20080831175045.128504000@de.ibm.com> User-Agent: quilt/0.46-1 Date: Sun, 31 Aug 2008 18:15:00 -0000 From: uweigand@de.ibm.com To: gdb-patches@sourceware.org Subject: [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines Content-Disposition: inline; filename=diff-type-infcall Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00709.txt.bz2 Hello, this patch removes builtin_type_ macros from infcall.c. The instances in value_arg_coerce are simply made per-arch by passing in the architecture from the (sole) call site. find_function_addr used to return a default "builtin_type_int" if the actual function return type could not be detected from debug data. However: most callers to not even look at the return type computed by find_function_addr, and the call site in eval.c implements its own unknown return type handling. Thus the patch moves the return type default setting to the sole remaining caller, call_function_by_hand. Bye, Ulrich ChangeLog: * infcall.c (value_arg_coerce): Add GDBARCH parameter. Use its associates types instead of builtin_type_ macros. (find_function_addr): Leave output VALUE_TYPE NULL if unknown. (call_function_by_hand): Use per-architecture "int" type as fall-back if find_function_addr returns NULL VALUE_TYPE. Update call to value_arg_coerce. Index: gdb-head/gdb/infcall.c =================================================================== --- gdb-head.orig/gdb/infcall.c +++ gdb-head/gdb/infcall.c @@ -100,9 +100,10 @@ Unwinding of stack if a signal is receiv its value as needed). */ static struct value * -value_arg_coerce (struct value *arg, struct type *param_type, - int is_prototyped, CORE_ADDR *sp) +value_arg_coerce (struct gdbarch *gdbarch, struct value *arg, + struct type *param_type, int is_prototyped, CORE_ADDR *sp) { + const struct builtin_type *builtin = builtin_type (gdbarch); struct type *arg_type = check_typedef (value_type (arg)); struct type *type = param_type ? check_typedef (param_type) : arg_type; @@ -141,22 +142,22 @@ value_arg_coerce (struct value *arg, str /* If we don't have a prototype, coerce to integer type if necessary. */ if (!is_prototyped) { - if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int)) - type = builtin_type_int; + if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int)) + type = builtin->builtin_int; } /* Currently all target ABIs require at least the width of an integer type for an argument. We may have to conditionalize the following type coercion for future targets. */ - if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int)) - type = builtin_type_int; + if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int)) + type = builtin->builtin_int; break; case TYPE_CODE_FLT: if (!is_prototyped && coerce_float_to_double_p) { - if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_double)) - type = builtin_type_double; - else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin_type_double)) - type = builtin_type_long_double; + if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_double)) + type = builtin->builtin_double; + else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin->builtin_double)) + type = builtin->builtin_long_double; } break; case TYPE_CODE_FUNC: @@ -199,7 +200,7 @@ find_function_addr (struct value *functi { struct type *ftype = check_typedef (value_type (function)); enum type_code code = TYPE_CODE (ftype); - struct type *value_type; + struct type *value_type = NULL; CORE_ADDR funaddr; /* If it's a member function, just look at the function @@ -223,8 +224,6 @@ find_function_addr (struct value *functi ¤t_target); value_type = TYPE_TARGET_TYPE (ftype); } - else - value_type = builtin_type_int; } else if (code == TYPE_CODE_INT) { @@ -251,8 +250,6 @@ find_function_addr (struct value *functi /* Handle integer used as address of a function. */ funaddr = (CORE_ADDR) value_as_long (function); } - - value_type = builtin_type_int; } else error (_("Invalid data type for function to be called.")); @@ -472,6 +469,9 @@ call_function_by_hand (struct value *fun funaddr = find_function_addr (function, &values_type); CHECK_TYPEDEF (values_type); + if (!values_type) + values_type = builtin_type (gdbarch)->builtin_int; + /* Are we returning a value using a structure return (passing a hidden argument pointing to storage) or a normal value return? There are two cases: language-mandated structure return and @@ -590,7 +590,8 @@ call_function_by_hand (struct value *fun else param_type = NULL; - args[i] = value_arg_coerce (args[i], param_type, prototyped, &sp); + args[i] = value_arg_coerce (gdbarch, args[i], + param_type, prototyped, &sp); if (param_type != NULL && language_pass_by_reference (param_type)) args[i] = value_addr (args[i]); -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com