[lldb-dev] Python type summaries

Enrico Granata granata.enrico at gmail.com
Mon Feb 20 13:57:00 PST 2012


Hi John,
replies are inlined

On Feb 20, 2012, at 1:46 PM, John Firebaugh wrote:

> I'm having trouble getting a custom type summary to work. I can get a
> basic `type summary add --python-script` command to work, but not the
> -P or -F options. -P segfaults, and -F just doesn't seem to work.
> 

the segfault with -P is fixed in ToT LLDB

as for -F, it works. The problem in your sample command
> (lldb) command script import ~/ruby.py
> ready!
> (lldb) type summary add -F ruby_value VALUE
is that it is ignoring modules. When you load a file named ruby.py, Python loads its contents in a module named 'ruby'.
Hence, your function is not really named ruby_value but ruby.ruby_value
If you really need it to be named ruby_value then you need to drop into the interactive interpreter, and from ruby import *
then names will go into the global namespace, and ruby_value will be a valid Python function name
If either one of these does not work, then please let us know since it may be a genuine issue :)

> Here's what I'm doing: https://gist.github.com/1871632
> 
> Any ideas? Is the llvm included with Xcode 4.3 already too old for this feature?
> 
> Also, I was held up temporarily by a few documentation errors:
> 
> In varformats.html, "or somehow loaded it from a file, using the
> `script import` command" should read "or somehow loaded it from a
> file, using the `command script import` command".
> 

Not really a typo..They are two different commands.

script import foo
is the same as entering the interactive interpreter, typing import foo as a command and then quitting the interactive interpreter

command script import ~/foo.py
is an LLDB command that tries to import whatever script module might be stored in file foo.py in the user's home folder

provided that ~ is in your Python path, the two should most probably be equivalent

> In python-reference.html, there are several references to
> __lldb_module_init that should be __lldb_init_module.
> 

This is a true issue with the docs. Needs to fixed.

> Thanks,
> John
> 

Thanks for your feedback :)

- Enrico Granata

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20120220/a09bc76a/attachment.html>


More information about the lldb-dev mailing list