This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Document fixed/floating variable objects and thread-id.

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?  


> 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

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]