Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Varobj cleanups
@ 2006-12-08 18:56 Vladimir Prus
  2006-12-08 20:06 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Prus @ 2006-12-08 18:56 UTC (permalink / raw)
  To: gdb-patches

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


This patch ports some varobj cleanups from Apple's version, in preparation
for some much more interesting ports. OK?	

- Volodya

	Port from Apple's version.
	gdb/
	* varobj.c (type_changeable): Rename to...
	(varobj_value_is_changeable_p): ...this. Adjust all callers.
	(is_root_p): New function. Use it everywhere.


[-- Attachment #2: path_1__gdb_mainline.diff --]
[-- Type: text/x-diff, Size: 4161 bytes --]

--- gdb/varobj.c	(/mirrors/gdb_mainline)	(revision 2554)
+++ gdb/varobj.c	(/patches/gdb/path_1/gdb_mainline)	(revision 2554)
@@ -102,8 +102,8 @@ struct varobj
   struct type *type;
 
   /* The value of this expression or subexpression.  This may be NULL. 
-     Invariant: if type_changeable (this) is non-zero, the value is either
-     NULL, or not lazy.  */
+     Invariant: if varobj_value_is_changeable_p (this) is non-zero, 
+     the value is either NULL, or not lazy.  */
   struct value *value;
 
   /* Did an error occur evaluating the expression or getting its value? */
@@ -233,7 +233,9 @@ static int variable_editable (struct var
 
 static char *my_value_of_variable (struct varobj *var);
 
-static int type_changeable (struct varobj *var);
+static int varobj_value_is_changeable_p (struct varobj *var);
+
+static int is_root_p (struct varobj *var);
 
 /* C implementation */
 
@@ -404,6 +406,11 @@ static struct vlist **varobj_table;
 \f
 
 /* API Implementation */
+static int
+is_root_p (struct varobj *var)
+{
+  return (var->root->rootvar == var);
+}
 
 /* Creates a varobj (not its children) */
 
@@ -827,7 +834,7 @@ varobj_set_value (struct varobj *var, ch
 	}
 
       /* All types that are editable must also be changeable.  */
-      gdb_assert (type_changeable (var));
+      gdb_assert (varobj_value_is_changeable_p (var));
 
       /* The value of a changeable variable object must not be lazy.  */
       gdb_assert (!value_lazy (var->value));
@@ -914,7 +921,7 @@ install_new_value (struct varobj *var, s
      be fetched or not.  C++ fake children (public/protected/private) don't have
      a type. */
   gdb_assert (var->type || CPLUS_FAKE_CHILD (var));
-  changeable = type_changeable (var);
+  changeable = varobj_value_is_changeable_p (var);
   need_to_fetch = changeable;
 
   if (var->type && TYPE_CODE (var->type) == TYPE_CODE_UNION)
@@ -1028,7 +1035,7 @@ varobj_update (struct varobj **varp, str
     return -1;
 
   /*  Only root variables can be updated... */
-  if ((*varp)->root->rootvar != *varp)
+  if (!is_root_p (*varp))
     /* Not a root var */
     return -1;
 
@@ -1249,7 +1256,7 @@ install_variable (struct varobj *var)
   *(varobj_table + index) = newvl;
 
   /* If root, add varobj to root list */
-  if (var->root->rootvar == var)
+  if (is_root_p (var))
     {
       /* Add to list of root variables */
       if (rootlist == NULL)
@@ -1308,7 +1315,7 @@ uninstall_variable (struct varobj *var)
   xfree (cv);
 
   /* If root, remove varobj from root list */
-  if (var->root->rootvar == var)
+  if (is_root_p (var))
     {
       /* Remove from list of root variables */
       if (rootlist == var->root)
@@ -1485,7 +1492,7 @@ static void
 free_variable (struct varobj *var)
 {
   /* Free the expression if this is a root variable. */
-  if (var->root->rootvar == var)
+  if (is_root_p (var))
     {
       free_current_contents (&var->root->exp);
       xfree (var->root);
@@ -1703,7 +1710,7 @@ value_of_root (struct varobj **var_handl
   /* This should really be an exception, since this should
      only get called with a root variable. */
 
-  if (var->root->rootvar != var)
+  if (!is_root_p (var))
     return NULL;
 
   if (var->root->use_selected_frame)
@@ -1785,7 +1792,7 @@ my_value_of_variable (struct varobj *var
    Return value of 0 means that gdb need not call value_fetch_lazy
    for the value of this variable object.  */
 static int
-type_changeable (struct varobj *var)
+varobj_value_is_changeable_p (struct varobj *var)
 {
   int r;
   struct type *type;
@@ -1934,7 +1941,7 @@ c_value_of_root (struct varobj **var_han
   int within_scope;
 
   /*  Only root variables can be updated... */
-  if (var->root->rootvar != var)
+  if (!is_root_p (var))
     /* Not a root var */
     return NULL;
 
@@ -2143,7 +2150,7 @@ c_value_of_variable (struct varobj *var)
 	    struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
 	    char *thevalue;
 
-	    gdb_assert (type_changeable (var));
+	    gdb_assert (varobj_value_is_changeable_p (var));
 	    gdb_assert (!value_lazy (var->value));
 	    common_val_print (var->value, stb,
 			      format_code[(int) var->format], 1, 0, 0);

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: Varobj cleanups
@ 2006-12-18  3:51 Nick Roberts
  2006-12-18  7:27 ` Vladimir Prus
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Roberts @ 2006-12-18  3:51 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb-patches


>     * From: Daniel Jacobowitz
>     * To: Vladimir Prus
>     * Cc: gdb-patches at sources dot redhat dot com
>     * Date: Fri, 8 Dec 2006 15:06:14 -0500
>     * Subject: Re: Varobj cleanups
>     * References: <200612082155.44157.ghost@cs.msu.su>
> 
> On Fri, Dec 08, 2006 at 09:55:42PM +0300, Vladimir Prus wrote:
> > 
> > This patch ports some varobj cleanups from Apple's version, in preparation
> > for some much more interesting ports. OK?	
> > 
> > - Volodya
> > 
> > 	Port from Apple's version.
> > 	gdb/
> > 	* varobj.c (type_changeable): Rename to...
> > 	(varobj_value_is_changeable_p): ...this. Adjust all callers.
> > 	(is_root_p): New function. Use it everywhere.
> 
> OK.

Is there any reason that this patch has not been committed?


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


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

end of thread, other threads:[~2006-12-18  7:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-08 18:56 Varobj cleanups Vladimir Prus
2006-12-08 20:06 ` Daniel Jacobowitz
2006-12-18  3:51 Nick Roberts
2006-12-18  7:27 ` Vladimir Prus

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