GDB pretty printers for iterators

Jonathan Wakely jwakely.gcc@gmail.com
Fri Mar 19 01:45:00 GMT 2010


On 18 March 2010 19:23, Tom Tromey wrote:
> Joe> I debug a lot of C++ code with iterators.  For me, it's OK to see
> Joe> the internals because I know what they look like, and I'd prefer that
> Joe> to any attempt to make things pretty that hides vital information I
> Joe> need to fix the bug.  Maybe it's possible to make things pretty *and*
> Joe> expose all relevant information, but an iterator is far more than simply
> Joe> the value that it points to, so I don't think that just printing
> Joe> "-> 2"
> Joe> is going to cut it.
>
> We could easily add a new gdb parameter to let you choose whether these
> printers are activated.  Something like "set print libstdcxx-iterators off"
> (or whatever name you like).

FWIW I think that's an excellent idea.

> Joe> What I would like is to be able to reliably call the * and ->
> Joe> operators on an iterator from the debugger, so that gdb can do the
> Joe> same kinds of expressions that appear in source code.  In some
> Joe> cases this works today, and in others it doesn't.
>
> If you know when it does not work, that would be handy.
>
> Joe> Having == and != work would be even better, though this is trickier
> Joe> because of the need to handle any overloading properly on pairs of
> Joe> iterators, conversion between const_iterator and iterator, and
> Joe> other nastiness.
>
> We'll get there eventually.  We are slowly chipping away at the
> expression evaluation discrepancies between gdb and g++.  We can't
> achieve full compatibility, but I think we can get a lot closer than we
> are now.

The current situation is fantastic compared with gdb a year or two ago
- THANK YOU!



More information about the Libstdc++ mailing list