From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10123 invoked by alias); 8 Jan 2007 05:53:26 -0000 Received: (qmail 10112 invoked by uid 22791); 8 Jan 2007 05:53:25 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 08 Jan 2007 05:53:18 +0000 Received: from kahikatea.snap.net.nz (p202-124-125-176.snap.net.nz [202.124.125.176]) by viper.snap.net.nz (Postfix) with ESMTP id E163D3D8213 for ; Mon, 8 Jan 2007 18:53:13 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 500) id 434724F6E2; Mon, 8 Jan 2007 18:53:13 +1300 (NZDT) From: Nick Roberts Message-ID: <17825.56391.466504.569955@kahikatea.snap.net.nz> Date: Mon, 08 Jan 2007 05:53:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: gdb-patches@sources.redhat.com Subject: Re: MI testsuite failures [PATCH] In-Reply-To: <17825.33653.885121.321357@kahikatea.snap.net.nz> References: <17825.33653.885121.321357@kahikatea.snap.net.nz> X-Mailer: VM 7.19 under Emacs 22.0.92.6 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00219.txt.bz2 > After this I plan to fix the testsuite failures so I can then > add the field for -var-update. Here's a patch with fixes for the testsuite. I've made a further change to varobj.c to fix a failure in mi-var-child.exp. I'm not sure what saved_input_radix does because currently GDB can return from varobj_set_value without restoring input_radix. I've fixed mi-var-cmd.exp and mi-var-display.exp but nor their mi2 counterparts. I can easily do this but I'd rather just remove the mi2-*.exp files completely especially with the changes needed for the proposed change to -var-update. Is this an option? -- Nick http://www.inet.net.nz/~nickrob 2007-01-08 Nick Roberts * 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. 2007-01-08 Nick Roberts * gdb.mi/mi-var-cmd.exp: Add fields to changelists for string contents changes. After -var-assign, do -var-update before -var-evaluate-expression. * gdb.mi/mi-var-display.exp: After -var-assign, do -var-update before -var-evaluate-expression. 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 8 Jan 2007 05:37:44 -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 8 Jan 2007 05:37:47 -0000 *************** struct varobj *** 130,138 **** /* The format of the output for this object */ enum varobj_display_formats format; - /* Was this variable updated via a varobj_set_value operation */ - int updated; - /* Last print value. */ char *print_value; }; --- 130,135 ---- *************** 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! */ --- 794,804 ---- 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 */ --- 818,836 ---- { /* 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 */ *************** install_new_value (struct varobj *var, s *** 963,1001 **** var->print_value = value_get_print_value (value, var->format); else if (changeable) { ! /* If the value of the varobj was changed by -var-set-value, then the ! value in the varobj and in the target is the same. However, that value ! is different from the value that the varobj had after the previous ! -var-update. So need to the varobj as changed. */ ! if (var->updated) changed = 1; ! else { ! /* Try to compare the values. That requires that both ! values are non-lazy. */ ! ! /* Quick comparison of NULL values. */ ! if (var->value == NULL && value == NULL) ! /* Equal. */ ! ; ! else if (var->value == NULL || value == NULL) ! changed = 1; ! else ! { ! char *print_value; ! gdb_assert (!value_lazy (var->value)); ! gdb_assert (!value_lazy (value)); ! print_value = value_get_print_value (value, var->format); ! if (strcmp (var->print_value, print_value) != 0) ! { ! xfree (var->print_value); ! var->print_value = print_value; ! changed = 1; ! } ! else ! xfree (print_value); } } } --- 935,963 ---- var->print_value = value_get_print_value (value, var->format); else if (changeable) { ! /* Try to compare the values. That requires that both ! values are non-lazy. */ ! ! /* Quick comparison of NULL values. */ ! if (var->value == NULL && value == NULL) ! /* Equal. */ ! ; ! else if (value == NULL) changed = 1; ! else { ! char *print_value; ! gdb_assert (!value_lazy (value)); ! print_value = value_get_print_value (value, var->format); ! if (strcmp (var->print_value, print_value) != 0) ! { ! xfree (var->print_value); ! var->print_value = print_value; ! changed = 1; } + else + xfree (print_value); } } *************** install_new_value (struct varobj *var, s *** 1003,1009 **** if (var->value != NULL) value_free (var->value); var->value = value; - var->updated = 0; gdb_assert (!var->value || value_type (var->value)); --- 965,970 ---- *************** varobj_update (struct varobj **varp, str *** 1116,1122 **** { /* Note that it's changed */ VEC_safe_push (varobj_p, result, v); - v->updated = 0; } } } --- 1077,1082 ---- *************** new_variable (void) *** 1390,1396 **** var->children = NULL; var->format = 0; var->root = NULL; - var->updated = 0; var->print_value = NULL; return var; --- 1350,1355 ---- 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 8 Jan 2007 05:37:49 -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: testsuite/gdb.mi/mi-var-cmd.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-cmd.exp,v retrieving revision 1.22 diff -c -p -r1.22 mi-var-cmd.exp *** testsuite/gdb.mi/mi-var-cmd.exp 4 Jan 2007 21:59:10 -0000 1.22 --- testsuite/gdb.mi/mi-var-cmd.exp 8 Jan 2007 05:37:50 -0000 *************** mi_execute_to "exec-step 8" "end-steppin *** 261,267 **** # Note: this test also checks that lpsimple->integer and lsimple.integer have # changed (they are the same) mi_gdb_test "-var-update *" \ ! "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ "update all vars: func and lpsimple changed" --- 261,267 ---- # Note: this test also checks that lpsimple->integer and lsimple.integer have # changed (they are the same) mi_gdb_test "-var-update *" \ ! "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ "update all vars: func and lpsimple changed" *************** mi_gdb_test "-var-assign linteger 3333" *** 279,285 **** "assign to linteger" mi_gdb_test "-var-update *" \ ! "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ "update all vars: linteger changed after assign" mi_gdb_test "-var-assign linteger 3333" \ --- 279,285 ---- "assign to linteger" mi_gdb_test "-var-update *" \ ! "\\^done,changelist=\\\[\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ "update all vars: linteger changed after assign" mi_gdb_test "-var-assign linteger 3333" \ *************** mi_gdb_test "-var-assign lcharacter 'z'" *** 324,329 **** --- 324,332 ---- "\\^done,value=\"122 'z'\"" \ "assign to lcharacter" + mi_gdb_test "-var-update *" \ + "\\^done,changelist=.*" \ + "var update" mi_gdb_test "-var-evaluate-expression lcharacter" \ "\\^done,value=\"122 'z'\"" \ "eval lcharacter" *************** mi_gdb_test "-var-evaluate-expression lc *** 331,336 **** --- 334,342 ---- mi_gdb_test "-var-assign llong 1313L" \ "\\^done,value=\"1313\"" \ "assign to llong" + mi_gdb_test "-var-update *" \ + "\\^done,changelist=.*" \ + "var update" mi_gdb_test "-var-evaluate-expression llong" \ "\\^done,value=\"1313\"" \ "eval llong" *************** mi_gdb_test "-var-assign lplong &llong" *** 351,356 **** --- 357,365 ---- mi_gdb_test "-var-assign lfloat 3.4567" \ "\\^done,value=\"3.45.*\"" \ "assign to lfloat" + mi_gdb_test "-var-update *" \ + "\\^done,changelist=.*" \ + "var update" mi_gdb_test "-var-evaluate-expression lfloat" \ "\\^done,value=\"3.45.*\"" \ "eval lfloat" Index: testsuite/gdb.mi/mi-var-display.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v retrieving revision 1.15 diff -c -p -r1.15 mi-var-display.exp *** testsuite/gdb.mi/mi-var-display.exp 10 Aug 2006 05:27:21 -0000 1.15 --- testsuite/gdb.mi/mi-var-display.exp 8 Jan 2007 05:37:51 -0000 *************** mi_gdb_test "-var-assign bar 3" \ *** 108,114 **** mi_gdb_test "-var-set-format bar decimal" \ "\\^done,format=\"decimal\"" \ "set format variable bar" ! mi_gdb_test "-var-evaluate-expression bar" \ "\\^done,value=\"3\"" \ "eval variable bar with new value" --- 108,116 ---- mi_gdb_test "-var-set-format bar decimal" \ "\\^done,format=\"decimal\"" \ "set format variable bar" ! mi_gdb_test "-var-update *" \ ! "\\^done,changelist=.*" \ ! "var update" mi_gdb_test "-var-evaluate-expression bar" \ "\\^done,value=\"3\"" \ "eval variable bar with new value" *************** mi_gdb_test "-var-set-format foo decimal *** 169,174 **** --- 171,179 ---- # Test: c_variable-6.18 # Desc: check new value of foo + mi_gdb_test "-var-update *" \ + "\\^done,changelist=.*" \ + "var update" mi_gdb_test "-var-evaluate-expression foo" \ "\\^done,value=\"3\"" \ "eval variable foo"