From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31126 invoked by alias); 5 Jul 2005 03:43:20 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31116 invoked by uid 22791); 5 Jul 2005 03:43:17 -0000 Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 05 Jul 2005 03:43:17 +0000 Received: from farnswood.snap.net.nz (p93-tnt1.snap.net.nz [202.124.110.93]) by viper.snap.net.nz (Postfix) with ESMTP id 8FAF65E2387; Tue, 5 Jul 2005 15:43:13 +1200 (NZST) Received: by farnswood.snap.net.nz (Postfix, from userid 501) id 7FD0662A99; Tue, 5 Jul 2005 04:44:24 +0100 (BST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17098.535.651717.248101@farnswood.snap.net.nz> Date: Tue, 05 Jul 2005 03:43: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> X-SW-Source: 2005-07/txt/msg00057.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"? Unfortunately the index for "name" is used to compute the expression "exp" (which makes it a bit redundant): INTEGER ARRAY2(-1:4) Zero based gives: (gdb) -var-list-children var1 ^done,numchild="6",children=[child={name="var1.0",exp="0",numchild="0",type="integer"},child={name="var1.1",exp="1",numchild="0",type="integer"}... My patch currently gives: (gdb) -var-list-children var1 ^done,numchild="6",children=[child={name="var1.-1",exp="-1",numchild="0",type="integer"},child={name="var1.0",exp="0",numchild="0",type="integer"}... As (I think) you say, ideal would be: (gdb) -var-list-children var1 ^done,numchild="6",children=[child={name="var1.0",exp="-1",numchild="0",type="integer"},child={name="var1.1",exp="0",numchild="0",type="integer"}... In any case it would make sense to compute the offset outside the loop as shown below. Nick type = get_type (var); if (TYPE_CODE (type) == TYPE_CODE_ARRAY) j = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (var->type)); else j = 0; for (i = 0; i < var->num_children; i++) { /* Mark as the end in case we bail out */ *((*childlist) + i) = NULL; /* check if child exists, if not create */ name = name_of_child (var, i + j); child = child_exists (var, name); if (child == NULL) child = create_child (var, i + j, name); *((*childlist) + i) = child; }