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]

[patch] Fix gdb.mi hang on floating VAROBJs


Hi,

while so-called floating (frame "@") VAROBJs are unusual they will crash on
varobj_invalidate.

The patch also reformats the function is at was also the reason of the bug.


Thanks,
Jan


gdb/
2009-05-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* varobj.c (varobj_invalidate): New variable `var'.  Fix hang on
	FLOATING VAROBJs.  Reformat the function.

gdb/testsuite/
2009-05-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.mi/mi2-var-cmd.exp (floating varobj invalidation): New test.

diff --git a/gdb/varobj.c b/gdb/varobj.c
index d36e46d..eb5ecc7 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2767,44 +2767,41 @@ When non-zero, varobj debugging is enabled."),
 void 
 varobj_invalidate (void)
 {
-  struct varobj **all_rootvarobj;
-  struct varobj **varp;
+  struct varobj **all_rootvarobj, **varp, *var;
 
-  if (varobj_list (&all_rootvarobj) > 0)
+  varobj_list (&all_rootvarobj);
+
+  for (varp = all_rootvarobj; *varp != NULL; varp++)
     {
-      varp = all_rootvarobj;
-      while (*varp != NULL)
+      var = *varp;
+
+      /* Floating varobjs are reparsed on each stop, so we don't care if
+	 the presently parsed expression refers to something that's gone.
+	 */
+      if (var->root->floating)
+	continue;
+
+      /* global var must be re-evaluated.  */     
+      if (var->root->valid_block == NULL)
 	{
-	  /* Floating varobjs are reparsed on each stop, so we don't care if
-	     the presently parsed expression refers to something that's gone.
-	     */
-	  if ((*varp)->root->floating)
-	    continue;
-
-	  /* 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 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 = xstrdup ((*varp)->obj_name);
-		  varobj_delete (*varp, NULL, 0);
-		  install_variable (tmp_var);
-		}
-	      else
-		(*varp)->root->is_valid = 0;
+	  struct varobj *tmp_var;
+
+	  /* Try to create a varobj with same expression.  If we succeed
+	     replace the old varobj, otherwise invalidate it.  */
+	  tmp_var = varobj_create (NULL, var->name, (CORE_ADDR) 0,
+				   USE_CURRENT_FRAME);
+	  if (tmp_var != NULL) 
+	    { 
+	      tmp_var->obj_name = xstrdup (var->obj_name);
+	      varobj_delete (var, NULL, 0);
+	      install_variable (tmp_var);
 	    }
-	  else /* locals must be invalidated.  */
-	    (*varp)->root->is_valid = 0;
-
-	  varp++;
+	  else
+	    var->root->is_valid = 0;
 	}
+      else /* locals must be invalidated.  */
+	var->root->is_valid = 0;
     }
+
   xfree (all_rootvarobj);
-  return;
 }
diff --git a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp
index a4279a8..a1689a0 100644
--- a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp
@@ -523,5 +523,9 @@ mi_gdb_test "-var-update selected_a" \
 	"\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",type_changed=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
 	"update selected_a in do_special_tests"
 
+mi_gdb_test "-file-exec-and-symbols ${binfile}" "\\^done" \
+	    "floating varobj invalidation"
+
+
 mi_gdb_exit
 return 0


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