This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] varobj deletion after the binary has changed


To avoid confusion these are my opinions; I don't have authority to approve
the patch.

 > --- varobj.c	(revision 552)
 > +++ varobj.c	(working copy)
 > @@ -77,6 +77,10 @@ struct varobj_root
 >  
 >    /* Next root variable */
 >    struct varobj_root *next;
 > +
 > +  /* Flag that indicates validity: set to 0 when this varobj_root refers 
 > +     to symbols that do not exist anymore.  */
 > +  int is_valid;
 >  };

I would move the is_valid member before *next.

 >  /* Every variable in the system has a structure of this type defined
 > @@ -912,6 +916,9 @@ varobj_update (struct varobj **varp, str
 >      /* Not a root var */
 >      return -1;
 >  
 > +  if (!(*varp)->root->is_valid)
 > +    return -1;

This seems to make the variable object some kind of zombie.  Wouldn't it
be better to make GDB report something like:

^done,changelist=[{name="var1",in_scope="invalid",type_changed="false"}]

so then the frontend can choose to delete these variable objects?

 >...
 > +void 
 > +varobj_invalidate (void)
 > +{
 > +  struct varobj **all_rootvarobj;
 > +  struct varobj **varp;
 > +
 > +  if (varobj_list (&all_rootvarobj) > 0)
 > +  {
 > +    varp = all_rootvarobj;
 > +    while (*varp != NULL)
 > +      {
 > +        /* global var must be re-evaluated.  */     
 > +        if ((*varp)->root->valid_block == NULL)
 > +        {
 > +          struct varobj *tmp_var;
 > +
 > +          /* try to create a varobj with same expression. if success we replace
 > +             the old varobj, othewize we invalidate it.  */      

              /* Try to create a varobj with same expression.  If we succeed replace
                 the old varobj, otherwise invalidate it.  */      



 > +          tmp_var = varobj_create (NULL, (*varp)->name, (CORE_ADDR) 0, USE_CURRENT_FRAME);
 > +          if (tmp_var != NULL) 
 > +            { 
 > +	      tmp_var->obj_name =
 > +		savestring ((*varp)->obj_name, strlen ((*varp)->obj_name));

Is xstrdup just a simpler version of savestring? i.e.
   
              tmp_var->obj_name = xstrdup (*varp)->obj_name);


 > +              varobj_delete (*varp, NULL, 0);
 > +              install_variable (tmp_var);
 > +            }
 > +          else
 > +              (*varp)->root->is_valid = 0;
 > +        }
 > +        else /* locals must be invalidated.  */
 > +          (*varp)->root->is_valid = 0;
 > +
 > +        varp++;
 > +      }
 > +    xfree (all_rootvarobj);
 > +  }
 > +  return;
 > +}
 >...

-- 
Nick                                           http://www.inet.net.nz/~nickrob


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]