This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: Compat: Missing things from libstdc++-v3/python/libstdcxx/v6/printers.py


On Sun, 2016-12-18 at 23:22 +0000, Jonathan Wakely wrote:
> > Also it would be nice if there were some way of creating a "debugger
> > iterator", implemented for all the basic STL types that would allow us
> > to iterate over them from within the debugger, including with core
> > files.
> 
> I'm not sure what you're suggesting, could you give an example of what
> you mean?

Well, suppose I have a class that contains a list of objects.  I want to
write a Python function for my class that will walk that list and print
out information from the objects in it, in some format.  From what I can
see, walking through a std::list and obtaining each object in the list
is not that simple to implement.  Or what if I have a std::set or
std::unordered_map or whatever?

Or maybe I'm debugging a core file and my std::list has too many entries
in it to make it practical to run "p myList" and search through all
those entries by sight, but I'd like to be able to write something up
that would walk the container looking for some value for example.

Even if I have something like operator[] xmethod for each STL container,
each time I run it I have to start from the beginning of the container
which, if the container has many elements, can be very slow.  Having an
iterator-like _debugger_ object for an STL container that could be
incremented to the next item, etc. seems like a useful thing.

Also, it would be great to be able to have the same interface available
to iterate through whatever STL container we had.

I'm just spit-balling here, but suppose there were an xmethod for
begin() on each container, which returned some sort of Python object
which held enough information to be an iterator for that container, and
had methods to move forward/backward etc.  I don't mean an actual C++
iterator, I mean a Python iterator over the C++ container.  Does that
make sense or am I missing something basic?


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