-
-
Notifications
You must be signed in to change notification settings - Fork 140
Clojure nREPL CIDER debugger
The CIDER debugger support inside Conjure is very rough and minimal. It has the bare bones set of features to let you inspect things but it’s not intended to be particularly pretty or smooth. This role will be filled by Olical/clojure-dap in the near future.
We initialise the debugger by running :ConjureCljDebugInit inside a Clojure buffer connected to a CIDER enabled nREPL.
Once done, you can add #break tags into your code where you would like it to pause. Once done, re-evaluate the code with the new #break tags like so:
(defn add
"Hello, World!
This is a function."
[a b]
#break (+ a b))Now evaluate that code by invoking it with (add 1 2). This should pause the REPL and print something like this:
; --------------------------------------------------------------------------------
; CIDER debugger
; Respond with :ConjureCljDebugInput [input]
; Inputs: continue, locals, inspect, trace, here, continue-all, next, out, inject, inspect-prompt, quit, in, evalAs the output shows, we can inspect a specific value by executing :ConjureCljDebugInput inspect-prompt then entering the name of a value we’re interested in at the following prompt, such as b. It will then print information about the value you asked about.
We can print the current value and information about it with :ConjureCljDebugInput inspect or the locals with :ConjureCljDebugInput locals, which looks like the output below.
; --------------------------------------------------------------------------------
; CIDER debugger
; Class: clojure.lang.PersistentArrayMap
; Contents:
; a = 1
; b = 2
;
; Respond with :ConjureCljDebugInput [input]
; Inputs: continue, locals, inspect, trace, here, continue-all, next, out, inject, inspect-prompt, quit, in, evalNot all features will work correctly, this is a best effort approach and just a stop gap until the DAP system is ready to go.