From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14809 invoked by alias); 9 Sep 2008 21:18:41 -0000 Received: (qmail 14801 invoked by uid 22791); 9 Sep 2008 21:18:41 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 09 Sep 2008 21:18:06 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BD0AA2A9689; Tue, 9 Sep 2008 17:18:04 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Fc4JW+Xt1IOP; Tue, 9 Sep 2008 17:18:04 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 549142A9695; Tue, 9 Sep 2008 17:18:04 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 120D7E7ACD; Tue, 9 Sep 2008 23:18:02 +0200 (CEST) Date: Tue, 09 Sep 2008 21:18:00 -0000 From: Joel Brobecker To: Ulrich Weigand Cc: gdb-patches@sourceware.org Subject: Re: [rfc][00/37] Eliminate builtin_type_ macros Message-ID: <20080909211801.GH12222@adacore.com> References: <20080906031554.GP15267@adacore.com> <200809071642.m87GgJKT023918@d12av02.megacenter.de.ibm.com> <20080909180502.GF12222@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="TakKZr9L6Hm6aLOc" Content-Disposition: inline In-Reply-To: <20080909180502.GF12222@adacore.com> User-Agent: Mutt/1.4.2.2i 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-09/txt/msg00198.txt.bz2 --TakKZr9L6Hm6aLOc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1549 Hi Ulrich, > I still got a few regressions with our testsuite, which I will > investigate now. Can you hold the patch off a little while longer? OK, our testsuite found 2 issues: 1. Pointer arithmetics, in particular "PTR + PTR" or "PTR - PTR" expressions. For instance: (gdb) print b'address - a'address Argument to arithmetic operation not a number or boolean. It's worth mentioning that the problem was already present with pointer addition (adding two pointers doesn't necessarily make a lot of sense, but anyway...). The regression on the substraction is because we replaced the call to (rip'ed) value_sub by a call to value_binop, which doesn't support pointer differences. I think the semantics of pointer differences in Ada are different from C. It's just a number substraction. So I just added support for it directly at the caller site, thus calling value_binop only for values that it supports. Same for addition. 2. The second problem is just an oversight. You needed a variable to store the int builtin type, and unfortunately you reused a variable that was still in use. See ada-lang.c (evaluate_subexp) [OP_ATR_SIZE]. For now, I just used builtin_type_int32. Not ideal, but should be large enough for the vast majority of objects we actually have to deal with in real life. Two suggested patches attached... BTW: I tested on x86-linux (DWARF & STABS) as well as on x86_64-linux (DWARF only, obviously). -- Joel --TakKZr9L6Hm6aLOc Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="01-ptrdiff.diff" Content-length: 1252 diff -r ef6e8d4d28b4 -r c0202064b824 ada-lang.c --- a/ada-lang.c Tue Sep 09 10:27:10 2008 -0700 +++ b/ada-lang.c Tue Sep 09 12:31:38 2008 -0700 @@ -9909,6 +9909,10 @@ ada_evaluate_subexp (struct type *expect arg2 = evaluate_subexp_with_coercion (exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; + if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR) + return (value_from_longest + (value_type (arg1), + value_as_long (arg1) + value_as_long (arg2))); if ((ada_is_fixed_point_type (value_type (arg1)) || ada_is_fixed_point_type (value_type (arg2))) && value_type (arg1) != value_type (arg2)) @@ -9927,6 +9931,10 @@ ada_evaluate_subexp (struct type *expect arg2 = evaluate_subexp_with_coercion (exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; + if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR) + return (value_from_longest + (value_type (arg1), + value_as_long (arg1) - value_as_long (arg2))); if ((ada_is_fixed_point_type (value_type (arg1)) || ada_is_fixed_point_type (value_type (arg2))) && value_type (arg1) != value_type (arg2)) --TakKZr9L6Hm6aLOc Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="02-size_atr.diff" Content-length: 749 diff -r c0202064b824 -r 61698126d402 ChangeLog.joel diff -r c0202064b824 -r 61698126d402 ada-lang.c --- a/ada-lang.c Tue Sep 09 12:31:38 2008 -0700 +++ b/ada-lang.c Tue Sep 09 12:57:26 2008 -0700 @@ -10541,11 +10541,10 @@ ada_evaluate_subexp (struct type *expect if (noside == EVAL_SKIP) goto nosideret; - type = builtin_type (exp->gdbarch)->builtin_int; if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (type, not_lval); - else - return value_from_longest (type, + return value_zero (builtin_type_int32, not_lval); + else + return value_from_longest (builtin_type_int32, TARGET_CHAR_BIT * TYPE_LENGTH (type)); case OP_ATR_VAL: --TakKZr9L6Hm6aLOc--