How to extend and debug pretty printers?

Is there any tutorial about how to extend the pretty printers for lldb? Couldn’t find any yet.
I would also like to know how to debug the pretty printers.

Variable Formatting — The LLDB Debugger has some examples.

The following works with VSCode (install Python extension, install debugpy package, create debug configuration that listens on port 3470):

script import debugpy; debugpy.configure(python='python3'); debugpy.connect(3470)

Something similar should be possible with other IDEs/debuggers.

I usually do this in command-line lldb by inserting:

import pdb; pdb.set_trace()

wherever I want to stop in the formatter. When lldb runs the set_trace() command, the lldb prompt will change to a pdb prompt, and you can walk through the code using pdb commands till it exits (or you do “continue”) and then you will be returned to the lldb prompt. Other hosts of the command interpreter (e.g. VSCode) might not handle this well, however.

1 Like