Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] Variables view to show implementation class members?

> Gdb sees type of variable as declared. If you want to access 
> field that are in actual type you have to cast it.
> Cast is available from context menu in variables view.

As for DSF-GDB, if you want to use it, we don't currently have
the Cast menu (bug 219203), but you can use the Expressions view
and make your expression 
(SpecificClient*)p

Now, as a user, I tend to agree with Jens that it would be nice if the 
variables view showed the actual type of the variable instead of its
declared type.  After all, that is what the JDT does ;-)
And this "set print object on" seems to show that GDB can figure
this out somehow.

I have opened Bug 251398 on DSF-GDB to track this.

Marc


> 
> Elmenthaler, Jens wrote:
> > Hi all,
> > 
> >  
> > 
> > We are heavily making use of polymorphism. Using the debugger, the 
> > variables view shows the members of the declared class, not of the 
> > implemented. This doesn't really help much.
> > 
> >  
> > 
> > However, using gdb in the console view, I can look into the 
> > implementation class, using the following command sequence:
> > 
> >  
> > 
> > set print object on
> > 
> > print expression
> > 
> >  
> > 
> > My question, is this a limitation of the gdb MI 
> > (-var-evaluate-expression seems to be used for the variables view), 
> > should the input be sent to the gdb folks instead?
> > 
> >  
> > 
> > Or could the CDT do it, e.g. gdb commands can be also sent 
> to a gdb MI 
> > session?
> > 
> >  
> > 
> > Anyone working on that already?
> > 
> >  
> > 
> > Greetings, Jens.
> > 
> >  
> > 
> > Example:
> > 
> > #include <iostram>
> > 
> > using namespace std;
> > 
> >  
> > 
> > class Client {
> > 
> > public:
> > 
> >   virtual ~Client() {}
> > 
> > };
> > 
> >  
> > 
> > class SpecificClient : public Client {
> > 
> > public:
> > 
> >  
> > 
> >   virtual ~SpecificClient() {};
> > 
> >  
> > 
> > private:
> > 
> >   int mFive;
> > 
> >   string mText;
> > 
> > };
> > 
> >  
> > 
> > int main()
> > 
> > {
> > 
> >   Client *p = new SpecificClient;
> > 
> >  
> > 
> >   cerr << "Set break point here " << p << endl;
> > 
> >   return 0;
> > 
> > }
> > 
> >  
> > 
> > Set print object on
> > 
> > print *p
> > 
> >  
> > 
> > 1329-interpreter-exec console "print *p"
> > 
> > ~"$1 = (SpecificClient) {\n"
> > 
> > $1 = (SpecificClient) {
> > 
> > ~"  <Client> = {\n"
> > 
> >   <Client> = {
> > 
> > ~"    _vptr.Client = 0x400eb0\n"
> > 
> >     _vptr.Client = 0x400eb0
> > 
> > ~"  }, \n"
> > 
> >   },
> > 
> > ~"  members of SpecificClient: \n"
> > 
> >   members of SpecificClient:
> > 
> > ~"  mFive = 0"
> > 
> >   mFive = 0~", \n"
> > 
> > ,
> > 
> > ~"  mText = {\n"
> > 
> >   mText = {
> > 
> > ~"    static npos = 18446744073709551615"
> > 
> >     static npos = 18446744073709551615~", \n"
> > 
> > ,
> > 
> > ~"    _M_dataplus = {\n"
> > 
> >     _M_dataplus = {
> > 
> > ~"      <std::allocator<char>> = {\n"
> > 
> >       <std::allocator<char>> = {
> > 
> > ~"        <__gnu_cxx::new_allocator<char>> = {<No data 
> fields>}, <No 
> > data fields>}, \n"
> > 
> >         <__gnu_cxx::new_allocator<char>> = {<No data 
> fields>}, <No data 
> > fields>},
> > 
> > ~"      members of 
> > std::basic_string<char,std::char_traits<char>,std::allocator<char> 
> >  >::_Alloc_hider: \n"
> > 
> >       members of 
> > std::basic_string<char,std::char_traits<char>,std::allocator<char> 
> >  >::_Alloc_hider:
> > 
> > ~"      _M_p = 0x3dfdcefe18 \"\""
> > 
> >       _M_p = 0x3dfdcefe18 ""~"\n"
> > 
> >  
> > 
> > ~"    }"
> > 
> >     }~"\n"
> > 
> >  
> > 
> > ~"  }"
> > 
> >   }~"\n"
> > 
> >  
> > 
> > ~"}"
> > 
> > }~"\n"
> > 
> >  
> > 
> > Jens Elmenthaler
> > Platform & Components Lab
> > 
> > Architecture Development Team
> > 
> >  
> > 
> > 
> > 
> > Verigy Germany GmbH, Herrenberger Str. 130, 71034 Böblingen
> > Sitz der Gesellschaft: Böblingen - Amtsgericht Böblingen HRB 6167
> > 
> > WEEE-Reg.-Nr. DE 16968742
> > Geschäftsführer: Hans-Jürgen Wagner, Dietmar Höller
> > 
> > Tel: +49 7031 4357-119
> > j*ens.elmenthaler@xxxxxxxxxx* <mailto:jens.elmenthaler@xxxxxxxxxx>
> >  
> > 
> >  
> > 
> > 
> > 
> --------------------------------------------------------------
> ----------
> > 
> > _______________________________________________
> > cdt-dev mailing list
> > cdt-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/cdt-dev
> 


Back to the top