GDB pretty printers for iterators

Jonathan Wakely jwakely.gcc@gmail.com
Wed Mar 17 09:34:00 GMT 2010


On 17 March 2010 04:23, Joe Buck wrote:
>> (gdb) p j
>> $1 = 2
>>
>> I think I'd rather have iterators print something like "iterator
>> pointing to 2" or even "-> 2"
>
> Even that is going to be a problem, if for example you're
> debugging code that computes distances between random iterators,
> for example.
>
> (gdb) p *j
> should print 2, but printing the iterator should reveal the internals,
> I think.  If gdb has special knowledge of the meaning of the interals,
> that can be reported, but if any information is left out, you'll
> hamper debugging.

There's always print/r for the raw output, but I do think the pretty
output needs to find a middle ground between automatic dereferencing
(which falsely implies the iterator is nothing more than the thing it
points to) and printing the impenetrable internals of iterators and
containers.



More information about the Libstdc++ mailing list