From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23232 invoked by alias); 31 Aug 2008 17:52:17 -0000 Received: (qmail 23173 invoked by uid 22791); 31 Aug 2008 17:52:14 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate2.de.ibm.com (HELO mtagate2.de.ibm.com) (195.212.17.162) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 31 Aug 2008 17:51:24 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id m7VHpLNG013384 for ; Sun, 31 Aug 2008 17:51:21 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 m7VHpLWe2326580 for ; Sun, 31 Aug 2008 19:51:21 +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 m7VHpLUU020029 for ; Sun, 31 Aug 2008 19:51:21 +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 m7VHpLTN020026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:21 +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 m7VHpKvD002417 for ; Sun, 31 Aug 2008 19:51:20 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpKTa002416 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:20 +0200 Message-Id: <20080831175120.645205000@de.ibm.com> References: <20080831175045.128504000@de.ibm.com> User-Agent: quilt/0.46-1 Date: Sun, 31 Aug 2008 17:52:00 -0000 From: uweigand@de.ibm.com To: gdb-patches@sourceware.org Subject: [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type Content-Disposition: inline; filename=diff-type-sizeof 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/msg00672.txt.bz2 Hello, evaluate_subexp_for_sizeof simply uses "builtin_type_int" as the type of its result. This should really be a platform-specific "size_t" type. The following patch at least uses the proper gdbarch; at some later point we can add a "size_t" as gdbarch property. Bye, Ulrich ChangeLog: * eval.c (evaluate_subexp_for_sizeof): Use builtin_int type of the expression architecture instead of builtin_type_int as the sizeof return type. Index: gdb-head/gdb/eval.c =================================================================== --- gdb-head.orig/gdb/eval.c +++ gdb-head/gdb/eval.c @@ -2335,6 +2335,8 @@ evaluate_subexp_with_coercion (struct ex static struct value * evaluate_subexp_for_sizeof (struct expression *exp, int *pos) { + /* FIXME: This should size_t. */ + struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; enum exp_opcode op; int pc; struct type *type; @@ -2358,24 +2360,22 @@ evaluate_subexp_for_sizeof (struct expre && TYPE_CODE (type) != TYPE_CODE_ARRAY) error (_("Attempt to take contents of a non-pointer value.")); type = check_typedef (TYPE_TARGET_TYPE (type)); - return value_from_longest (builtin_type_int, (LONGEST) - TYPE_LENGTH (type)); + return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); case UNOP_MEMVAL: (*pos) += 3; type = check_typedef (exp->elts[pc + 1].type); - return value_from_longest (builtin_type_int, - (LONGEST) TYPE_LENGTH (type)); + return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); case OP_VAR_VALUE: (*pos) += 4; type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol)); return - value_from_longest (builtin_type_int, (LONGEST) TYPE_LENGTH (type)); + value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); default: val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - return value_from_longest (builtin_type_int, + return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (value_type (val))); } } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com