From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23113 invoked by alias); 11 Oct 2002 22:42:17 -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 23100 invoked from network); 11 Oct 2002 22:42:15 -0000 Received: from unknown (HELO touchme.toronto.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 11 Oct 2002 22:42:15 -0000 Received: from redhat.com (toocool.toronto.redhat.com [172.16.14.72]) by touchme.toronto.redhat.com (Postfix) with ESMTP id EF13180039F for ; Fri, 11 Oct 2002 18:42:14 -0400 (EDT) Message-ID: <3DA753C6.DD6CD4FD@redhat.com> Date: Fri, 11 Oct 2002 15:42:00 -0000 From: "J. Johnston" Organization: Red Hat Inc. X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: Patch for gdb/mi 792 Content-Type: multipart/mixed; boundary="------------F76CDDB7A486C4D303437B06" X-SW-Source: 2002-10/txt/msg00241.txt.bz2 This is a multi-part message in MIME format. --------------F76CDDB7A486C4D303437B06 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 770 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. --------------F76CDDB7A486C4D303437B06 Content-Type: text/plain; charset=us-ascii; name="792.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="792.patch" Content-length: 1483 --- 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")) + { + while (i >= 0) + { + if (TYPE_FIELD_PRIVATE (type, index)) + --i; + ++index; + } + --index; + } + 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); --------------F76CDDB7A486C4D303437B06--