17f01ac39SJohnny ChenFiles in this directory:
27f01ac39SJohnny Chen
37f01ac39SJohnny Cheno importcmd.py:
47f01ac39SJohnny Chen
57f01ac39SJohnny ChenPython module which provides implementation for the 'import' command.
67f01ac39SJohnny Chen
77f01ac39SJohnny Cheno README:
87f01ac39SJohnny Chen
97f01ac39SJohnny ChenThe file you are reading now.
107f01ac39SJohnny Chen
117f01ac39SJohnny Chen================================================================================
127f01ac39SJohnny ChenThe import command defined by importcmd.py can be used in LLDB to load a Python
137f01ac39SJohnny Chenmodule given its full pathname.
147f01ac39SJohnny ChenThe command works by extending Python's sys.path lookup to include the path to
157f01ac39SJohnny Chenthe module to be imported when required, and then going through the language
167f01ac39SJohnny Chenordinary 'import' mechanism. In this respect, modules imported from LLDB command
177f01ac39SJohnny Chenline should not be distinguishable from those imported using the script interpreter.
187f01ac39SJohnny ChenThe following terminal output shows an interaction with lldb using this new command.
197f01ac39SJohnny Chen
207f01ac39SJohnny ChenEnrico-Granatas-MacBook-Pro:Debug enricogranata$ ./lldb
217f01ac39SJohnny Chen(lldb) script import importcmd
227f01ac39SJohnny Chen(lldb) command script add import -f importcmd.pyimport_cmd
237f01ac39SJohnny Chen(lldb) import ../demo.py
247f01ac39SJohnny Chen(lldb) script demo.test_function('hello world')
257f01ac39SJohnny ChenI am a Python function that says hello world
267f01ac39SJohnny Chen(lldb) quit
277f01ac39SJohnny ChenEnrico-Granatas-MacBook-Pro:Debug enricogranata$
287f01ac39SJohnny Chen
297f01ac39SJohnny ChenOf course, the commands to import the importcmd.py module and to define the import
307f01ac39SJohnny Chencommand, can be included in the .lldbinit file to make this feature available at
317f01ac39SJohnny Chendebugger startup
32*676d3b06SEnrico Granata
33*676d3b06SEnrico GranataWARNING: The import command defined by importcmd.py is now obsolete
34*676d3b06SEnrico GranataIn TOT LLDB, you can say:
35*676d3b06SEnrico Granata(lldb) command script import ../demo.py
36*676d3b06SEnrico Granata(lldb) script demo.test_function('hello world')
37*676d3b06SEnrico GranataI am a Python function that says hello world
38*676d3b06SEnrico Granata(lldb) quit
39*676d3b06SEnrico Granata
40*676d3b06SEnrico Granatausing the native "command script import" command, which offers a superset of what the import command provided by importcmd.py does
41