Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Variable objects and STL containers
@ 2008-02-05  6:01 Nick Roberts
  2008-02-05  6:17 ` Vladimir Prus
  0 siblings, 1 reply; 27+ messages in thread
From: Nick Roberts @ 2008-02-05  6:01 UTC (permalink / raw)
  To: gdb


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> >
      public	 
        _M_impl	std::_Vector_base<int,std::allocator<int> >::_Vector_impl
          std::allocator<int>	std::allocator<int>
            __gnu_cxx::new_allocator<int>	{...}
          public	 
            _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?

-- 
Nick                                           http://www.inet.net.nz/~nickrob


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2008-02-18 14:19 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-05  6:01 Variable objects and STL containers Nick Roberts
2008-02-05  6:17 ` Vladimir Prus
2008-02-05  6:34   ` Nick Roberts
2008-02-05  6:56     ` Vladimir Prus
2008-02-05 13:16     ` Daniel Jacobowitz
2008-02-15  9:24       ` Nick Roberts
2008-02-17  0:19         ` Nick Roberts
2008-02-17  7:14           ` Vladimir Prus
2008-02-17 19:55             ` Nick Roberts
2008-02-18  8:12               ` Vladimir Prus
2008-02-19 16:31         ` Daniel Jacobowitz
2008-02-05 11:31   ` Mark Kettenis
2008-02-05 12:03     ` Vladimir Prus
2008-02-05 13:18     ` Daniel Jacobowitz
2008-02-08  0:53   ` Nick Roberts
2008-02-08  6:47     ` Vladimir Prus
2008-02-10  4:28       ` Nick Roberts
2008-02-10  7:11         ` Vladimir Prus
2008-02-10 17:52           ` Daniel Jacobowitz
2008-02-10 18:14             ` Vladimir Prus
2008-02-10 19:45             ` Doug Evans
2008-02-10 19:44           ` Doug Evans
2008-02-10 20:05             ` Vladimir Prus
2008-02-10 21:02           ` Nick Roberts
2008-02-11  9:12             ` Vladimir Prus
2008-02-11 13:07               ` Daniel Jacobowitz
2008-02-11 20:28               ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox