Reputation: 4925
I would like write a helper function which to be available in my LLDB session. (I am not talking about python here) This function will invoke methods of current program variables and then pass them to a python script. I guess i understand how to write a python script, but i am still not sure how to write an lldb-script which interacts with my program.
Upvotes: 1
Views: 694
Reputation: 27110
For a general intro on how to use the lldb Python module to interact with your program, see:
https://lldb.llvm.org/use/python-reference.html
That will show you some different ways you can use Python in lldb, and particularly how to make Python based commands and load them into the lldb command interpreter.
There are a variety of example scripts that you can look at here:
https://github.com/llvm/llvm-project/tree/main/lldb/examples/python
There's an on-line version of the Python API help here:
https://lldb.llvm.org/python_api.html
and you can access the same information from within lldb by doing:
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> help(lldb)
Help on package lldb:
NAME
lldb
FILE
/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py
DESCRIPTION
...
Upvotes: 2