This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Variable objects: references formatting
On Thursday 04 May 2006 11:20, Nick Roberts wrote:
> > Again, maybe you can provide specific case where this error is produced?
> > If it affect real-world cases we'd better fix it soon.
>
> It happens when I debug Emacs but I can't provide a simple case yet.
> However, do you see the problem with references that I mentioned earlier
> (that they don't seem to disappear from the changelist with -var-update)?
> This seems to be the case for any variable object made from a reference.
Yes, I see that for variable object created from reference, -var-update *
always mentions that. Looking at this under debugger, it seems that the call
to my_value_equal in varobj_update compares the value of *reference* to the
value of new *referenced-to* object. This happens in my_value_equal
(varobj.c):
static int
my_value_equal (struct value *val1, struct value *volatile val2, int
*error2)
{
/* Make sure we also know the contents of VAL2. */
val2 = coerce_array (val2);
Before this call, val2 is the value of reference itself. After this call, it
has value of referenced-to object. val1, on the other hand, is still the
value of reference.
I'm not sure what's the point of that call is, and importantly, I'm not sure
what would be the right behaviour. Variable object corresponding to reference
can be reported as updated either when:
(1) The referenced-to value changes
(2) The value of reference changes itself
(3) Both
I think that (1) is the right solution since in C++ reference can't change
value, and change of reference value in gdb can be only when reference goes
into scope or goes out of scope, so we're never interested in the value of
reference itself. In fact, both Eclipse and KDevelop hide the reference value
in its displays.
If (1) is what we need, there should be extra call to 'coerce_array' for
'val1'. In fact, that call should probably be done when varobj is first
created. Alas, quick attempt to do that results in segfault, and I'm out of
time for today. Feel free to beat me to it ;-)
- Volodya