Re: MI: fix base members in references

Vladimir Prus
2006-12-05T13:23:49Z

Vladimir Prus wrote:

>
> 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.

*PING*? This is one-liner, and causes no regressions, so should be
non-controversial.

- Volodya