MI: fix base members in references
Vladimir Prus
ghost@cs.msu.su
Wed Nov 29 12:56:00 GMT 2006
A KDevelop user reported the following bug. If you have C++ reference variable
that refers to a class type, and that class has bases, gdb is not able to
show the values of any fields of bases. The trimmed down example is this:
struct S { int i; int j; };
struct S2 : S {};
int foo(S2& s)
{
return s.i;
}
int main()
{
S2 s;
s.i = 1;
s.j = 2;
return foo(s);
}
If you are in 'foo' and try to create MI variable objects for s, and navigate
it, the varobjs for 'i' and 'j' members of the base class will have no value.
The problem happens when creating varobj for the base object. MI sees that
it's reference and tries to pass it via value_ind. The latter immediately
removes top-level reference and rightly refuses to deference a structure.
MI should just do nothing about references -- the value_cast function used to
obtain base handles references just fine.
The attached patch fixed the problem, no regression. I'll write a testcase for
it as soon as my previous references patch is reviewed -- I don't want to
pile too many testcases in as-yet-uncommitted file.
OK?
If this patch is fine, can I also commit it to 6.6 branch? The bug in question
is quite problematic for C++ code.
- Volodya
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 01REFERENCES_AND_BASES.diff
Type: text/x-diff
Size: 679 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20061129/f211d06a/attachment.bin>
More information about the Gdb-patches
mailing list