From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32277 invoked by alias); 22 Oct 2002 03:06:41 -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 32268 invoked from network); 22 Oct 2002 03:06:40 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 22 Oct 2002 03:06:40 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id g9M2jOw03676 for ; Mon, 21 Oct 2002 22:45:24 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g9M36df09751; Mon, 21 Oct 2002 23:06:39 -0400 Received: from localhost.redhat.com (IDENT:EmM72RfXaoMtFfaavTwy8j5BKDH+WAD1@tooth.toronto.redhat.com [172.16.14.29]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g9M36cw29191; Mon, 21 Oct 2002 23:06:38 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id C7F38FF79; Mon, 21 Oct 2002 23:03:54 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15796.49177.866732.495080@localhost.redhat.com> Date: Mon, 21 Oct 2002 20:06:00 -0000 To: "J. Johnston" Cc: gdb-patches@sources.redhat.com Subject: Re: Patch for gdb/mi 792 In-Reply-To: <3DA753C6.DD6CD4FD@redhat.com> References: <3DA753C6.DD6CD4FD@redhat.com> X-SW-Source: 2002-10/txt/msg00385.txt.bz2 J. Johnston writes: > The following is a proposed patch for gdb/mi 792. The problem occurs because > the code is trying to reference public, private, and protected via indexes. > The order of the fields in the type are in the order they are entered so the > index cannot be used computationally. The new code takes the index and > does a loop through the fields verifying that the field has the desired > access control. It decrements the index until the desired indexed value > with the specified access is found. > > gdb/ChangeLog: > > 2002-10-11 Jeff Johnston > > * varobj.c (cplus_name_of_child): Change code to handle the fact that > fields are not necessarily contiguous with regards to their access control. > This is a fix for PR gdb/792. > > May this code be committed? > > -- Jeff J.--- varobj.0.c Fri Oct 11 15:46:03 2002 > +++ varobj.c Fri Oct 11 18:28:06 2002 > @@ -2195,23 +2195,49 @@ > > if (CPLUS_FAKE_CHILD (parent)) > { > - int i; > + int i = index; > > /* Skip over vptr, if it exists. */ > if (TYPE_VPTR_BASETYPE (type) == type > && index >= TYPE_VPTR_FIELDNO (type)) > index++; > > - /* FIXME: This assumes that type orders > - inherited, public, private, protected */ > - i = index + TYPE_N_BASECLASSES (type); > - if (STREQ (parent->name, "private") > - || STREQ (parent->name, "protected")) > - i += children[v_public]; > - if (STREQ (parent->name, "protected")) > - i += children[v_private]; > + index = TYPE_N_BASECLASSES (type); > + if (STREQ (parent->name, "private")) Argh!! STREQ! Run away! We are trying to kill STREQ from gdb, you should just use strcmp(). [BTW, you know about the ARI? very useful, http://sources.redhat.com/gdb/ari/] > + { > + while (i >= 0) > + { > + if (TYPE_FIELD_PRIVATE (type, index)) > + --i; > + ++index; > + } > + --index; > + } > + How are the fields organized within the structure? I am a bit confused by the decreasing 'i'. Elena else if (STREQ (parent->name, "protected")) > + { > + while (i >= 0) > + { > + if (TYPE_FIELD_PROTECTED (type, index)) > + --i; > + ++index; > + } > + --index; > + } > + else if (STREQ (parent->name, "public")) > + { > + while (i >= 0) > + { > + if (!TYPE_FIELD_PRIVATE (type, index) && > + !TYPE_FIELD_PROTECTED (type, index)) > + --i; > + ++index; > + } > + --index; > + } > + else > + index += i; > > - name = TYPE_FIELD_NAME (type, i); > + name = TYPE_FIELD_NAME (type, index); > } > else if (index < TYPE_N_BASECLASSES (type)) > name = TYPE_FIELD_NAME (type, index);