This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GDB pretty printers for iterators


On Wed, Mar 17, 2010 at 02:34:04AM -0700, Jonathan Wakely wrote:
> 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.

Perhaps just the address of the storage the iterator points to (in hex,
like a pointer), and the pointed-to value if it's a valid iterator?  If
the user is debugging code that depends on iterator equality or distance,
she needs to be able to tell if two iterators are the same or different,
and a container might contain the same value twice.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]