This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Python API - nested pretty printers MI implications
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb at sourceware dot org
- Cc: Andrew Oakley <andrew at ado dot is-a-geek dot net>
- Date: Mon, 15 Aug 2011 13:57:50 +0100
- Subject: Re: Python API - nested pretty printers MI implications
- References: <20110814171023.19db4f49@ado-gentoo>
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