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
of 0.12.0. You’ve always been able to debug functions by adding a #dbg in
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 for one
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?
Conditional breakpoints in the CIDER Debugger
07 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 of
0.12.0
. You’ve always been able to debug functions by adding a#dbg
in 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 thatfor
one 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 asi ≤ 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?
Tags: debugging, clojure, emacs,
A small improvement to clj-refactor »
« Commands to thread and unwind code in Emacs-Lisp
Related Posts
A small improvement to clj-refactor in clojure
Update on tdd-mode with CIDER in clojure
Test-Driven-Development in CIDER and Emacs in clojure
Content © 2019, All rights reserved. Icons under CC3.0.