Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <ghost@cs.msu.su>
To: gdb@sources.redhat.com
Subject: Re: Variable objects and STL containers
Date: Tue, 05 Feb 2008 06:17:00 -0000	[thread overview]
Message-ID: <fo8v0i$c41$1@ger.gmane.org> (raw)
In-Reply-To: <18343.64413.689019.489727@kahikatea.snap.net.nz>

Nick Roberts wrote:

> 
> 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?

Technically, there is formal interface, called iterators, provided by the
C++ standard. I don't have the slightest confidence in gdb not falling over
if you try to use them, though.

We discussed using Python scripting for that; in fact, I have a patch locally
that will make 

        -var-evaluate-expression V 

for a vector print something like:

        [1,2,3]

I'm working on making those element the children of the variable object,
but it's not done yet.

- Volodya



  reply	other threads:[~2008-02-05  6:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-05  6:01 Nick Roberts
2008-02-05  6:17 ` Vladimir Prus [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='fo8v0i$c41$1@ger.gmane.org' \
    --to=ghost@cs.msu.su \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox