Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: revised changes for gdb/mi 792
@ 2002-10-15 14:21 J. Johnston
  2002-10-16  8:16 ` Fernando Nasser
  2002-10-22  8:46 ` Elena Zannoni
  0 siblings, 2 replies; 6+ messages in thread
From: J. Johnston @ 2002-10-15 14:21 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

Keith has pointed out some scenarios my original patch did not address and supplied
an alternate solution such that I have modified my patch.  This replaces the former 
patch that was posted.
 

gdb/ChangeLog:

2002-10-15  Jeff Johnston  <jjohnstn@redhat.com>
	    Keith Seitz  <keiths@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.

Ok to commit?

-- Jeff J.

[-- Attachment #2: 792.patch --]
[-- Type: text/plain, Size: 3751 bytes --]

--- varobj.0.c	Fri Oct 11 15:46:03 2002
+++ varobj.c	Tue Oct 15 17:00:14 2002
@@ -2176,7 +2176,6 @@
 {
   char *name;
   struct type *type;
-  int children[3];
 
   if (CPLUS_FAKE_CHILD (parent))
     {
@@ -2191,55 +2190,97 @@
     {
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
-      cplus_class_num_children (type, children);
-
       if (CPLUS_FAKE_CHILD (parent))
 	{
-	  int i;
-
-	  /* 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];
+	  /* The fields of the class type are ordered as they
+	     appear in the class.  We are given an index for a
+	     particular access control type ("public","protected",
+	     or "private").  We must skip over fields that don't
+	     have the access control we are looking for to properly
+	     find the indexed field. */
+	  int type_index = TYPE_N_BASECLASSES (type);
+	  if (STREQ (parent->name, "private"))
+	    {
+	      while (index >= 0)
+		{
+	  	  if (TYPE_VPTR_BASETYPE (type) == type
+	      	      && type_index == TYPE_VPTR_FIELDNO (type))
+		    ; /* ignore vptr */
+		  else if (TYPE_FIELD_PRIVATE (type, type_index))
+		    --index;
+		  ++type_index;
+		}
+	      --type_index;
+	    }
+	  else if (STREQ (parent->name, "protected"))
+	    {
+	      while (index >= 0)
+		{
+	  	  if (TYPE_VPTR_BASETYPE (type) == type
+	      	      && type_index == TYPE_VPTR_FIELDNO (type))
+		    ; /* ignore vptr */
+		  else if (TYPE_FIELD_PROTECTED (type, type_index))
+		    --index;
+		  ++type_index;
+		}
+	      --type_index;
+	    }
+	  else
+	    {
+	      while (index >= 0)
+		{
+	  	  if (TYPE_VPTR_BASETYPE (type) == type
+	      	      && type_index == TYPE_VPTR_FIELDNO (type))
+		    ; /* ignore vptr */
+		  else if (!TYPE_FIELD_PRIVATE (type, type_index) &&
+		      !TYPE_FIELD_PROTECTED (type, type_index))
+		    --index;
+		  ++type_index;
+		}
+	      --type_index;
+	    }
 
-	  name = TYPE_FIELD_NAME (type, i);
+	  name = TYPE_FIELD_NAME (type, type_index);
 	}
       else if (index < TYPE_N_BASECLASSES (type))
+	/* We are looking up the name of a base class */
 	name = TYPE_FIELD_NAME (type, index);
       else
 	{
+	  int children[3];
+	  cplus_class_num_children(type, children);
+
 	  /* Everything beyond the baseclasses can
-	     only be "public", "private", or "protected" */
+	     only be "public", "private", or "protected"
+
+	     The special "fake" children are always output by varobj in
+	     this order. So if INDEX == 2, it MUST be "protected". */
 	  index -= TYPE_N_BASECLASSES (type);
 	  switch (index)
 	    {
 	    case 0:
-	      if (children[v_public] != 0)
-		{
-		  name = "public";
-		  break;
-		}
+	      if (children[v_public] > 0)
+	 	name = "public";
+	      else if (children[v_private] > 0)
+	 	name = "private";
+	      else 
+	 	name = "protected";
+	      break;
 	    case 1:
-	      if (children[v_private] != 0)
+	      if (children[v_public] > 0)
 		{
-		  name = "private";
-		  break;
+		  if (children[v_private] > 0)
+		    name = "private";
+		  else
+		    name = "protected";
 		}
+	      else if (children[v_private] > 0)
+	 	name = "protected";
+	      break;
 	    case 2:
-	      if (children[v_protected] != 0)
-		{
-		  name = "protected";
-		  break;
-		}
+	      /* Must be protected */
+	      name = "protected";
+	      break;
 	    default:
 	      /* error! */
 	      break;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: revised changes for gdb/mi 792
  2002-10-15 14:21 RFA: revised changes for gdb/mi 792 J. Johnston
@ 2002-10-16  8:16 ` Fernando Nasser
  2002-10-16  8:39   ` Keith Seitz
  2002-10-22  8:46 ` Elena Zannoni
  1 sibling, 1 reply; 6+ messages in thread
From: Fernando Nasser @ 2002-10-16  8:16 UTC (permalink / raw)
  To: J. Johnston; +Cc: gdb-patches

Have you guys tested the effect of this on Insight?

_If_ Insight variable and watch windows are still working after this change, 
then please check it in.

And thanks for the improvements.

Fernando


J. Johnston wrote:> Keith has pointed out some scenarios my original patch did 
not address and supplied
> an alternate solution such that I have modified my patch.  This replaces the former 
> patch that was posted.
>  
> 
> gdb/ChangeLog:
> 
> 2002-10-15  Jeff Johnston  <jjohnstn@redhat.com>
> 	    Keith Seitz  <keiths@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.
> 
> Ok to commit?
> 
> -- Jeff J.
> 
> 
> ------------------------------------------------------------------------
> 
> --- varobj.0.c	Fri Oct 11 15:46:03 2002
> +++ varobj.c	Tue Oct 15 17:00:14 2002
> @@ -2176,7 +2176,6 @@
>  {
>    char *name;
>    struct type *type;
> -  int children[3];
>  
>    if (CPLUS_FAKE_CHILD (parent))
>      {
> @@ -2191,55 +2190,97 @@
>      {
>      case TYPE_CODE_STRUCT:
>      case TYPE_CODE_UNION:
> -      cplus_class_num_children (type, children);
> -
>        if (CPLUS_FAKE_CHILD (parent))
>  	{
> -	  int i;
> -
> -	  /* 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];
> +	  /* The fields of the class type are ordered as they
> +	     appear in the class.  We are given an index for a
> +	     particular access control type ("public","protected",
> +	     or "private").  We must skip over fields that don't
> +	     have the access control we are looking for to properly
> +	     find the indexed field. */
> +	  int type_index = TYPE_N_BASECLASSES (type);
> +	  if (STREQ (parent->name, "private"))
> +	    {
> +	      while (index >= 0)
> +		{
> +	  	  if (TYPE_VPTR_BASETYPE (type) == type
> +	      	      && type_index == TYPE_VPTR_FIELDNO (type))
> +		    ; /* ignore vptr */
> +		  else if (TYPE_FIELD_PRIVATE (type, type_index))
> +		    --index;
> +		  ++type_index;
> +		}
> +	      --type_index;
> +	    }
> +	  else if (STREQ (parent->name, "protected"))
> +	    {
> +	      while (index >= 0)
> +		{
> +	  	  if (TYPE_VPTR_BASETYPE (type) == type
> +	      	      && type_index == TYPE_VPTR_FIELDNO (type))
> +		    ; /* ignore vptr */
> +		  else if (TYPE_FIELD_PROTECTED (type, type_index))
> +		    --index;
> +		  ++type_index;
> +		}
> +	      --type_index;
> +	    }
> +	  else
> +	    {
> +	      while (index >= 0)
> +		{
> +	  	  if (TYPE_VPTR_BASETYPE (type) == type
> +	      	      && type_index == TYPE_VPTR_FIELDNO (type))
> +		    ; /* ignore vptr */
> +		  else if (!TYPE_FIELD_PRIVATE (type, type_index) &&
> +		      !TYPE_FIELD_PROTECTED (type, type_index))
> +		    --index;
> +		  ++type_index;
> +		}
> +	      --type_index;
> +	    }
>  
> -	  name = TYPE_FIELD_NAME (type, i);
> +	  name = TYPE_FIELD_NAME (type, type_index);
>  	}
>        else if (index < TYPE_N_BASECLASSES (type))
> +	/* We are looking up the name of a base class */
>  	name = TYPE_FIELD_NAME (type, index);
>        else
>  	{
> +	  int children[3];
> +	  cplus_class_num_children(type, children);
> +
>  	  /* Everything beyond the baseclasses can
> -	     only be "public", "private", or "protected" */
> +	     only be "public", "private", or "protected"
> +
> +	     The special "fake" children are always output by varobj in
> +	     this order. So if INDEX == 2, it MUST be "protected". */
>  	  index -= TYPE_N_BASECLASSES (type);
>  	  switch (index)
>  	    {
>  	    case 0:
> -	      if (children[v_public] != 0)
> -		{
> -		  name = "public";
> -		  break;
> -		}
> +	      if (children[v_public] > 0)
> +	 	name = "public";
> +	      else if (children[v_private] > 0)
> +	 	name = "private";
> +	      else 
> +	 	name = "protected";
> +	      break;
>  	    case 1:
> -	      if (children[v_private] != 0)
> +	      if (children[v_public] > 0)
>  		{
> -		  name = "private";
> -		  break;
> +		  if (children[v_private] > 0)
> +		    name = "private";
> +		  else
> +		    name = "protected";
>  		}
> +	      else if (children[v_private] > 0)
> +	 	name = "protected";
> +	      break;
>  	    case 2:
> -	      if (children[v_protected] != 0)
> -		{
> -		  name = "protected";
> -		  break;
> -		}
> +	      /* Must be protected */
> +	      name = "protected";
> +	      break;
>  	    default:
>  	      /* error! */
>  	      break;



-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: revised changes for gdb/mi 792
  2002-10-16  8:16 ` Fernando Nasser
@ 2002-10-16  8:39   ` Keith Seitz
  0 siblings, 0 replies; 6+ messages in thread
From: Keith Seitz @ 2002-10-16  8:39 UTC (permalink / raw)
  To: Fernando Nasser; +Cc: J. Johnston, gdb-patches

On Wed, 16 Oct 2002, Fernando Nasser wrote:

> Have you guys tested the effect of this on Insight?

I've checked it, and I've written a testsuite for it, but it is all 
hinging on my varobj-support library, which I sent out an RFC on last 
week.

[Turns out Jeff and I were both working on the bug at the same time.]

Keith



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: revised changes for gdb/mi 792
  2002-10-15 14:21 RFA: revised changes for gdb/mi 792 J. Johnston
  2002-10-16  8:16 ` Fernando Nasser
@ 2002-10-22  8:46 ` Elena Zannoni
  2002-10-22  9:07   ` J. Johnston
  1 sibling, 1 reply; 6+ messages in thread
From: Elena Zannoni @ 2002-10-22  8:46 UTC (permalink / raw)
  To: J. Johnston; +Cc: gdb-patches

J. Johnston writes:
 > Keith has pointed out some scenarios my original patch did not address and supplied
 > an alternate solution such that I have modified my patch.  This replaces the former 
 > patch that was posted.
 >  
 > 

Has this been committed?
In any event, could the STREQ that you touched be replaced by strcmp()?

Thanks
Elena




 > gdb/ChangeLog:
 > 
 > 2002-10-15  Jeff Johnston  <jjohnstn@redhat.com>
 > 	    Keith Seitz  <keiths@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.
 > 
 > Ok to commit?
 > 
 > -- Jeff J.--- varobj.0.c	Fri Oct 11 15:46:03 2002
 > +++ varobj.c	Tue Oct 15 17:00:14 2002
 > @@ -2176,7 +2176,6 @@
 >  {
 >    char *name;
 >    struct type *type;
 > -  int children[3];
 >  
 >    if (CPLUS_FAKE_CHILD (parent))
 >      {
 > @@ -2191,55 +2190,97 @@
 >      {
 >      case TYPE_CODE_STRUCT:
 >      case TYPE_CODE_UNION:
 > -      cplus_class_num_children (type, children);
 > -
 >        if (CPLUS_FAKE_CHILD (parent))
 >  	{
 > -	  int i;
 > -
 > -	  /* 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];
 > +	  /* The fields of the class type are ordered as they
 > +	     appear in the class.  We are given an index for a
 > +	     particular access control type ("public","protected",
 > +	     or "private").  We must skip over fields that don't
 > +	     have the access control we are looking for to properly
 > +	     find the indexed field. */
 > +	  int type_index = TYPE_N_BASECLASSES (type);
 > +	  if (STREQ (parent->name, "private"))
 > +	    {
 > +	      while (index >= 0)
 > +		{
 > +	  	  if (TYPE_VPTR_BASETYPE (type) == type
 > +	      	      && type_index == TYPE_VPTR_FIELDNO (type))
 > +		    ; /* ignore vptr */
 > +		  else if (TYPE_FIELD_PRIVATE (type, type_index))
 > +		    --index;
 > +		  ++type_index;
 > +		}
 > +	      --type_index;
 > +	    }
 > +	  else if (STREQ (parent->name, "protected"))
 > +	    {
 > +	      while (index >= 0)
 > +		{
 > +	  	  if (TYPE_VPTR_BASETYPE (type) == type
 > +	      	      && type_index == TYPE_VPTR_FIELDNO (type))
 > +		    ; /* ignore vptr */
 > +		  else if (TYPE_FIELD_PROTECTED (type, type_index))
 > +		    --index;
 > +		  ++type_index;
 > +		}
 > +	      --type_index;
 > +	    }
 > +	  else
 > +	    {
 > +	      while (index >= 0)
 > +		{
 > +	  	  if (TYPE_VPTR_BASETYPE (type) == type
 > +	      	      && type_index == TYPE_VPTR_FIELDNO (type))
 > +		    ; /* ignore vptr */
 > +		  else if (!TYPE_FIELD_PRIVATE (type, type_index) &&
 > +		      !TYPE_FIELD_PROTECTED (type, type_index))
 > +		    --index;
 > +		  ++type_index;
 > +		}
 > +	      --type_index;
 > +	    }
 >  
 > -	  name = TYPE_FIELD_NAME (type, i);
 > +	  name = TYPE_FIELD_NAME (type, type_index);
 >  	}
 >        else if (index < TYPE_N_BASECLASSES (type))
 > +	/* We are looking up the name of a base class */
 >  	name = TYPE_FIELD_NAME (type, index);
 >        else
 >  	{
 > +	  int children[3];
 > +	  cplus_class_num_children(type, children);
 > +
 >  	  /* Everything beyond the baseclasses can
 > -	     only be "public", "private", or "protected" */
 > +	     only be "public", "private", or "protected"
 > +
 > +	     The special "fake" children are always output by varobj in
 > +	     this order. So if INDEX == 2, it MUST be "protected". */
 >  	  index -= TYPE_N_BASECLASSES (type);
 >  	  switch (index)
 >  	    {
 >  	    case 0:
 > -	      if (children[v_public] != 0)
 > -		{
 > -		  name = "public";
 > -		  break;
 > -		}
 > +	      if (children[v_public] > 0)
 > +	 	name = "public";
 > +	      else if (children[v_private] > 0)
 > +	 	name = "private";
 > +	      else 
 > +	 	name = "protected";
 > +	      break;
 >  	    case 1:
 > -	      if (children[v_private] != 0)
 > +	      if (children[v_public] > 0)
 >  		{
 > -		  name = "private";
 > -		  break;
 > +		  if (children[v_private] > 0)
 > +		    name = "private";
 > +		  else
 > +		    name = "protected";
 >  		}
 > +	      else if (children[v_private] > 0)
 > +	 	name = "protected";
 > +	      break;
 >  	    case 2:
 > -	      if (children[v_protected] != 0)
 > -		{
 > -		  name = "protected";
 > -		  break;
 > -		}
 > +	      /* Must be protected */
 > +	      name = "protected";
 > +	      break;
 >  	    default:
 >  	      /* error! */
 >  	      break;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: revised changes for gdb/mi 792
  2002-10-22  8:46 ` Elena Zannoni
@ 2002-10-22  9:07   ` J. Johnston
  2002-10-22  9:10     ` Elena Zannoni
  0 siblings, 1 reply; 6+ messages in thread
From: J. Johnston @ 2002-10-22  9:07 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Elena Zannoni wrote:
> 
> J. Johnston writes:
>  > Keith has pointed out some scenarios my original patch did not address and supplied
>  > an alternate solution such that I have modified my patch.  This replaces the former
>  > patch that was posted.
>  >
>  >
> 
> Has this been committed?
> In any event, could the STREQ that you touched be replaced by strcmp()?
> 

I have not applied any patches unless they were approved.  This patch has
not been committed.  Yes, I can change the STREQs in the new code to be
strcmp.

-- Jeff J.

> Thanks
> Elena
> 
>  > gdb/ChangeLog:
>  >
>  > 2002-10-15  Jeff Johnston  <jjohnstn@redhat.com>
>  >          Keith Seitz  <keiths@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.
>  >
>  > Ok to commit?
>  >
>  > -- Jeff J.--- varobj.0.c     Fri Oct 11 15:46:03 2002
>  > +++ varobj.c Tue Oct 15 17:00:14 2002
>  > @@ -2176,7 +2176,6 @@
>  >  {
>  >    char *name;
>  >    struct type *type;
>  > -  int children[3];
>  >
>  >    if (CPLUS_FAKE_CHILD (parent))
>  >      {
>  > @@ -2191,55 +2190,97 @@
>  >      {
>  >      case TYPE_CODE_STRUCT:
>  >      case TYPE_CODE_UNION:
>  > -      cplus_class_num_children (type, children);
>  > -
>  >        if (CPLUS_FAKE_CHILD (parent))
>  >      {
>  > -      int i;
>  > -
>  > -      /* 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];
>  > +      /* The fields of the class type are ordered as they
>  > +         appear in the class.  We are given an index for a
>  > +         particular access control type ("public","protected",
>  > +         or "private").  We must skip over fields that don't
>  > +         have the access control we are looking for to properly
>  > +         find the indexed field. */
>  > +      int type_index = TYPE_N_BASECLASSES (type);
>  > +      if (STREQ (parent->name, "private"))
>  > +        {
>  > +          while (index >= 0)
>  > +            {
>  > +              if (TYPE_VPTR_BASETYPE (type) == type
>  > +                  && type_index == TYPE_VPTR_FIELDNO (type))
>  > +                ; /* ignore vptr */
>  > +              else if (TYPE_FIELD_PRIVATE (type, type_index))
>  > +                --index;
>  > +              ++type_index;
>  > +            }
>  > +          --type_index;
>  > +        }
>  > +      else if (STREQ (parent->name, "protected"))
>  > +        {
>  > +          while (index >= 0)
>  > +            {
>  > +              if (TYPE_VPTR_BASETYPE (type) == type
>  > +                  && type_index == TYPE_VPTR_FIELDNO (type))
>  > +                ; /* ignore vptr */
>  > +              else if (TYPE_FIELD_PROTECTED (type, type_index))
>  > +                --index;
>  > +              ++type_index;
>  > +            }
>  > +          --type_index;
>  > +        }
>  > +      else
>  > +        {
>  > +          while (index >= 0)
>  > +            {
>  > +              if (TYPE_VPTR_BASETYPE (type) == type
>  > +                  && type_index == TYPE_VPTR_FIELDNO (type))
>  > +                ; /* ignore vptr */
>  > +              else if (!TYPE_FIELD_PRIVATE (type, type_index) &&
>  > +                  !TYPE_FIELD_PROTECTED (type, type_index))
>  > +                --index;
>  > +              ++type_index;
>  > +            }
>  > +          --type_index;
>  > +        }
>  >
>  > -      name = TYPE_FIELD_NAME (type, i);
>  > +      name = TYPE_FIELD_NAME (type, type_index);
>  >      }
>  >        else if (index < TYPE_N_BASECLASSES (type))
>  > +    /* We are looking up the name of a base class */
>  >      name = TYPE_FIELD_NAME (type, index);
>  >        else
>  >      {
>  > +      int children[3];
>  > +      cplus_class_num_children(type, children);
>  > +
>  >        /* Everything beyond the baseclasses can
>  > -         only be "public", "private", or "protected" */
>  > +         only be "public", "private", or "protected"
>  > +
>  > +         The special "fake" children are always output by varobj in
>  > +         this order. So if INDEX == 2, it MUST be "protected". */
>  >        index -= TYPE_N_BASECLASSES (type);
>  >        switch (index)
>  >          {
>  >          case 0:
>  > -          if (children[v_public] != 0)
>  > -            {
>  > -              name = "public";
>  > -              break;
>  > -            }
>  > +          if (children[v_public] > 0)
>  > +            name = "public";
>  > +          else if (children[v_private] > 0)
>  > +            name = "private";
>  > +          else
>  > +            name = "protected";
>  > +          break;
>  >          case 1:
>  > -          if (children[v_private] != 0)
>  > +          if (children[v_public] > 0)
>  >              {
>  > -              name = "private";
>  > -              break;
>  > +              if (children[v_private] > 0)
>  > +                name = "private";
>  > +              else
>  > +                name = "protected";
>  >              }
>  > +          else if (children[v_private] > 0)
>  > +            name = "protected";
>  > +          break;
>  >          case 2:
>  > -          if (children[v_protected] != 0)
>  > -            {
>  > -              name = "protected";
>  > -              break;
>  > -            }
>  > +          /* Must be protected */
>  > +          name = "protected";
>  > +          break;
>  >          default:
>  >            /* error! */
>  >            break;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: revised changes for gdb/mi 792
  2002-10-22  9:07   ` J. Johnston
@ 2002-10-22  9:10     ` Elena Zannoni
  0 siblings, 0 replies; 6+ messages in thread
From: Elena Zannoni @ 2002-10-22  9:10 UTC (permalink / raw)
  To: J. Johnston; +Cc: Elena Zannoni, gdb-patches

J. Johnston writes:
 > Elena Zannoni wrote:
 > > 
 > > J. Johnston writes:
 > >  > Keith has pointed out some scenarios my original patch did not address and supplied
 > >  > an alternate solution such that I have modified my patch.  This replaces the former
 > >  > patch that was posted.
 > >  >
 > >  >
 > > 
 > > Has this been committed?
 > > In any event, could the STREQ that you touched be replaced by strcmp()?
 > > 
 > 
 > I have not applied any patches unless they were approved.  This patch has
 > not been committed.  Yes, I can change the STREQs in the new code to be
 > strcmp.

OK, I think Fernando approved it.

thanks
Elena


 > 
 > -- Jeff J.
 > 
 > > Thanks
 > > Elena
 > > 
 > >  > gdb/ChangeLog:
 > >  >
 > >  > 2002-10-15  Jeff Johnston  <jjohnstn@redhat.com>
 > >  >          Keith Seitz  <keiths@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.
 > >  >
 > >  > Ok to commit?
 > >  >
 > >  > -- Jeff J.--- varobj.0.c     Fri Oct 11 15:46:03 2002
 > >  > +++ varobj.c Tue Oct 15 17:00:14 2002
 > >  > @@ -2176,7 +2176,6 @@
 > >  >  {
 > >  >    char *name;
 > >  >    struct type *type;
 > >  > -  int children[3];
 > >  >
 > >  >    if (CPLUS_FAKE_CHILD (parent))
 > >  >      {
 > >  > @@ -2191,55 +2190,97 @@
 > >  >      {
 > >  >      case TYPE_CODE_STRUCT:
 > >  >      case TYPE_CODE_UNION:
 > >  > -      cplus_class_num_children (type, children);
 > >  > -
 > >  >        if (CPLUS_FAKE_CHILD (parent))
 > >  >      {
 > >  > -      int i;
 > >  > -
 > >  > -      /* 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];
 > >  > +      /* The fields of the class type are ordered as they
 > >  > +         appear in the class.  We are given an index for a
 > >  > +         particular access control type ("public","protected",
 > >  > +         or "private").  We must skip over fields that don't
 > >  > +         have the access control we are looking for to properly
 > >  > +         find the indexed field. */
 > >  > +      int type_index = TYPE_N_BASECLASSES (type);
 > >  > +      if (STREQ (parent->name, "private"))
 > >  > +        {
 > >  > +          while (index >= 0)
 > >  > +            {
 > >  > +              if (TYPE_VPTR_BASETYPE (type) == type
 > >  > +                  && type_index == TYPE_VPTR_FIELDNO (type))
 > >  > +                ; /* ignore vptr */
 > >  > +              else if (TYPE_FIELD_PRIVATE (type, type_index))
 > >  > +                --index;
 > >  > +              ++type_index;
 > >  > +            }
 > >  > +          --type_index;
 > >  > +        }
 > >  > +      else if (STREQ (parent->name, "protected"))
 > >  > +        {
 > >  > +          while (index >= 0)
 > >  > +            {
 > >  > +              if (TYPE_VPTR_BASETYPE (type) == type
 > >  > +                  && type_index == TYPE_VPTR_FIELDNO (type))
 > >  > +                ; /* ignore vptr */
 > >  > +              else if (TYPE_FIELD_PROTECTED (type, type_index))
 > >  > +                --index;
 > >  > +              ++type_index;
 > >  > +            }
 > >  > +          --type_index;
 > >  > +        }
 > >  > +      else
 > >  > +        {
 > >  > +          while (index >= 0)
 > >  > +            {
 > >  > +              if (TYPE_VPTR_BASETYPE (type) == type
 > >  > +                  && type_index == TYPE_VPTR_FIELDNO (type))
 > >  > +                ; /* ignore vptr */
 > >  > +              else if (!TYPE_FIELD_PRIVATE (type, type_index) &&
 > >  > +                  !TYPE_FIELD_PROTECTED (type, type_index))
 > >  > +                --index;
 > >  > +              ++type_index;
 > >  > +            }
 > >  > +          --type_index;
 > >  > +        }
 > >  >
 > >  > -      name = TYPE_FIELD_NAME (type, i);
 > >  > +      name = TYPE_FIELD_NAME (type, type_index);
 > >  >      }
 > >  >        else if (index < TYPE_N_BASECLASSES (type))
 > >  > +    /* We are looking up the name of a base class */
 > >  >      name = TYPE_FIELD_NAME (type, index);
 > >  >        else
 > >  >      {
 > >  > +      int children[3];
 > >  > +      cplus_class_num_children(type, children);
 > >  > +
 > >  >        /* Everything beyond the baseclasses can
 > >  > -         only be "public", "private", or "protected" */
 > >  > +         only be "public", "private", or "protected"
 > >  > +
 > >  > +         The special "fake" children are always output by varobj in
 > >  > +         this order. So if INDEX == 2, it MUST be "protected". */
 > >  >        index -= TYPE_N_BASECLASSES (type);
 > >  >        switch (index)
 > >  >          {
 > >  >          case 0:
 > >  > -          if (children[v_public] != 0)
 > >  > -            {
 > >  > -              name = "public";
 > >  > -              break;
 > >  > -            }
 > >  > +          if (children[v_public] > 0)
 > >  > +            name = "public";
 > >  > +          else if (children[v_private] > 0)
 > >  > +            name = "private";
 > >  > +          else
 > >  > +            name = "protected";
 > >  > +          break;
 > >  >          case 1:
 > >  > -          if (children[v_private] != 0)
 > >  > +          if (children[v_public] > 0)
 > >  >              {
 > >  > -              name = "private";
 > >  > -              break;
 > >  > +              if (children[v_private] > 0)
 > >  > +                name = "private";
 > >  > +              else
 > >  > +                name = "protected";
 > >  >              }
 > >  > +          else if (children[v_private] > 0)
 > >  > +            name = "protected";
 > >  > +          break;
 > >  >          case 2:
 > >  > -          if (children[v_protected] != 0)
 > >  > -            {
 > >  > -              name = "protected";
 > >  > -              break;
 > >  > -            }
 > >  > +          /* Must be protected */
 > >  > +          name = "protected";
 > >  > +          break;
 > >  >          default:
 > >  >            /* error! */
 > >  >            break;


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-10-22 16:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15 14:21 RFA: revised changes for gdb/mi 792 J. Johnston
2002-10-16  8:16 ` Fernando Nasser
2002-10-16  8:39   ` Keith Seitz
2002-10-22  8:46 ` Elena Zannoni
2002-10-22  9:07   ` J. Johnston
2002-10-22  9:10     ` Elena Zannoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox