This is the mail archive of the
mailing list for the GDB project.
Re: how to view content in stl vector
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: email@example.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 = (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
* 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.