Python API - nested pretty printers MI implications

Pedro Alves pedro@codesourcery.com
Mon Aug 15 12:58:00 GMT 2011


On Sunday 14 August 2011 17:10:23, Andrew Oakley wrote:
>         def children(self):
>                 yield ("normal variable", "some value")
>                 yield ("phony group 1", inner_pretty_printer(...))
>                 yield ("phony group 2", inner_pretty_printer(...))
> 
> This seems to work well but I'm not quite sure how to handle the for MI.
> 
> As far as I can tell I need to create "fake" varobj structures with no
> underlying value or type (because I don't have one). 

I'm not very familiar with the pretty printing stuff, but,
doesn't something like this work nowadays?

class phony_value:
       ...
       /* extend Value */

class phony_value_pretty_printer:
        def __init__(self, ...):
                ...

def new_phony(outer, whatnot):
       /* return new phony value for outer */
       ...

class outer_pretty_printer:
        def __init__(self, val):
                ...

        def to_string(self):
                ...

        def children(self):
                yield ("normal variable", "some value")
                yield ("phony group 1", new_phony(1))
                yield ("phony group 2", new_phony(2))


That is, create a specialized Value class and install the pretty
printer for that _value_.

-- 
Pedro Alves



More information about the Gdb mailing list