From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4579 invoked by alias); 10 Aug 2010 19:06:29 -0000 Received: (qmail 4492 invoked by uid 22791); 10 Aug 2010 19:06:28 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Aug 2010 19:06:23 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7AJ6GRa003255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 10 Aug 2010 15:06:16 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7AJ6GYR018676; Tue, 10 Aug 2010 15:06:16 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o7AJ6FNw024360; Tue, 10 Aug 2010 15:06:15 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 0056C3781A0; Tue, 10 Aug 2010 13:06:14 -0600 (MDT) From: Tom Tromey To: Ken Werner Cc: gdb-patches@sourceware.org Subject: Re: [patch] GNU vector binop support References: <201008101124.22450.ken@linux.vnet.ibm.com> <201008101401.39991.ken@linux.vnet.ibm.com> Date: Tue, 10 Aug 2010 19:06:00 -0000 In-Reply-To: <201008101401.39991.ken@linux.vnet.ibm.com> (Ken Werner's message of "Tue, 10 Aug 2010 14:01:39 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-08/txt/msg00130.txt.bz2 >>>>> "Ken" == Ken Werner writes: Ken> This patch implements some binary operations for GNU vectors by Ken> traversing through the vector and calling scalar_binop (the former Ken> value_binop) element wise. Thanks for tackling this. This patch looks good to me. I noticed a few nits, and one slightly more serious problem. Ken> struct value * Ken> -value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) Ken> +scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) Should be static. Ken> +struct value * Ken> +vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) Likewise. Ken> + if (TYPE_CODE (eltype1) != TYPE_CODE (eltype2)) Ken> + error (_("The vectors have different types")); Ken> + Ken> + elsize = TYPE_LENGTH (eltype1); Extra space after the "=". Ken> + n = TYPE_LENGTH (type1) / elsize; Ken> + val = allocate_value (type1); Ken> + Ken> + mark = value_mark (); Ken> + for (i = 0; i < n; i++) Ken> + { Ken> + tmp = value_binop (value_subscript (val1, i), Ken> + value_subscript (val2, i), op); Ken> + memcpy (value_contents_writeable (val) + i * elsize, Ken> + value_contents_all (tmp), Ken> + elsize); It seems to me that this could use some more checking. The TYPE_CODEs could be equal but still give the wrong answer here. For example, 'int' and 'long' will have the same TYPE_CODE, but different sizes. Depending on the order of the addition, this could cause the memcpy to overflow the destination buffer. Ken> +set testfile "gnu_vector" Ken> +set srcfile ${testfile}.c Ken> +set binfile ${objdir}/${subdir}/${testfile} Ken> + Ken> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { Ken> + untested "Couldn't compile ${srcfile}" Ken> + return -1 Ken> +} Ken> + Ken> +if [get_compiler_info ${binfile}] { Ken> + return -1 Ken> +} Ken> + Ken> +gdb_exit Ken> +gdb_start Ken> +gdb_reinitialize_dir $srcdir/$subdir Ken> +gdb_load $binfile I think most of this (except the get_compiler_info bit) can be replaced with prepare_for_testing. Tom