From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19196 invoked by alias); 12 Apr 2006 12:05:09 -0000 Received: (qmail 19181 invoked by uid 22791); 12 Apr 2006 12:05:07 -0000 X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 12 Apr 2006 12:05:04 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FTe5e-00007Y-D2 for gdb@sources.redhat.com; Wed, 12 Apr 2006 14:04:54 +0200 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Apr 2006 14:04:54 +0200 Received: from ghost by zigzag.lvk.cs.msu.su with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Apr 2006 14:04:54 +0200 To: gdb@sources.redhat.com From: Vladimir Prus Subject: -var-update and address changes Date: Wed, 12 Apr 2006 16:02:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit User-Agent: KNode/0.8.2 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-04/txt/msg00143.txt.bz2 Hi, I'm running into what looks like a bug in -var-update. Basically, I create a varobj with "&variable", then I enter a function that has a variable with the same name, and -var-update does not report anything. Here's the code, and the gdb session. int foo() { int i = 10; ++i; return i; } int main() { int i = 10; i = foo(); return i; } And here's the session -break-insert a.cpp:12 ^done,.... (gdb) -break-insert a.cpp:5 ^done,.... (gdb) -exec-run ^running (gdb) *stopped,reason="breakpoint-hit",..... (gdb) -var-create TEST * &i ^done,name="TEST",numchild="1",type="int *" (gdb) -exec-continue ^running (gdb) *stopped,reason="breakpoint-hit",....... (gdb) -var-update * ^done,changelist=[] (gdb) The value of "&i" changes, but -var-update does not report this. This can be explained by the fact that varobjs are "bound" to the stack frame where they were created, but that "binding" is not mentioned in documentation. The problem I'm trying to solve is this: 1. In some frame, I create varobj for 'i'. 2. After continue, I see that there's local variable 'i', and I want to find out if previously-created varobj can be used to show this local 'i', or if I should create new 'i'. - I can't use frame ids because gdb only prints code address, and two different stack frames can have the same code address. - I can't use -var-update, because it does not seem to report anything - I can't use -var-update on variable addresses, because of the above report So, the only solution is to remove all varobjs, and create them afresh, which is contrary to the very purpose of varobjs. Can somebody suggest the right fix? So far, I think that the simplest approach is to make gdb print stack address of current frame, like is done on the Apple branch: 553^done,stack=[frame= {level="0",addr="0x00003db0",fp="0xbffff2c0",...... That way, frontend can deal with the issue of frame stacks themself, and -var-update will be only used when single-stepping inside a given frame. Will patches to implement this be welcome? And I still don't know what to do about variable shadowing inside a single function. - Volodya