Internals for STL containers
Joe Buck
Joe.Buck@synopsys.COM
Thu Feb 7 20:09:00 GMT 2008
On Fri, Feb 08, 2008 at 08:28:21AM +1300, Nick Roberts wrote:
>
> > > I would say they are pretty stable, because we have a stable ABI which
> > > we are not going to break until C++0x: that means we can only implement
> > > limited span changes, we cannot add data members, for example neither
> > > change the memory layout of the classes.
>
> Probably an ignorant question, but how does this particular ABI get used?
>
> > Yes, it would certainly make sense to teach gdb (not just the Emacs
> > interface of gdb) to recognize STL containers and give a better display.
> > The members of std::vector have been stable since gcc-3.0, I'm pretty
> > sure (certainly since 3.2).
>
> I was thinking of doing it in Emacs, not Gdb. AFAIK, Gdb can't tell
> what compiler created the executable.
It doesn't need to know that. Any compiler that follows the ABI, whether gcc,
icc, or SGI's compiler, will produce the same data members on a GNU/Linux
or BSD platform. It's a portable specification.
gdb could cross-check to see if the class has the expected members.
So, if gdb sees the class std::vector<int> has the members _M_start
_M_finish, and _M_end_of_storage, and it's on a platform that supports
the standard ABI, it can assume that it has a standard vector<int>,
and could safely supply advanced methods.
More information about the Gcc
mailing list