Python type summaries

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.

Here's what I'm doing: ruby.py · GitHub

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".

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

Thanks,
John

Hi John,
replies are inlined

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 :slight_smile:

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 :slight_smile:

- Enrico Granata

Thank you, that explains it. `type summary add -F ruby.ruby_value
VALUE` indeed works.

Maybe `type summary add -F` could issue a diagnostic when it can't
resolve the function? That probably would have pointed me in the right
direction.

Thanks,
John