From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 419 invoked by alias); 10 Jul 2010 17:05:23 -0000 Received: (qmail 408 invoked by uid 22791); 10 Jul 2010 17:05:22 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate3.uk.ibm.com (HELO mtagate3.uk.ibm.com) (194.196.100.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 10 Jul 2010 17:05:17 +0000 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o6AH5Erf028665 for ; Sat, 10 Jul 2010 17:05:14 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o6AH5EBe1581148 for ; Sat, 10 Jul 2010 18:05:14 +0100 Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o6AH5BNI008247 for ; Sat, 10 Jul 2010 18:05:14 +0100 Received: from leonard.localnet (ICON-9-164-180-158.megacenter.de.ibm.com [9.164.180.158]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o6AH58MK007773 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 10 Jul 2010 18:05:11 +0100 From: Ken Werner To: Daniel Jacobowitz Subject: Re: [patch] Small fix for assigning values to vectors Date: Sat, 10 Jul 2010 17:05:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.32-23-generic-pae; KDE/4.4.2; i686; ; ) References: <201007091312.o69DC1TX013390@d12av02.megacenter.de.ibm.com> <201007101503.54109.ken@linux.vnet.ibm.com> <20100710153908.GE8410@caradoc.them.org> In-Reply-To: <20100710153908.GE8410@caradoc.them.org> Cc: Ulrich Weigand , gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_DhKOMwO6A4z/6g3" Message-Id: <201007101905.07082.ken@linux.vnet.ibm.com> X-IsSubscribed: yes 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: 2010-07/txt/msg00197.txt.bz2 --Boundary-00=_DhKOMwO6A4z/6g3 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-length: 918 On Saturday, July 10, 2010 05:39:09 pm Daniel Jacobowitz wrote: > On Sat, Jul 10, 2010 at 03:03:53PM +0200, Ken Werner wrote: > > But while we are at it. Are there any objections on copying the contents > > to the destination instead of creating a pointer? > > I think we're going a bit too far now, and maybe we need to figure out > what the semantics of internalvars are supposed to be... > > With this, IIUC, "set $internalvar = program_array" is going to read > the whole array. Previously, it would decay to a pointer as in C. I agree. As I don't have a strong opinion either way on this particular case I'd leave that decision to more experienced GDB developers. Here is the patch I intended to post where only the call to value_coerce_to_target is omitted and the value_must_coerce_to_target routine returns zero in case of a vector. Tested on powerpc64-*-linux-gnu with no regressions. Regards. -ken --Boundary-00=_DhKOMwO6A4z/6g3 Content-Type: text/x-patch; charset="UTF-8"; name="vec_lval.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vec_lval.patch" Content-length: 2538 Changelog: 2010-07-09 Ken Werner * valops.c (value_assign): Do not call to value_coerce_to_target. (value_must_coerce_to_target): Return 0 in case of TYPE_VECTOR. testsuite/ChangeLog: 2010-07-09 Ken Werner * gdb.arch/altivec-abi.exp: New tests. Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.248 diff -p -u -r1.248 valops.c --- gdb/valops.c 28 Jun 2010 20:35:52 -0000 1.248 +++ gdb/valops.c 10 Jul 2010 10:16:36 -0000 @@ -1079,10 +1079,7 @@ value_assign (struct value *toval, struc type = value_type (toval); if (VALUE_LVAL (toval) != lval_internalvar) - { - toval = value_coerce_to_target (toval); - fromval = value_cast (type, fromval); - } + fromval = value_cast (type, fromval); else { /* Coerce arrays and functions to pointers, except for arrays @@ -1427,6 +1424,7 @@ value_must_coerce_to_target (struct valu switch (TYPE_CODE (valtype)) { case TYPE_CODE_ARRAY: + return TYPE_VECTOR (valtype) ? 0 : 1; case TYPE_CODE_STRING: return 1; default: Index: gdb/testsuite/gdb.arch/altivec-abi.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/altivec-abi.exp,v retrieving revision 1.19 diff -u -p -r1.19 altivec-abi.exp --- gdb/testsuite/gdb.arch/altivec-abi.exp 2 Jul 2010 18:02:19 -0000 1.19 +++ gdb/testsuite/gdb.arch/altivec-abi.exp 6 Jul 2010 12:47:01 -0000 @@ -98,6 +98,16 @@ proc altivec_abi_tests { extra_flags for gdb_test "p vec_func(vshort_d,vushort_d,vint_d,vuint_d,vchar_d,vuchar_d,vfloat_d,x_d,y_d,a_d,b_d,c_d,intv_on_stack_d)" \ ".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2)" + # Attempt to take address of the return value of vec_func. + gdb_test "p &vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \ + "Attempt to take address of value not located in memory." \ + "Attempt to take address of the return value of vec_func" + + # Attempt to assing a value to the return value of vec_func. + gdb_test "set variable vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack) = {0,1,2,3}" \ + "Left operand of assignment is not an lvalue." \ + "Attempt to assing a value to the return value of vec_func" + # Let's step into the function, to see if the args are printed correctly. gdb_test "step" \ $pattern1 \ --Boundary-00=_DhKOMwO6A4z/6g3--