Debugging requires focus. Small annoyances can be distracting and delay the whole process. Yesterday, partly as an experiment and partly out of necessity, I started a new project to help us with debugging: MCSLLDBToolkit – a set of handy LLDB commands.
The main inspiration behind MCSLLDBToolkit was Facebook’s Chisel. I wanted something simpler and more pythonic, though, so I started from scratch and ended up writing helpers that make creating and registering custom LLDB commands as easy as adding a decorator to a Python function.
The first command I implemented displays nicely formatted and colored JSON in Quick Look. JSON is used in a wide variety of places: it is retrieved from web APIs, loaded from config files, stored in local databases, etc. Regardless of where it comes from, it is always easier to read when properly indented, colored, and formatted, with keys in alphabetical order. Line numbering can also prove useful, especially when comparing subsequent JSON responses while tweaking request parameters.
At the moment,
json is our sole custom command – after all, the project started only yesterday afternoon. We have a few ideas for future commands and I’m sure some will come up naturally as we encounter problems – which we now know can be solved by extending LLDB. If you, dear Reader, would like to help us move the project forward, don’t hesitate, just send us a pull request on GitHub.