how to view content in stl vector

Mark Kettenis mark.kettenis@xs4all.nl
Fri Jun 15 19:52:00 GMT 2007


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

There isn't a simple way.  You'll have to dig through the data
structure yourself, which requires knowledge about the particulat stl
implementation.  In a running program you might be able to call the
appropriate member functions (like operator[]), but doing so in the
right way isn't easy for heavily templated code used in most stl
implementations.  And that doesn't work in core dumps.

I generally consider C++ code to be undebuggable.

Mark



More information about the Gdb mailing list