From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27428 invoked by alias); 2 May 2006 13:41:20 -0000 Received: (qmail 27375 invoked by uid 22791); 2 May 2006 13:41:19 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 02 May 2006 13:41:18 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1Fav7m-0001IA-CM for gdb@sources.redhat.com; Tue, 02 May 2006 17:41:15 +0400 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by zigzag.lvk.cs.msu.su with esmtp (Exim 4.50) id 1Fav7J-0001B9-LY; Tue, 02 May 2006 17:40:41 +0400 From: Vladimir Prus To: Nick Roberts Subject: Re: -var-update and address changes Date: Tue, 02 May 2006 13:41:00 -0000 User-Agent: KMail/1.7.2 Cc: Jim Ingham , Daniel Jacobowitz , gdb@sources.redhat.com References: <200605021649.22475.ghost@cs.msu.su> <17495.23335.868893.219879@farnswood.snap.net.nz> In-Reply-To: <17495.23335.868893.219879@farnswood.snap.net.nz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200605021740.40193.ghost@cs.msu.su> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00009.txt.bz2 On Tuesday 02 May 2006 17:14, Nick Roberts wrote: > Vladimir Prus writes: > > On Friday 14 April 2006 23:49, Jim Ingham wrote: > > > Note as an aside, that we had to add another varobj type which is > > > evaluated in the selected frame, whatever that happens to be. That > > > was useful for a general "variable inspector" window. People wanted > > > to put some expression there, and have it re-evaluated in the topmost > > > frame whenever they stopped. So we added that functionality. But > > > that is clearly distinct from what the "*" varobj type is supposed to > > > mean. > > > > Hi Jim, > > is this "variable inspector" the same thing that's called "watches" in > > other IDEs? Well, I really wish that gdb did support variable objects > > that are reevaluated in the current frame. As it stands now, I have to > > re-create variable objects on each step. > > Assuming some ambiguity with current/selected, have you tried (not > documented): > > "-var-create - @ NAME" > > which behaves a bit differently to "-var-create - * NAME". Wow, that's exactly what I'm looking for. Except that it's buggy :-( When I have code like this: int foo() { long i = 15; printf("foo\n"); } int main() { int i = 5; printf("hi 1\n"); foo(); } and I use -var-create I @ i right before call to 'foo()', then when I enter 'foo', -var-update correctly notices the change in value and in type. However, when I have: int foo() { long i = 15; printf("foo\n"); } int main() { int i = 5; printf("hi 1\n"); foo(); } then -var-update inside 'foo' does not report anything and -var-evaluate-expression still reports the value of 'i' from 'main'. Here's the faulty code (varobj.c: value_of_root): tmp_var = varobj_create (NULL, var->name, (CORE_ADDR) 0, USE_SELECTED_FRAME); if (tmp_var == NULL) { return NULL; } new_type = varobj_get_type (tmp_var); if (strcmp (old_type, new_type) == 0) { varobj_delete (tmp_var, NULL, 0); *type_changed = 0; } else In other words, if the type of 'i' in the current frame happens to be the same, the newly created varobj is immediately deleted. What about patch along the following lines, that will create new varobj even if type is the same? @@ -1641,28 +1741,14 @@ return NULL; } new_type = varobj_get_type (tmp_var); - if (strcmp (old_type, new_type) == 0) - { - varobj_delete (tmp_var, NULL, 0); - *type_changed = 0; - } - else - { - if (*type_changed) - { - tmp_var->obj_name = - savestring (var->obj_name, strlen (var->obj_name)); - varobj_delete (var, NULL, 0); - } - else - { - tmp_var->obj_name = varobj_gen_name (); - } - install_variable (tmp_var); - *var_handle = tmp_var; - var = *var_handle; - *type_changed = 1; - } + *type_changed = (strcmp (old_type, new_type) != 0); + + tmp_var->obj_name = + savestring (var->obj_name, strlen (var->obj_name)); + varobj_delete (var, NULL, 0); + install_variable (tmp_var); + *var_handle = tmp_var; + var = *var_handle; } - Volodya