Line Breakpoints

Let's say we want to step into the function baz on line 11 and can't set a breakpoint on baz itself. This might sound a bit contrived, but it's not that uncommon for a function to get called an unknown number of times, maybe even asynchronously from another thread.

To set a breakpoint on line 11 in example.c, we can use the breakpoint set command or the b alias.

The debugger hits the breakpoint and is stopped at line 11. The step command allows us to step into the function calls on that line. To get to baz, we need to step through foo and bar first. The functions are pretty short, so we can step through them with next or use finish to step out of the current frame. I prefer the latter because it prints the function's return value, if any.

Column Breakpoints

Column breakpoints address the issue of having to step in and out of functions by making it possible to be more precise. With a column breakpoint we can skip over the calls to foo and bar altogether. For our example, the call to baz is located at column 26. To set a column breakpoint, we can either use the b command with a line and column number, or spell it out as breakpoint set -f example.c -l 11 -u 26.

Column breakpoints have been available in LLDB for a while. You can already set them from the SB API in Python. Support for columns in the breakpoint command lagged a bit behind. To use the b file:line:column syntax or to pass -u to breakpoint set, you'll need the latest LLDB from llvm.org.

Column breakpoints are especially convenient in IDEs where you visually select where to set the breakpoint. Line numbers are usually easy enough to spot in an editor, but the column can be a bit more tedious. If you're using Vim, I recommend adding a key binding or leader mapping to yank the current file, line and column number, which you can then paste straight into the debugger.