From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9197 invoked by alias); 13 Mar 2006 04:59:51 -0000 Received: (qmail 9188 invoked by uid 22791); 13 Mar 2006 04:59:50 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 13 Mar 2006 04:59:48 +0000 Received: from kahikatea.snap.net.nz (p202-124-115-79.snap.net.nz [202.124.115.79]) by viper.snap.net.nz (Postfix) with ESMTP id C9AFA748967; Mon, 13 Mar 2006 17:59:41 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 500) id 3E1C288E1; Mon, 13 Mar 2006 17:58:23 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17428.64494.595245.325277@kahikatea.snap.net.nz> Date: Mon, 13 Mar 2006 14:08:00 -0000 To: Daniel Jacobowitz Cc: Wu Zhou , gdb-patches@sources.redhat.com Subject: Re: PATCH: Start Fortran support for variable objects. In-Reply-To: <20050704034904.GA5802@nevyn.them.org> References: <17091.4780.953681.620094@farnswood.snap.net.nz> <20050630131809.GB8241@nevyn.them.org> <17092.28833.284587.118362@farnswood.snap.net.nz> <17092.51062.559020.560618@farnswood.snap.net.nz> <20050703161706.GA13289@nevyn.them.org> <17096.30621.21570.307217@farnswood.snap.net.nz> <20050703234725.GA28151@nevyn.them.org> <17096.37817.638887.840041@farnswood.snap.net.nz> <20050704034904.GA5802@nevyn.them.org> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00177.txt.bz2 > Also, I'm beginning to wonder if you're doing this in the right place. > Not that it matters a whole lot, but index is 0-based in every other > case, including for structs. Maybe the children of arr(4) should be > arr.0 == arr(1), arr.1 == arr(2), arr.2 == arr(3), arr.3 == arr(4). > Then you'd add the lower bound in c_value_of_child. Does that work? > Do you have an opinion on which is "more right"? Here's a new patch which does the same as my last one. So the children map as before i.e arr.1 == arr(1) because the index for expression "exp" is used to compute the "name". However this time I've made changes to c_name_of_child and c_value_of_child instead of varobj_list_children, so hopefully you'll find it more agreeable. If I don't change c_name_of_child, I get variable object names like arr.0 as you suggest. However, then I also get exp="0" which I use for the index of the watch expression. I think this is confusing. -- Nick http://www.inet.net.nz/~nickrob 2006-03-13 Nick Roberts * varobj.c (c_name_of_child, c_value_of_child): Allow non-zero offsets for languages like Fortran. *** varobj.c 13 Mar 2006 17:21:09 +1300 1.58 --- varobj.c 13 Mar 2006 16:31:26 +1300 *************** c_name_of_child (struct varobj *parent, *** 1833,1839 **** switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: ! name = xstrprintf ("%d", index); break; case TYPE_CODE_STRUCT: --- 1833,1839 ---- switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: ! name = xstrprintf ("%d", index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type))); break; case TYPE_CODE_STRUCT: *************** c_value_of_child (struct varobj *parent, *** 1931,1936 **** --- 1931,1937 ---- struct value *indval; struct type *type, *target; char *name; + int real_index; type = get_type (parent); target = get_target_type (type); *************** c_value_of_child (struct varobj *parent, *** 1943,1955 **** switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: #if 0 /* This breaks if the array lives in a (vector) register. */ ! value = value_slice (temp, index, 1); temp = value_coerce_array (value); gdb_value_ind (temp, &value); #else ! indval = value_from_longest (builtin_type_int, (LONGEST) index); gdb_value_subscript (temp, indval, &value); #endif break; --- 1944,1957 ---- switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: + real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)); #if 0 /* This breaks if the array lives in a (vector) register. */ ! value = value_slice (temp, real_index, 1); temp = value_coerce_array (value); gdb_value_ind (temp, &value); #else ! indval = value_from_longest (builtin_type_int, (LONGEST) real_index); gdb_value_subscript (temp, indval, &value); #endif break;