[lldb-dev] new 'import' script by path command

Jim Ingham jingham at apple.com
Wed Oct 12 11:11:03 PDT 2011


This is a nice convenience, I was a little worried at first because I want to try to avoid introducing top-level name commands when not necessary...  I want to keep that namespace as clean as possible so people can use it for shortcuts. 

On thinking a bit, it seems more logical to me if the same functionality was done through "command script import"; that could do whatever the current script language does to import a module into the scripting language.

It is also pretty consistent with having "command script add/delete/etc..."

If you follow this through further, if we have control of it we could also make some convention like if you do:

def __lldb_init_for_interpreter (lldb_interpreter):

we would call this and pass in the LLDB interpreter that was doing the import.  Then you could put your package's "command script add" commands in there.  That way you could make up modules that you import and they would add all their commands to the LLDB interpreter they were being imported into...

We could also add commands to set the PYTHONPATH, etc, like:

command script import --path-component ~/.lldb_python my_script...

This is more work, so I have no problem with adding the example for now.  But if we do more work on it, I argue more for it's going into "command script import..."

Jim


On Oct 12, 2011, at 3:07 AM, Enrico Granata wrote:

> Hi all,
> 
> the proposed patch provides an implementation of a new 'import' command for LLDB, based upon Python commands. an example usage is:
> (lldb) script import importcmd
> (lldb) command script add -f importcmd.pyimport_cmd import
> (lldb) import /Users/user/Documents/demo1.py
> (lldb) script demo1.test_function(1)
> there is an included test case that checks for correctness of this new command by importing some Python script files and using the resulting modules
> 
> plus, this fixes a minor issue where the custom Python commands defined for the functionalities/command_python/ test case would not be cleaned up if the test case itself failed
> 
> Any feedback on this is most welcome.
> 
> Thanks,
> - Enrico Granata
> <importcmd_patch.diff>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev




More information about the lldb-dev mailing list