From: "Alpár Jüttner" <alpar@cs.elte.hu>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: kdsfinger@gmail.com, gdb@sourceware.org
Subject: Re: how to view content in stl vector
Date: Mon, 18 Jun 2007 08:53:00 -0000 [thread overview]
Message-ID: <1182156720.4609.31.camel@mikro.mikro> (raw)
In-Reply-To: <200706151952.l5FJq2B7009679@brahms.sibelius.xs4all.nl>
In a running On Fri, 2007-06-15 at 21:52 +0200, Mark Kettenis wrote:
> > Date: Tue, 12 Jun 2007 11:05:21 -0400
> > From: kdsfinger@gmail.com
> >
> > hi, all
> > How may I view the content in a stl vector in ddd? (or the command to
> > print it in gdb?). It seems I can only view the first element. I
> > searched google but did not find answer. Thanks for help.
You can simply use the member functions and operators of std::vector<>
in the p[rint] gdb command. For example:
(gdb) p v.size()
$1 = 8
(gdb) p v[2]
$2 = (double &) @0x804c048: 12
This works perfectly provided that
* optimization is turned off and debugging (-ggdb) is turned on,
* operator[] (or any other query function you would like to use)
is used at least once in the code, thus its code is put in the
executable,
* you debug a running process, not a core dump.
> I generally consider C++ code to be undebuggable.
I wouldn't say that. It is at least as well debuggable as a C code.
(Debugging any non-trivial data structure in C is also very cumbersome).
The only major difficulty I frequently encounter is that debugging of
the STL header files cannot be turned off.
Regards,
Alpar
next prev parent reply other threads:[~2007-06-18 8:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-12 15:05 kdsfinger
2007-06-15 19:52 ` Mark Kettenis
2007-06-18 8:53 ` Alpár Jüttner [this message]
2007-06-18 11:15 ` Maik Beckmann
2007-06-18 11:27 ` Daniel Jacobowitz
2007-06-18 12:27 ` Maik Beckmann
2007-06-18 12:36 ` Daniel Jacobowitz
2007-06-18 12:54 ` Maik Beckmann
2007-06-18 13:06 ` Daniel Jacobowitz
2007-06-18 14:35 ` Maik Beckmann
2007-06-18 14:44 ` Daniel Jacobowitz
2007-06-18 14:57 ` Maik Beckmann
2007-06-18 15:03 ` Maik Beckmann
2007-06-18 15:28 ` Andreas Schwab
2007-06-18 15:49 ` Maik Beckmann
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=1182156720.4609.31.camel@mikro.mikro \
--to=alpar@cs.elte.hu \
--cc=gdb@sourceware.org \
--cc=kdsfinger@gmail.com \
--cc=mark.kettenis@xs4all.nl \
/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