Conditional breakpoints in the CIDER Debugger07 Mar 2016, by Artur Malabarba.
CIDER 0.11.0 has been out for less than week and already the snapshots are
getting new features. This one comes from a gentleman called Chris Perkins. It
provides an easy way to automatically skip some breakpoints during evaluation,
and it even comes with 300 brand new lines of tests.
The feature is very straightforward, and is already available on the snapshots
0.12.0. You’ve always been able to debug functions by adding a
before it and then reevaluating its definition.
However, if you’re trying to debug a problem that only happens somewhere around
i = 1000, then you’re going to have to step through the body of that
thousand times before getting to where you need.
This new feature lets you specify a condition, and the debugger will
automatically skip all breakpoints as long as that condition is false. You
specify it via the
:break/when metadata. In the above example, that would be
something like this.
Thus, everything inside the
(some ...) form would be skipped as long as
i ≤ 1000.
The debugger’s inner workings are not what I’d call simple, so it makes me happy to know I’ve made the code legible enough for people to understand without my help. Of course, it certainly helped that Chris is no average fellow. Did I mention he even wrote a DSL for the new tests?