Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andrew Oakley <andrew@ado.is-a-geek.net>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb@sourceware.org
Subject: Re: Python API - nested pretty printers MI implications
Date: Mon, 15 Aug 2011 14:06:00 -0000	[thread overview]
Message-ID: <4E4927D2.2050903@ado.is-a-geek.net> (raw)
In-Reply-To: <201108151357.50298.pedro@codesourcery.com>

On 15/08/11 13:57, Pedro Alves wrote:
> 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?

[snip]

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

This didn't come up when I asked about this previously.

I assume the idea is to create a gdb.Value (with some data it doesn't
really matter what) and then detect that it is that particular gdb.Value
when the pretty printers list is searched?  Perhaps you could do
something like this:

def fake_value_printer(val):
	if hasattr(val, "prettyprinter"):
		return val.prettyprinter
	else:
		return None

gdb.pretty_printers.insert(0, fake_value_printer)

Then you could just return any old gdb.Value and as long as it had a
prettyprinter attribute then that would be called instead of the
"normal" version.

Is this what you were thinking of?

That's quite a nice trick but I'm not sure its a good long-term
solution.  It relies on the same python gdb.Value being passed back to
the pretty printer selection function and probably causes exactly the
same problems for the MI.

Back to my initial question I guess for MI this is also creating a
"dummy" varobj with some type and value chosen by the python script.  Do
you know if this works in practice with MI frontends?

-- 
Andrew Oakley


  reply	other threads:[~2011-08-15 14:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-14 16:11 Andrew Oakley
2011-08-14 22:18 ` Daniel Jacobowitz
2011-08-15 12:36   ` André Pönitz
2011-08-15 13:26     ` Pedro Alves
2011-08-15 14:33       ` André Pönitz
2011-08-15 14:49         ` Pedro Alves
2011-08-15 15:36           ` André Pönitz
2011-08-16 22:12             ` Andrew Oakley
2011-08-16 22:23   ` [PATCH] Allow nested python pretty printers andrew
2011-08-17  9:56     ` Phil Muldoon
2011-08-17 13:28       ` Andrew Oakley
2011-08-15 12:58 ` Python API - nested pretty printers MI implications Pedro Alves
2011-08-15 14:06   ` Andrew Oakley [this message]
2011-08-15 14:30     ` Pedro Alves
2011-08-16 22:12       ` Andrew Oakley
2011-08-17 12:49         ` Pedro Alves
2011-08-17 18:31           ` Andrew Oakley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4927D2.2050903@ado.is-a-geek.net \
    --to=andrew@ado.is-a-geek.net \
    --cc=gdb@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox