From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6967 invoked by alias); 5 Jan 2007 04:46:50 -0000 Received: (qmail 6649 invoked by uid 22791); 5 Jan 2007 04:46:49 -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; Fri, 05 Jan 2007 04:46:43 +0000 Received: from kahikatea.snap.net.nz (p202-124-120-54.snap.net.nz [202.124.120.54]) by viper.snap.net.nz (Postfix) with ESMTP id 3CFDD3D81D5; Fri, 5 Jan 2007 17:46:35 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 500) id 9C3BF4F6CD; Fri, 5 Jan 2007 17:46:33 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17821.55336.12928.800849@kahikatea.snap.net.nz> Date: Fri, 05 Jan 2007 04:46:00 -0000 To: Vladimir Prus Cc: Daniel Jacobowitz , gdb-patches@sources.redhat.com Subject: Re: RFC: MI - Detecting change of string contents with variable objects In-Reply-To: <200701042358.59475.ghost@cs.msu.su> References: <17798.19683.251190.740216@kahikatea.snap.net.nz> <17821.25837.573239.858406@kahikatea.snap.net.nz> <20070104205039.GH24634@nevyn.them.org> <200701042358.59475.ghost@cs.msu.su> X-Mailer: VM 7.19 under Emacs 22.0.92.5 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/msg00167.txt.bz2 > > I'm not sure if we'll do that any more after your patch, e.g. if something > > beyond the limit of "set print elements" changes. So, do you think any > > front end relies on the parent being marked updated if any of its children > > are? Vlad, any opinion? > > I think the code in question is never executed for structures or arrays -- > only for "changeable" values. I agree. Below is my latest patch, incorporating some of your suggestions. -- Nick http://www.inet.net.nz/~nickrob *** varobj.c 05 Jan 2007 13:16:30 +1300 1.74 --- varobj.c 05 Jan 2007 15:41:23 +1300 *************** struct varobj *** 132,137 **** --- 132,140 ---- /* Was this variable updated via a varobj_set_value operation */ int updated; + + /* Last print value. */ + char *print_value; }; struct cpstack *************** static int variable_editable (struct var *** 206,211 **** --- 209,217 ---- static char *my_value_of_variable (struct varobj *var); + static char *value_get_print_value (struct value *value, + enum varobj_display_formats format); + static int varobj_value_is_changeable_p (struct varobj *var); static int is_root_p (struct varobj *var); *************** install_new_value (struct varobj *var, s *** 953,959 **** /* If the type is changeable, compare the old and the new values. If this is the initial assignment, we don't have any old value to compare with. */ ! if (!initial && 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 --- 959,967 ---- /* If the type is changeable, compare the old and the new values. If this is the initial assignment, we don't have any old value to compare with. */ ! if (initial) ! 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 *************** install_new_value (struct varobj *var, s *** 974,999 **** changed = 1; else { gdb_assert (!value_lazy (var->value)); ! gdb_assert (!value_lazy (value)); ! ! if (!value_contents_equal (var->value, value)) ! changed = 1; } } } ! /* We must always keep the new value, since children depend on it. */ if (var->value != NULL) value_free (var->value); var->value = value; var->updated = 0; ! gdb_assert (!var->value || value_type (var->value)); return changed; } - /* Update the values for a variable and its children. This is a two-pronged attack. First, re-parse the value for the root's --- 982,1013 ---- changed = 1; else { + char *print_value; gdb_assert (!value_lazy (var->value)); ! print_value = value_get_print_value (value, var->format); ! ! if (strcmp (var->print_value, print_value)) ! { ! xfree (var->print_value); ! var->print_value = print_value; ! changed = 1; ! } ! else ! xfree (print_value); } } } ! /* We must always keep the new value, since children depend on it. */ if (var->value != NULL) value_free (var->value); var->value = value; var->updated = 0; ! gdb_assert (!var->value || value_type (var->value)); return changed; } /* Update the values for a variable and its children. This is a two-pronged attack. First, re-parse the value for the root's *************** new_variable (void) *** 1376,1381 **** --- 1390,1396 ---- var->format = 0; var->root = NULL; var->updated = 0; + var->print_value = NULL; return var; } *************** free_variable (struct varobj *var) *** 1409,1414 **** --- 1424,1430 ---- xfree (var->name); xfree (var->obj_name); + xfree (var->print_value); xfree (var); } *************** my_value_of_variable (struct varobj *var *** 1666,1671 **** --- 1682,1701 ---- return (*var->root->lang->value_of_variable) (var); } + static char * + value_get_print_value (struct value *value, enum varobj_display_formats format) + { + long dummy; + struct ui_file *stb = mem_fileopen (); + struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); + char *thevalue; + + common_val_print (value, stb, format_code[(int) format], 1, 0, 0); + thevalue = ui_file_xstrdup (stb, &dummy); + do_cleanups (old_chain); + return thevalue; + } + /* Return non-zero if changes in value of VAR must be detected and reported by -var-update. Return zero is -var-update should never report *************** c_value_of_variable (struct varobj *var) *** 2038,2056 **** } else { - long dummy; - struct ui_file *stb = mem_fileopen (); - struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); - char *thevalue; - gdb_assert (varobj_value_is_changeable_p (var)); gdb_assert (!value_lazy (var->value)); ! common_val_print (var->value, stb, ! format_code[(int) var->format], 1, 0, 0); ! thevalue = ui_file_xstrdup (stb, &dummy); ! do_cleanups (old_chain); ! return thevalue; ! } } } } --- 2068,2077 ---- } else { gdb_assert (varobj_value_is_changeable_p (var)); gdb_assert (!value_lazy (var->value)); ! return value_get_print_value (var->value, var->format); ! } } } }