From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3599 invoked by alias); 13 Dec 2010 20:03:22 -0000 Received: (qmail 3573 invoked by uid 22791); 13 Dec 2010 20:03:21 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate1.uk.ibm.com (HELO mtagate1.uk.ibm.com) (194.196.100.161) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Dec 2010 20:03:16 +0000 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id oBDK3BZG008580 for ; Mon, 13 Dec 2010 20:03:11 GMT Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oBDK3CqT3600604 for ; Mon, 13 Dec 2010 20:03:12 GMT Received: from d06av05.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oBDK3Aik024306 for ; Mon, 13 Dec 2010 13:03:10 -0700 Received: from leonard.localnet (ICON-9-167-230-107.megacenter.de.ibm.com [9.167.230.107]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oBDK39YO024291 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 13 Dec 2010 13:03:10 -0700 From: Ken Werner To: gdb-patches@sourceware.org Subject: Re: [patch] DW_AT_byte_size for array type entries Date: Mon, 13 Dec 2010 20:03:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-23-generic-pae; KDE/4.5.1; i686; ; ) Cc: Tom Tromey References: <201010191323.57251.ken@linux.vnet.ibm.com> <201011031522.50715.ken@linux.vnet.ibm.com> In-Reply-To: <201011031522.50715.ken@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_9vnBNsSIukuHayq" Message-Id: <201012132103.09320.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-12/txt/msg00199.txt.bz2 --Boundary-00=_9vnBNsSIukuHayq Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-length: 1999 On Wednesday, November 03, 2010 3:22:50 pm Ken Werner wrote: > On Tuesday, November 02, 2010 11:31:03 pm Tom Tromey wrote: > > >>>>> "Ken" == Ken Werner writes: > > Ken> Index: gdb/c-valprint.c > > Ken> =================================================================== > > Ken> RCS file: /cvs/src/src/gdb/c-valprint.c,v > > Ken> retrieving revision 1.74 > > Ken> diff -p -u -r1.74 c-valprint.c > > Ken> --- gdb/c-valprint.c 15 Oct 2010 18:54:12 -0000 1.74 > > Ken> +++ gdb/c-valprint.c 19 Oct 2010 12:15:30 -0000 > > Ken> @@ -171,8 +171,13 @@ c_val_print (struct type *type, const gd > > Ken> elttype = check_typedef (unresolved_elttype); > > Ken> if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH > > (unresolved_elttype) > > > > > 0) Ken> { > > > > Ken> + LONGEST low_bound, high_bound; > > Ken> + > > Ken> + if (!get_array_bounds(type, &low_bound, &high_bound)) > > > > Missing space before open paren. > > Fixed. > > > Ken> + error (_("Could not determine the array high bound")); > > Ken> + > > Ken> eltlen = TYPE_LENGTH (elttype); > > Ken> - len = TYPE_LENGTH (type) / eltlen; > > Ken> + len = high_bound - low_bound + 1; > > > > I guess it is ok to use 'eltlen' elsewhere in the function because it is > > only the array's overall size which is "weird" -- the element size is > > still correct. (Since we don't implement the DWARF stride stuff...) > > Yes, that is also my understanding. > > > The patch is ok with the above nit fixed. > > Thanks. I've checked in the version below: > http://sourceware.org/ml/gdb-cvs/2010-11/msg00014.html Hi, The attached patch changes the value_one(), value_complement() and value_neg() functions to use get_array_bounds to compute the number of array elements instead of dividing the length of the array by the length of the element types. It seems that I overlooked these in the first place. Tested on i686-*-linux-gnu with no regressions. Ok to apply? Regards Ken --Boundary-00=_9vnBNsSIukuHayq Content-Type: text/x-patch; charset="UTF-8"; name="arraybounds.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="arraybounds.patch" Content-length: 2724 2010-12-13 Ken Werner * valops.c (value_one): Use get_array_bounds to compute the number of array elements instead of dividing the length of the array by the length of the element types. * valarith.c (value_complement, value_neg): Likewise. Index: gdb/valarith.c =================================================================== RCS file: /cvs/src/src/gdb/valarith.c,v retrieving revision 1.91 diff -u -r1.91 valarith.c --- gdb/valarith.c 29 Nov 2010 21:18:16 -0000 1.91 +++ gdb/valarith.c 13 Dec 2010 19:43:52 -0000 @@ -1766,9 +1766,13 @@ { struct value *tmp, *val = allocate_value (type); struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type)); - int i, n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; - for (i = 0; i < n; i++) + if (!get_array_bounds (type, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); + + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_neg (value_subscript (arg1, i)); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), @@ -1798,10 +1802,14 @@ { struct value *tmp; struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type)); - int i, n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; + + if (!get_array_bounds (type, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); val = allocate_value (type); - for (i = 0; i < n; i++) + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_complement (value_subscript (arg1, i)); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.259 diff -u -r1.259 valops.c --- gdb/valops.c 1 Dec 2010 16:49:41 -0000 1.259 +++ gdb/valops.c 13 Dec 2010 19:43:52 -0000 @@ -877,11 +877,15 @@ else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1)) { struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type1)); - int i, n = TYPE_LENGTH (type1) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; struct value *tmp; + if (!get_array_bounds (type1, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); + val = allocate_value (type); - for (i = 0; i < n; i++) + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_one (eltype, lv); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), --Boundary-00=_9vnBNsSIukuHayq--