From: "J. Johnston" <jjohnstn@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Patch for gdb/mi 792
Date: Fri, 11 Oct 2002 15:42:00 -0000 [thread overview]
Message-ID: <3DA753C6.DD6CD4FD@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 770 bytes --]
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 <jjohnstn@redhat.com>
* 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.
[-- Attachment #2: 792.patch --]
[-- Type: text/plain, Size: 1483 bytes --]
--- 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);
next reply other threads:[~2002-10-11 22:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-11 15:42 J. Johnston [this message]
2002-10-21 20:06 ` Elena Zannoni
2002-10-22 14:59 ` David Carlton
2002-10-22 15:11 ` Elena Zannoni
2002-10-22 15:19 ` David Carlton
2002-10-22 15:12 ` Andrew Cagney
2002-10-22 15:26 ` David Carlton
2002-10-22 18:05 ` Andrew Cagney
2002-10-22 22:57 ` Eli Zaretskii
2002-10-24 11:53 ` Andrew Cagney
2002-10-24 12:06 ` Eli Zaretskii
2002-10-24 14:29 ` Andrew Cagney
2002-11-07 13:31 J. Johnston
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DA753C6.DD6CD4FD@redhat.com \
--to=jjohnstn@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox