This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Variable objects and STL containers

Using variable objects, if I display a watch expression for an STL container, e.g.

  vector<int> v (3);
  v[0] = 1;
  v[1] = 11;
  v[2] = 22;

in Emacs, I get something like this:

v std::vector<int,std::allocator<int> >
    std::_Vector_base<int,std::allocator<int> > std::_Vector_base<int,std::allocator<int> >
        _M_impl	std::_Vector_base<int,std::allocator<int> >::_Vector_impl
          std::allocator<int>	std::allocator<int>
            __gnu_cxx::new_allocator<int>	{...}
            _M_start             int * 	    0x804c008
              *_M_start	                    0
            _M_finish	         int *	    0x804c014	
              *_M_finish                    135153	
            _M_end_of_storage    int *      0x804c014
              *_M_end_of_storage            135153	

which is a bit meaningless to the end user.  This is for gcc, and I guess other
compilers store STL containers differently.  In this case, I know where the
values are really stored:

 v._M_impl._M_start	int *	0x804c008
 *v._M_impl._M_start		1
 *(v._M_impl._M_start+1)	11
 *(v._M_impl._M_start+2)	22

(gdb) p v._M_impl._M_finish - v._M_impl._M_start
$1 = 3

and it would be better to display these.

I have two questions:

1) Does GDB know what compiler was used to create an object file/executable?

2) _M_impl, _M_start are gcc internals and I guess they could change (like CLI!)
   Is it meaningful to ask on the gcc list for a formal interface to these details?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]