Reputation: 445
For example, while writing GDB Macros, I can give something like:
list_iterate $arg0
If my list_iterate() function in the C code looks like
list_iterate(list_node *)
In the LLDB Python API, how do I do the same thing, i.e call and execute a function from the C code? I've scoured the documentation but can't seem to find something like this
Upvotes: 1
Views: 796
Reputation: 27110
SBFrame::EvaluateExpression
is the function you want. Something like:
(lldb) script
>>> options = lldb.SBExpressionOptions()
>>> result = lldb.frame.EvaluateExpression('printf("Hello there.\\n");', options)
Hello there.
>>> print result
(int) $1 = 13
Note, if you are writing scripts (or Python commands, etc.) don't use lldb.frame, you can get the selected frame from your process, or if you are writing a command use the form that gets passed an SBExecutionContext. See:
https://lldb.llvm.org/use/python-reference.html
for more details.
Upvotes: 3