public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
* A few python/pretty-printing questions
@ 2009-04-06 20:07 Ray Ruvinskiy
  2009-04-06 21:55 ` Thiago Jung Bauermann
  2009-04-06 21:57 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Ray Ruvinskiy @ 2009-04-06 20:07 UTC (permalink / raw)
  To: archer

Hello,

I've been trying out Archer's python and pretty-printing  
functionality, and I have a few questions:
- Can pretty-printers be toggled on a case-by-case basis? If I have a  
printer enabled for a certain type, can I still look at the raw  
structure?
- Is it possible to export convenience variables from within the  
python layer so that they would be visible from the gdb prompt?
- Suppose I want to pass an expression of the form 'this- 
 >inner1.inner2.leaf' to a python command, is there a quick way to  
look up the gdb.Value corresponding to the name, or do I have to first  
look up 'this' and then index into the dictionary?

Thanks,

Ray

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A few python/pretty-printing questions
  2009-04-06 20:07 A few python/pretty-printing questions Ray Ruvinskiy
@ 2009-04-06 21:55 ` Thiago Jung Bauermann
  2009-04-06 21:57 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Thiago Jung Bauermann @ 2009-04-06 21:55 UTC (permalink / raw)
  To: Ray Ruvinskiy; +Cc: archer

Hi Ray,

El lun, 06-04-2009 a las 16:07 -0400, Ray Ruvinskiy escribió:
> - Can pretty-printers be toggled on a case-by-case basis? If I have a  
> printer enabled for a certain type, can I still look at the raw  
> structure?

Yes, with print/r.

> - Is it possible to export convenience variables from within the  
> python layer so that they would be visible from the gdb prompt?

I'm not sure I understood this or if my answer will apply to what you
have in mind, but you can create a python -> gdb convenience variables
"escape path" with a convenience function. Whatever the invoke method
returns, see:

http://sourceware.org/gdb/current/onlinedocs/gdb_22.html#SEC253

> - Suppose I want to pass an expression of the form 'this- 
>  >inner1.inner2.leaf' to a python command, is there a quick way to  
> look up the gdb.Value corresponding to the name, or do I have to first  
> look up 'this' and then index into the dictionary?

You mean, an easy way to get to the value of .leaf? The Python command
will get the expression as a string. It can then call the
gdb.parse_and_eval function and it will evaluate the string as an
expression in the current language and return the resulting gdb.Value.
In your example, that would be the contents of "leaf".

The gdb.parse_and_eval function is not present in GDB CVS yet, only in
the Python branch. It will probably be renamed when we push it
upstream. 

In fact, we are running a contest to see who can come up with a good
name for it. It's clear that Tromey and myself failed. Any takers?
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A few python/pretty-printing questions
  2009-04-06 20:07 A few python/pretty-printing questions Ray Ruvinskiy
  2009-04-06 21:55 ` Thiago Jung Bauermann
@ 2009-04-06 21:57 ` Tom Tromey
  2009-04-07 12:46   ` Ray Ruvinskiy
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-04-06 21:57 UTC (permalink / raw)
  To: Ray Ruvinskiy; +Cc: archer

>>>>> "Ray" == Ray Ruvinskiy <rruvinsk@sybase.com> writes:

Ray> - Can pretty-printers be toggled on a case-by-case basis? If I have a
Ray> printer enabled for a certain type, can I still look at the raw
Ray> structure?

Yes, "print /r value".  Here, "r" means "raw".

Ray> - Is it possible to export convenience variables from within the
Ray> python layer so that they would be visible from the gdb prompt?

We don't have an API for this, but I suppose we could add one.

Ray> - Suppose I want to pass an expression of the form
Ray> 'this->inner1.inner2.leaf' to a python command, is there a quick
Ray> way to look up the gdb.Value corresponding to the name, or do I
Ray> have to first look up 'this' and then index into the dictionary?

You can use the function gdb.parse_and_eval to parse an expression,
evaluate it, and yield a Value.  We'll probably change the name of
this function, AFAIK none of us particularly likes this name :)

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A few python/pretty-printing questions
  2009-04-06 21:57 ` Tom Tromey
@ 2009-04-07 12:46   ` Ray Ruvinskiy
  0 siblings, 0 replies; 4+ messages in thread
From: Ray Ruvinskiy @ 2009-04-07 12:46 UTC (permalink / raw)
  To: archer

Thank you both for your replies.

Ray

On 6-Apr-09, at 5:57 PM, Tom Tromey wrote:

>>>>>> "Ray" == Ray Ruvinskiy <rruvinsk@sybase.com> writes:
>
> Ray> - Can pretty-printers be toggled on a case-by-case basis? If I  
> have a
> Ray> printer enabled for a certain type, can I still look at the raw
> Ray> structure?
>
> Yes, "print /r value".  Here, "r" means "raw".
>
> Ray> - Is it possible to export convenience variables from within the
> Ray> python layer so that they would be visible from the gdb prompt?
>
> We don't have an API for this, but I suppose we could add one.
>
> Ray> - Suppose I want to pass an expression of the form
> Ray> 'this->inner1.inner2.leaf' to a python command, is there a quick
> Ray> way to look up the gdb.Value corresponding to the name, or do I
> Ray> have to first look up 'this' and then index into the dictionary?
>
> You can use the function gdb.parse_and_eval to parse an expression,
> evaluate it, and yield a Value.  We'll probably change the name of
> this function, AFAIK none of us particularly likes this name :)
>
> Tom
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-07 12:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-06 20:07 A few python/pretty-printing questions Ray Ruvinskiy
2009-04-06 21:55 ` Thiago Jung Bauermann
2009-04-06 21:57 ` Tom Tromey
2009-04-07 12:46   ` Ray Ruvinskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).