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]

Cleanup varobjs for invalid expressions


Pretty much everywhere in varobj.c, we use a convention
that varobj value of NULL means that some error occured
when evaluating the value. However, in some cases
we try to evaluate at least the type of varobj, and that
code unintentionally sets varobj value to non-null.
The result of this is:

	-var-create null_ptr * **0
        ^done,name="null_ptr",numchild="0",value="0",type="int"

Clearly, the value of "0" is bogus (on x86).

This patch fixes the problem and changes the above output to:

        ^done,name="null_ptr",numchild="0",value="",type="int"

OK?

- Volodya



	

Attachment: invalid_expr_varobj.ChangeLog
Description: Text document

--- gdb/varobj.c	(/mirrors/gdb_mainline)	(revision 3543)
+++ gdb/varobj.c	(/patches/gdb/invalid_expr_varobj/gdb_mainline)	(revision 3543)
@@ -433,7 +433,7 @@ varobj_create (char *objname,
     {
       char *p;
       enum varobj_languages lang;
-      struct value *value;
+      struct value *value = NULL;
 
       /* Parse and evaluate the expression, filling in as much
          of the variable's data as possible */
@@ -495,11 +495,15 @@ varobj_create (char *objname,
          If evaluate_expression succeeds we got the value we wanted.
          But if it fails, we still go on with a call to evaluate_type()  */
       if (!gdb_evaluate_expression (var->root->exp, &value))
-	/* Error getting the value.  Try to at least get the
-	   right type.  */
-	value = evaluate_type (var->root->exp);
+	{
+	  /* Error getting the value.  Try to at least get the
+	     right type.  */
+	  struct value *value = evaluate_type (var->root->exp);
+	  var->type = value_type (value);
+	}
+      else 
+	var->type = value_type (value);
 
-      var->type = value_type (value);
       install_new_value (var, value, 1 /* Initial assignment */);
 
       /* Set language info */

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