Re: Compat: Missing things from libstdc++-v3/python/libstdcxx/v6/printers.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19 December 2016 at 05:43, Paul Smith wrote:
> 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?

OK, I understand now.

You want a Python Iterable for a container. That already exists for
std::map, std::set etc. and is used to implement the pretty printer
for those types:

class RbtreeIterator(Iterator):
    """
    Turn an RB-tree-based container (std::map, std::set etc.) into
    a Python iterable object.
    """

There's no reason it can't be done for other containers, but somebody
needs to do the work. Somebody who wants this. Hint hint ;-)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux