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 "). 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 " 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, (” +
“logging.log(frame, bp_loc, (” +
Thanks much in advance …
logging.py (2.25 KB)