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]

varobj.c cleanup


I've checked in the below varobj.c cleanup; no behaviour change.

- Volodya

2008-03-26  Vladimir Prus  <vladimir@codesourcery.com>

	* varobj.c (struct varobj_root): Rename use_selected_frame to
	floating, and clarify the meaning.
	(varobj_create, varobj_update,  new_root_variable): Adjust.
	(value_of_root): Don't use type_changed as in variable,
	adjust comment.
	(c_value_of_root): Adjust.
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.106
diff -u -p -r1.106 varobj.c
--- varobj.c	24 Mar 2008 17:33:30 -0000	1.106
+++ varobj.c	26 Mar 2008 14:01:51 -0000
@@ -75,9 +75,10 @@ struct varobj_root
      was created.  */
   int thread_id;
 
-  /* If 1, "update" always recomputes the frame & valid block
-     using the currently selected frame. */
-  int use_selected_frame;
+  /* If 1, the -var-update always recomputes the value in the
+     current thread and frame.  Otherwise, variable object is
+     always updated in the specific scope/thread/frame  */
+  int floating;
 
   /* Flag that indicates validity: set to 0 when this varobj_root refers 
      to symbols that do not exist anymore.  */
@@ -472,7 +473,7 @@ varobj_create (char *objname,
 
       /* frame = -2 means always use selected frame */
       if (type == USE_SELECTED_FRAME)
-	var->root->use_selected_frame = 1;
+	var->root->floating = 1;
 
       block = NULL;
       if (fi != NULL)
@@ -1157,10 +1158,9 @@ varobj_update (struct varobj **varp, str
 	 the frame in which a local existed. We are letting the 
 	 value_of_root variable dispose of the varobj if the type
 	 has changed.  */
-      type_changed = 1;
       new = value_of_root (varp, &type_changed);
       
-      /* If this is a "use_selected_frame" varobj, and its type has changed,
+      /* If this is a floating varobj, and its type has changed,
 	 them note that it's changed.  */
       if (type_changed)
 	VEC_safe_push (varobj_p, result, *varp);
@@ -1504,7 +1504,7 @@ new_root_variable (void)
   var->root->exp = NULL;
   var->root->valid_block = NULL;
   var->root->frame = null_frame_id;
-  var->root->use_selected_frame = 0;
+  var->root->floating = 0;
   var->root->rootvar = NULL;
   var->root->is_valid = 1;
 
@@ -1699,16 +1699,15 @@ name_of_child (struct varobj *var, int i
   return (*var->root->lang->name_of_child) (var, index);
 }
 
-/* What is the ``struct value *'' of the root variable VAR? 
-   TYPE_CHANGED controls what to do if the type of a
-   use_selected_frame = 1 variable changes.  On input,
-   TYPE_CHANGED = 1 means discard the old varobj, and replace
-   it with this one.  TYPE_CHANGED = 0 means leave it around.
-   NB: In both cases, var_handle will point to the new varobj,
-   so if you use TYPE_CHANGED = 0, you will have to stash the
-   old varobj pointer away somewhere before calling this.
-   On return, TYPE_CHANGED will be 1 if the type has changed, and 
-   0 otherwise. */
+/* What is the ``struct value *'' of the root variable VAR?
+   For floating variable object, evaluation can get us a value
+   of different type from what is stored in varobj already.  In
+   that case:
+   - *type_changed will be set to 1
+   - old varobj will be freed, and new one will be
+   created, with the same name.
+   - *var_handle will be set to the new varobj 
+   Otherwise, *type_changed will be set to 0.  */
 static struct value *
 value_of_root (struct varobj **var_handle, int *type_changed)
 {
@@ -1725,7 +1724,7 @@ value_of_root (struct varobj **var_handl
   if (!is_root_p (var))
     return NULL;
 
-  if (var->root->use_selected_frame)
+  if (var->root->floating)
     {
       struct varobj *tmp_var;
       char *old_type, *new_type;
@@ -1745,16 +1744,10 @@ value_of_root (struct varobj **var_handl
 	}
       else
 	{
-	  if (*type_changed)
-	    {
-	      tmp_var->obj_name =
-		savestring (var->obj_name, strlen (var->obj_name));
-	      varobj_delete (var, NULL, 0);
-	    }
-	  else
-	    {
-	      tmp_var->obj_name = varobj_gen_name ();
-	    }
+	  tmp_var->obj_name =
+	    savestring (var->obj_name, strlen (var->obj_name));
+	  varobj_delete (var, NULL, 0);
+
 	  install_variable (tmp_var);
 	  *var_handle = tmp_var;
 	  var = *var_handle;
@@ -2200,7 +2193,7 @@ c_value_of_root (struct varobj **var_han
     inferior_ptid, get_frame_id (deprecated_safe_get_selected_frame ()));
 
   /* Determine whether the variable is still around. */
-  if (var->root->valid_block == NULL || var->root->use_selected_frame)
+  if (var->root->valid_block == NULL || var->root->floating)
     within_scope = 1;
   else if (var->root->thread_id == 0)
     {

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