Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 304010

Summary: Variable view fails to show details for base class member (next)
Product: [Tools] CDT Reporter: Francois Rigault <francois.rigault>
Component: cdt-debug-cdi-gdbAssignee: Elena Laskavaia <elaskavaia.cdt>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: major    
Priority: P3 CC: pawel.1.piech
Version: 5.0   
Target Milestone: 7.0   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Sample file with comments to reproduce the problem
none
A patch that will fix the problem on the sample file
none
updated patch elaskavaia.cdt: iplog-

Description Francois Rigault CLA 2010-02-26 05:14:46 EST
Build Identifier: 20090920-1017

Following bug 244025. Variable view still fails to show the content of some variables.
1- when inspecting "this" variable, cast to subclass must be done using (struct subclass) instance instead of (subclass) instance
2- when casting the subclass is from a given namespace, cast should be done using (struct 'namespace::subclass') instance instead of (struct namespace::subclass) instance.

Reproducible: Always

Steps to Reproduce:
I attach a simple file with comments to reproduce the problem.
Comment 1 Francois Rigault CLA 2010-02-26 05:15:52 EST
Created attachment 160276 [details]
Sample file with comments to reproduce the problem
Comment 2 Francois Rigault CLA 2010-02-26 05:19:24 EST
Created attachment 160277 [details]
A patch that will fix the problem on the sample file
Comment 3 Elena Laskavaia CLA 2010-02-26 13:02:04 EST
What if it is not a struct? What if it is a union?
Comment 4 Francois Rigault CLA 2010-03-01 04:49:14 EST
A union can't appear in the inheritance tree. The union type does not appear in the Variables view and the modified code is not triggered.

I'd be happy to contribute to a test suite if one exists already. We might test some more tricky cases like inheritance with templates for example.
Comment 5 Francois Rigault CLA 2010-03-18 04:44:46 EDT
This bug prevent memory introspection during a debugging session (no specific circumstances required), I guess it owned its major importance flag.

Please tell me any test or any code you need, I'd be happy to provide them asap.
Comment 6 Elena Laskavaia CLA 2010-03-19 10:56:52 EDT
I still don't think it is right patch. I don't understand statement:
The union type does not appear in
the Variables view and the modified code is not triggered.

Union type does not but variable of this type will. I need to create more tests
for it, sorry I did not have time yet to look at it. If you can contribute test it would be good.
Comment 7 Francois Rigault CLA 2010-03-19 11:49:58 EDT
This is what happen for unions (here C is the union type and c the instance)
http://i.imgur.com/zDefv.jpg

Please tell me how I should contribute tests.

---
above test:

union U {
	int i;
	unsigned int j;
};


struct S {
	U* u;
	S() {}
};



int main() {
 S s;

 s.u = new U();
 s.u->i = -1;

 /* display s.u here to see it's ok */
 s.u->i = 0;
}
Comment 8 Elena Laskavaia CLA 2010-04-08 16:58:29 EDT
-> assigned
Comment 9 Elena Laskavaia CLA 2010-04-08 17:02:01 EDT
Created attachment 164293 [details]
updated patch

finally I looked at it. So union is not a concern here because unions cannot be base classes, so struct should be ok. 
I did some more testing and find out that is you declare pointer
to a class, such as 
B * b; (from your example) and try to check values for base class it won't
work either. But this is unrelated to patch - it did not work before either.
I found a solution for that, see new patch attached
Comment 10 Francois Rigault CLA 2010-04-09 03:31:43 EDT
Hi Alena
I verified your patch with previous tests and the pointer case and it works perfectly!
Comment 11 Elena Laskavaia CLA 2010-04-09 12:11:56 EDT
I fixed it on trunk and 6.0 branch, however default framework now is DSF
and it has same problem for base classes, but because gdb itself returns
incorrect stuff...