From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16980 invoked by alias); 2 May 2006 17:23:43 -0000 Received: (qmail 16971 invoked by uid 22791); 2 May 2006 17:23:42 -0000 X-Spam-Check-By: sourceware.org Received: from mail-out4.apple.com (HELO mail-out4.apple.com) (17.254.13.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 02 May 2006 17:23:39 +0000 Received: from relay8.apple.com (a17-128-113-38.apple.com [17.128.113.38]) by mail-out4.apple.com (8.12.11/8.12.11) with ESMTP id k42HMnjI020962; Tue, 2 May 2006 10:22:49 -0700 (PDT) Received: from [17.201.22.240] (unknown [17.201.22.240]) by relay8.apple.com (Apple SCV relay) with ESMTP id 16BA417B; Tue, 2 May 2006 10:22:49 -0700 (PDT) In-Reply-To: <200605021740.40193.ghost@cs.msu.su> References: <200605021649.22475.ghost@cs.msu.su> <17495.23335.868893.219879@farnswood.snap.net.nz> <200605021740.40193.ghost@cs.msu.su> Mime-Version: 1.0 (Apple Message framework v749.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1B177ECC-2AD9-4476-AF44-D91F4268E70E@apple.com> Cc: Nick Roberts , Daniel Jacobowitz , gdb@sources.redhat.com Content-Transfer-Encoding: 7bit From: Jim Ingham Subject: Re: -var-update and address changes Date: Tue, 02 May 2006 17:23:00 -0000 To: Vladimir Prus X-Mailer: Apple Mail (2.749.3) X-IsSubscribed: yes 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/msg00010.txt.bz2 Shouldn't the call to var->root->lang->value_of_root down at the bottom of value_of_root take care of fetching the new value? You don't want to discard the old varobj unless you have to, because if the varobj represents a structure or pointer to a structure and the user has fetched any children, or changed the format, or whatever, you will lose that state. Also, I must be missing something this morning, but I can't see any difference between your two examples. Jim On May 2, 2006, at 6:40 AM, Vladimir Prus wrote: > 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 >