[lldb-dev] command script import

Jim Ingham jingham at apple.com
Fri Oct 14 10:26:24 PDT 2011


Enrico, this looks great.  The only quibble I have is that you do a bunch of path manipulation by hand here that should be done through FileSpec.  For instance, calling your SplitPathInDirAndFile, and then running through Python to expand ~ isn't necessary, you should be able to just create a FileSpec, passing in "resolve_path = true" and then grab the file name and the directory name, or grab the full path.  If there is something wrong with the FileSpec implementation that's keeping you from using it this way, we should fix that.  Also, instead of pulling off the .pyc or .py extension by hand it would be good to add this functionality to FileSpec, since that is also generally useful.  Something like GetFileNameExtension and GetFilenameRemovingExtension or whatever...

Jim

On Oct 14, 2011, at 8:15 AM, Enrico Granata wrote:

> <importcmd.diff>
> 
> Hi all,
> the proposed patch is a follow-up to the Python script defining an "import" command.
> This one patch introduces a new "command script import" with equivalent semantics, but implemented in C++ through ScriptInterpreterPython and not cluttering the root namespace, as Jim was suggesting.
> Also as an addition, modules imported through "command script import" can define an __lldb_init_module(SBDebugger,session_dict) function that is called after import-ing the new module. The included test case (I put it in python_api/import, but if this is not the best location, I can easily fix that) also provides an example of how to use the feature.
> 
> Any feedback and ideas for improvements are, as usual, most welcome.
> 
> Sincerely,
> - Enrico Granata
> 
> _______________________________________________
> 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