Emacsist RSS --- If never, make it ever: C-h C-h

Conditional breakpoints in the CIDER Debugger

7307

这里 查看更多 Emacs 相关推荐文章最新 Emacs 圈的动态. 欢迎关注微信公众账号: Emacsist

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.

#dbg
(defn buggy-function []
  (for [i (range 3000)]
    (some (kinda complicated)
          code (logic) i)))

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.

#dbg
(defn buggy-function []
  (for [i (range 3000)]
    ^{:break/when (> i 1000)}
    (some (kinda complicated)
          code (logic) i)))

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?

原文出处: EndlessParenthese
原文地址: http://endlessparentheses.com/conditional-breakpoints-in-the-cider-debugger.html?source=rss
原文时间: 2016-03-07 08:00
本文地址: http://emacsist.com/10796
整理时间: 2016-03-08 01:41

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .