[lldb-dev] Syntax/documentation on continuing from a breakpoint in a one-line python script

Randy Smith via lldb-dev lldb-dev at lists.llvm.org
Thu Sep 8 11:23:03 PDT 2016


I've been playing around with lldb and customization in python recently,
and the interface seems unclear and/or broken around continuing from a
breakpoint when using a one-line python script ("breakpoint command add -s
python -o <one-liner>").  The documentation isn't clear about whether this
works with a one liner (It says both "Your Python code, however organized,
can optionally return a value.  If the returned value is False, that tells
LLDB not to stop at the breakpoint to which the code is associated." and
"Single line breakpoint commands will be interpreted 'as is' when the
breakpoint is hit.  Multiple lines of Python will be wrapped in a generated
function, and a call to the function will be attached to the breakpoint.")
and my experiments have suggested that it can't (neither an expression that
returns False nor an explicit "return <False>" seem to work).

Is this expected to work?  Should the documentation be cleared up?

(In case anyone wants to help with the background problem I'm trying to
solve: I'm trying to write some generic logging code that can be attached
to a breakpoint, so that I can log variable values at particular locations
without repeatedly recompiling the program.  So I'm trying to have a
command that creates a breakpoint at a location that prints different
variables and then continues.  I couldn't find a way to have the python
code enter multiple lines of commands attached to a breakpoint (hence the
one-liner).  From the doc it looked like I could set a python callback to
be called when the breakpoint was hit and do everything in python, but I
couldn't find any documentation on how to use
SBBreakpoint::BreakpointHitCallback.
I can't just attach a python function directly to the breakpoint
(--python-function) because the function has to vary depending on what
variables you want to trace.

I've attached my python module to make this clear.  The "experiments" I
refer to above are whether the text on line 58 is

"return logging.log(frame, bp_loc, (" +

or

"logging.log(frame, bp_loc, (" +

).

Thanks much in advance ...

-- Randy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160908/316c1eff/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logging.py
Type: text/x-python-script
Size: 2308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160908/316c1eff/attachment-0001.bin>


More information about the lldb-dev mailing list