From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 693 invoked by alias); 26 Apr 2008 17:16:39 -0000 Received: (qmail 684 invoked by uid 22791); 26 Apr 2008 17:16:38 -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; Sat, 26 Apr 2008 17:16:19 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Jpo0R-0002ZV-V6 for gdb-patches@sources.redhat.com; Sat, 26 Apr 2008 17:16:11 +0000 Received: from 78.158.192.230 ([78.158.192.230]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 26 Apr 2008 17:16:11 +0000 Received: from vladimir by 78.158.192.230 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 26 Apr 2008 17:16:11 +0000 To: gdb-patches@sources.redhat.com From: Vladimir Prus Subject: Re: [RFA] Document fixed/floating variable objects and thread-id. Date: Sat, 26 Apr 2008 17:44:00 -0000 Message-ID: References: <200804041320.00361.vladimir@codesourcery.com> <200804092147.37085.ghost@cs.msu.su> <200804100105.31748.ghost@cs.msu.su> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit User-Agent: KNode/0.10.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: 2008-04/txt/msg00600.txt.bz2 Eli Zaretskii wrote: >> From: Vladimir Prus >> Date: Wed, 23 Apr 2008 14:26:14 +0400 >> >> > void foo (int i) >> > { >> > ... >> > } >> > >> > void bar (int i) >> > { >> > ... >> > } >> > >> > >> > If you create a fixed varobj in 'bar', then each time you updating, new value of >> > bar's i will be read. If you create a floating varobj in 'bar', then if you update >> > it while still in bar, new value of bar's i will be read. If you update it in foo, >> > then the value of foo's i will be used. >> > >> > So while for fixed varobj's update fetches new value of 'i', for floating varobjs >> > we also decide which 'i' to use each time. >> >> Eli, >> does the above make the code behaviour clear enough for you to suggest better doc >> working, or you want something else clarified? > > Sorry, I somehow was certain I replied to you back then, but I see now > that I didn't. > > More to the point, I cannot say that I have a clear understanding of > the issue. In what other situations will fixed and floating varobjs > behave differently? Are we talking about any situation where > identically named variables have different binding to memory > addresses, depending on scope and context? Yes. > Like, for example, > identically named members of different C++ classes? This is one possible example, but not the primary one, see below. > Also, why does such behavior make sense? That is, why would I want an > object whose value depends on semi-random factors? E.g., if the > inferior stopped at a watchpoint, the context is unpredictable, and > then so is the value of a floating varobj, if I understand you > correctly. How is this helpful? One example is that you have function 'foo' that has a very important variable 'foo_state' that you always want to see when you're inside 'foo'. The 'foo' function might be recursive, or it might be used in different threads. With floating variable objects, when you switch a thread or frame, you can update variable object, and see the value of 'foo_state' in the current thread/frame. With fixed variable object, you'd have to delete and create a variable object. In this case, while 'foo_state' will always resolve to the same variable declaration in the source code, the address of the variable will be different each time. It's possible to imagine cases where an identifier can be resolved to different declaration each time a variable object is updated. For example, you might have a convention that all classes have a 'str' method that give a textual rendition of its state, even though those classes are not necessary in a common hierarchy. By creating a floating varobj for 'str()' expression you'll make that textual rendition show up. - Volodya