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]

MI testsuite failures


I notice now that my last change introduced several testsuite failures:

  FAIL: gdb.mi/mi2-var-cmd.exp: update all vars: func and lpsimple changed
  FAIL: gdb.mi/mi2-var-cmd.exp: update all vars: linteger changed after assign

These are because GDB notices that string contents have been changed and
just need an extra output field, which I guess is a good thing.


  FAIL: gdb.mi/mi-var-cmd.exp: assign same value to func (update)

This is more subtle and is caused by having two variable objects for
one variable, var1 and var2 say.  Then if they have a common value 10
say and you do:

-var-assign var1 11
-var-assign var2 12

var->updated is set to 1 for each and they are both reported as changed
with -var-update.

However doing -var-update again gives var1 in the chagelist because the
real value is 12 but var->print_value is "11".

I think this is a bug in -var-assign; it should set the variable value
but not interfere with the variable object.  Note that generally if you
have two variable objects for one value and set the value of one with
-var-assign, one will be reported as changed because var->updated is 1,
and the other because the value has changed.  I think the value held
by the variable object shouldn't change until -var-update is issued,
just as is the case if the real value changes during execution.  This is
a patch to do that.

OK to commit?

After this I plan to fix the testsuite failures so I can then
add the field for -var-update.

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


2007-01-08  Nick Roberts  <nickrob@snap.net.nz>

	* varobj.h: Declare varobj_set_value as char*.

	* varobj.c (varobj_set_value): Make type char*. Return new value but
	don't install it.

	* mi/mi-cmd-var.c (mi_cmd_var_assign): Don't use varobj_get_value.


Index: varobj.h
===================================================================
RCS file: /cvs/src/src/gdb/varobj.h,v
retrieving revision 1.6
diff -c -p -r1.6 varobj.h
*** varobj.h	17 Dec 2005 22:34:03 -0000	1.6
--- varobj.h	7 Jan 2007 23:27:50 -0000
*************** extern int varobj_get_attributes (struct
*** 93,99 ****
  
  extern char *varobj_get_value (struct varobj *var);
  
! extern int varobj_set_value (struct varobj *var, char *expression);
  
  extern int varobj_list (struct varobj ***rootlist);
  
--- 93,99 ----
  
  extern char *varobj_get_value (struct varobj *var);
  
! extern char* varobj_set_value (struct varobj *var, char *expression);
  
  extern int varobj_list (struct varobj ***rootlist);
  
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.76
diff -c -p -r1.76 varobj.c
*** varobj.c	5 Jan 2007 21:58:48 -0000	1.76
--- varobj.c	7 Jan 2007 23:27:54 -0000
*************** varobj_get_value (struct varobj *var)
*** 797,808 ****
     value of the given expression */
  /* Note: Invokes functions that can call error() */
  
! int
  varobj_set_value (struct varobj *var, char *expression)
  {
    struct value *val;
!   int offset = 0;
!   int error = 0;
  
    /* The argument "expression" contains the variable's new value.
       We need to first construct a legal expression for this -- ugh! */
--- 797,807 ----
     value of the given expression */
  /* Note: Invokes functions that can call error() */
  
! char*
  varobj_set_value (struct varobj *var, char *expression)
  {
    struct value *val;
!   char* print_value;
  
    /* The argument "expression" contains the variable's new value.
       We need to first construct a legal expression for this -- ugh! */
*************** varobj_set_value (struct varobj *var, ch
*** 822,864 ****
  	{
  	  /* We cannot proceed without a valid expression. */
  	  xfree (exp);
! 	  return 0;
  	}
  
-       /* All types that are editable must also be changeable.  */
-       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));
- 
-       /* Need to coerce the input.  We want to check if the
- 	 value of the variable object will be different
- 	 after assignment, and the first thing value_assign
- 	 does is coerce the input.
- 	 For example, if we are assigning an array to a pointer variable we
- 	 should compare the pointer with the the array's address, not with the
- 	 array's content.  */
-       value = coerce_array (value);
- 
-       /* The new value may be lazy.  gdb_value_assign, or 
- 	 rather value_contents, will take care of this.
- 	 If fetching of the new value will fail, gdb_value_assign
- 	 with catch the exception.  */
        if (!gdb_value_assign (var->value, value, &val))
  	return 0;
!      
!       /* If the value has changed, record it, so that next -var-update can
! 	 report this change.  If a variable had a value of '1', we've set it
! 	 to '333' and then set again to '1', when -var-update will report this
! 	 variable as changed -- because the first assignment has set the
! 	 'updated' flag.  There's no need to optimize that, because return value
! 	 of -var-update should be considered an approximation.  */
!       var->updated = install_new_value (var, val, 0 /* Compare values. */);
        input_radix = saved_input_radix;
!       return 1;
      }
  
!   return 0;
  }
  
  /* Returns a malloc'ed list with all root variable objects */
--- 821,839 ----
  	{
  	  /* We cannot proceed without a valid expression. */
  	  xfree (exp);
! 	  return NULL;
  	}
  
        if (!gdb_value_assign (var->value, value, &val))
  	return 0;
! 
!       print_value = value_get_print_value (val, var->format);
        input_radix = saved_input_radix;
! 
!       return print_value;
      }
  
!   return NULL;
  }
  
  /* Returns a malloc'ed list with all root variable objects */
Index: mi/mi-cmd-var.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-var.c,v
retrieving revision 1.27
diff -c -p -r1.27 mi-cmd-var.c
*** mi/mi-cmd-var.c	8 Dec 2006 04:09:53 -0000	1.27
--- mi/mi-cmd-var.c	7 Jan 2007 23:27:55 -0000
*************** enum mi_cmd_result
*** 447,453 ****
  mi_cmd_var_assign (char *command, char **argv, int argc)
  {
    struct varobj *var;
!   char *expression;
  
    if (argc != 2)
      error (_("mi_cmd_var_assign: Usage: NAME EXPRESSION."));
--- 447,453 ----
  mi_cmd_var_assign (char *command, char **argv, int argc)
  {
    struct varobj *var;
!   char *expression, *print_value;
  
    if (argc != 2)
      error (_("mi_cmd_var_assign: Usage: NAME EXPRESSION."));
*************** mi_cmd_var_assign (char *command, char *
*** 463,472 ****
  
    expression = xstrdup (argv[1]);
  
!   if (!varobj_set_value (var, expression))
      error (_("mi_cmd_var_assign: Could not assign expression to varible object"));
  
!   ui_out_field_string (uiout, "value", varobj_get_value (var));
    return MI_CMD_DONE;
  }
  
--- 463,474 ----
  
    expression = xstrdup (argv[1]);
  
!   print_value = varobj_set_value (var, expression);
! 
!   if (!print_value)
      error (_("mi_cmd_var_assign: Could not assign expression to varible object"));
  
!   ui_out_field_string (uiout, "value", print_value);
    return MI_CMD_DONE;
  }
  


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