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] python/varobj: Fix accessing !IS_VALID EXPs


Hi,

the proposed gdb_assert in varobj_ensure_python_env is IMO correct.

But it breaks gdb.mi/mi-var-invalidate.exp .  Fixed in varobj_get_display_hint.

I am not completely sure where/if other similiar fixups are required.

The trick now is that the whole VAROBJ subtree gets invalid value/type/exp if
var->root->is_valid gets set to 0.  Despite those pointers stay != NULL.
I am still not completely sure it is stale-pointers-safe but it may be.

On FSF GDB it even passes valgrind now but it broke on my
archer-jankratochvil-vla branch which clears the pointers as a sanity check.

It regression passes on {x86_64,x86_64-m32,i686}-fedora11-linux-gnu.
(The test was a bit bogus due to some current regressions.)


Thanks,
Jan


gdb/
2009-08-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* varobj.c (varobj_ensure_python_env): Assert VAR IS_VALID.
	(varobj_get_display_hint): Return NULL for non-IS_VALID VARs.

--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -450,6 +450,8 @@ is_root_p (struct varobj *var)
 struct cleanup *
 varobj_ensure_python_env (struct varobj *var)
 {
+  gdb_assert (var->root->is_valid);
+
   return ensure_python_env (var->root->exp->gdbarch,
 			    var->root->exp->language_defn);
 }
@@ -792,7 +794,12 @@ varobj_get_display_hint (struct varobj *var)
   char *result = NULL;
 
 #if HAVE_PYTHON
-  struct cleanup *back_to = varobj_ensure_python_env (var);
+  struct cleanup *back_to;
+  
+  if (!var->root->is_valid)
+    return NULL;
+
+  back_to = varobj_ensure_python_env (var);
 
   if (var->pretty_printer)
     result = gdbpy_get_display_hint (var->pretty_printer);


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