Expression-based debugger for clojure code
Expression-based debugger for clojure code
Reader macros like #dbg which cause code to be instrumented when present.
Reader macros like #dbg which cause code to be instrumented when present.
Map used to determine whether to skip a breakpoint.
Don't set or examine this directly, it is bound in the session binding map,
use skip-breaks! and skip-breaks? instead. Its value is reset at the
beginning each eval session.
Map used to determine whether to skip a breakpoint. Don't set or examine this directly, it is bound in the session binding map, use `skip-breaks!` and `skip-breaks?` instead. Its value is reset at the beginning each eval session.
(apply-instrumented-maybe var-fn args coor STATE__)Apply var-fn or its instrumented version to args.
Apply var-fn or its instrumented version to args.
(break coor val locals STATE__)Breakpoint function.
Send the result of form and its coordinates to the client and wait for
response with read-debug-command'.
Breakpoint function. Send the result of form and its coordinates to the client and wait for response with `read-debug-command`'.
(break-on-exception-reader form)#exn reader. Wrap form in try-catch and break only on exception
#exn reader. Wrap `form` in try-catch and break only on exception
(breakpoint form {:keys [coor] :as dbg-state} original-form)Wrap form in a breakpoint unconditionally.
Wrap form in a breakpoint unconditionally.
(breakpoint-if-exception form dbg-state original-form)Wrap form in a try-catch that has breakpoint on exception.
Used as :breakfunction in tag-form.
Wrap form in a try-catch that has breakpoint on exception. Used as :breakfunction in `tag-form`.
(breakpoint-if-exception-with-initial-debug-bindings form
dbg-state
original-form)(breakpoint-if-interesting form dbg-state original-form)Wrap form in a breakpoint if it looks interesting.
Uninteresting forms are symbols that resolve to clojure.core
(taking locals into account), and sexps whose head is present in
irrelevant-return-value-forms. Used as :breakfunction in tag-form.
Wrap form in a breakpoint if it looks interesting. Uninteresting forms are symbols that resolve to `clojure.core` (taking locals into account), and sexps whose head is present in `irrelevant-return-value-forms`. Used as :breakfunction in `tag-form`.
(breakpoint-if-interesting-with-initial-debug-bindings form
dbg-state
original-form)(breakpoint-reader form)#break reader. Mark form for breakpointing.
#break reader. Mark `form` for breakpointing.
(breakpoint-with-initial-debug-bindings form dbg-state original-form)An unsorted set of commands supported by the debugger.
An unsorted set of commands supported by the debugger.
(debug-on-exception-reader form)#dbgexn reader. Mark all forms in form for breakpointing on exception.
form itself is also marked.
#dbgexn reader. Mark all forms in `form` for breakpointing on exception. `form` itself is also marked.
(debug-reader form)#dbg reader. Mark all forms in form for breakpointing.
form itself is also marked.
#dbg reader. Mark all forms in `form` for breakpointing. `form` itself is also marked.
Message used to communicate with the client. Stored by the
"init-debugger" op, and used by read-debug-input to ask for debug input through
the :need-debug-input status.
Message used to communicate with the client. Stored by the "init-debugger" op, and used by `read-debug-input` to ask for debug input through the :need-debug-input status.
(debugger-send & r)Send a response through debugger-message.
Send a response through debugger-message.
(expand-break form {:keys [coor]} original-form)Internal macro to avoid code repetition in breakpoint-if-interesting.
Internal macro to avoid code repetition in `breakpoint-if-interesting`.
(instrument-var-for-step-in v)Attach an instrumented version of the function in v as metadata to v,
leaving the contents of the var uninstrumented.
Attach an instrumented version of the function in `v` as metadata to `v`, leaving the contents of the var uninstrumented.
Set of special-forms whose return value we don't care about. When instrumenting, these will not be wrapped in a breakpoint.
Set of special-forms whose return value we don't care about. When instrumenting, these will not be wrapped in a breakpoint.
(looks-step-innable? form)(looks-step-innable? &env form)Decide whether a form looks like a call to a function that we could
instrument and step into.
You should prefer the second arity with the &env argument
to handle a local shadowing correctly.
Decide whether a form looks like a call to a function that we could instrument and step into. You should prefer the second arity with the `&env` argument to handle a local shadowing correctly.
(pr-short x)Like pr-str but limited in length and depth.
Like `pr-str` but limited in length and depth.
Map atom holding all unprocessed debug inputs.
This is where the "debug" op stores replies received for debug
input requests. read-debug-input will halt until it finds its input in
this map (identified by a key), and will dissoc it afterwards.
Map atom holding all unprocessed debug inputs. This is where the "debug" op stores replies received for debug input requests. `read-debug-input` will halt until it finds its input in this map (identified by a key), and will `dissoc` it afterwards.
(read-debug-command coor value locals STATE__)Read and take action on a debugging command.
Ask for one of the following debug commands using read-debug-input:
next: Return value.
continue: Skip the current breakpoint.
continue-all: Skip breakpoints for the remainder of this eval session.
in: Step into a function
out: Skip breakpoints in the current sexp.
here: Skip all breakpoints up till specified coordinate coord
inspect: Inspect the current expression
inspect-prompt: Prompt for an expression to evaluate and inspect it.
locals: Inspect local variables.
inject: Evaluate an expression and return it.
eval: Evaluate an expression, display result, and prompt again.
stacktrace: Print the current stacktrace, and prompt again.
trace: Continue, printing intermediate expressions and their values.
quit: Abort current eval session.
Response received can be any one of these values. It can also be a map whose :response entry is one of these values, which can thus be used to provide additional parameters. For instance, if this map has a :code entry, its value is used for operations such as :eval, which would otherwise interactively prompt for an expression.
Read and take action on a debugging command. Ask for one of the following debug commands using `read-debug-input`: next: Return value. continue: Skip the current breakpoint. continue-all: Skip breakpoints for the remainder of this eval session. in: Step into a function out: Skip breakpoints in the current sexp. here: Skip all breakpoints up till specified coordinate `coord` inspect: Inspect the current expression inspect-prompt: Prompt for an expression to evaluate and inspect it. locals: Inspect local variables. inject: Evaluate an expression and return it. eval: Evaluate an expression, display result, and prompt again. stacktrace: Print the current stacktrace, and prompt again. trace: Continue, printing intermediate expressions and their values. quit: Abort current eval session. Response received can be any one of these values. It can also be a map whose :response entry is one of these values, which can thus be used to provide additional parameters. For instance, if this map has a :code entry, its value is used for operations such as :eval, which would otherwise interactively prompt for an expression.
(safe-to-debug? ns)Some namespaces are not safe to debug, because doing so can cause a stack overflow that crashes the nrepl process.
Some namespaces are not safe to debug, because doing so can cause a stack overflow that crashes the nrepl process.
(sanitize-env env)Turn a macro's &env into a map usable for binding.
Turn a macro's &env into a map usable for binding.
(skip-breaks! mode)(skip-breaks! mode coor code force?)Set the value of skip-breaks for the top-level breakpoint. Additional arguments depend on mode, and should be:
skip-breaks?.Set the value of *skip-breaks* for the top-level breakpoint. Additional arguments depend on mode, and should be: - empty for :all or :trace - coordinates, code, and force for :deeper or :before See `skip-breaks?`.
(skip-breaks? coor STATE__)True if the breakpoint at coordinates should be skipped.
The *skip-breaks* map stores a mode, coordinates, the code that it
applies to, and a force? flag.
Behaviour depends on the mode:
*skip-breaks*, in the same code*skip-breaks*, in the same codeFor :deeper and :before, if we are not in the same code (i.e. we have stepped
into another instrumented function and code argument doesn't match old code in
skip-breaks), then return the value of force?.
True if the breakpoint at coordinates should be skipped.
The `*skip-breaks*` map stores a `mode`, `coordinates`, the `code` that it
applies to, and a `force?` flag.
Behaviour depends on the `mode`:
- :all - return true, skipping all breaks
- :trace - return false, skip nothing
- :deeper - return true if the given coordinates are deeper than the
coordinates stored in `*skip-breaks*`, in the same code
- :before - return true if the given coordinates represent a place before
the coordinates in `*skip-breaks*`, in the same code
For :deeper and :before, if we are not in the same code (i.e. we have stepped
into another instrumented function and code argument doesn't match old code in
*skip-breaks*), then return the value of `force?`.(step-in? v coor code)Return true if we can and should step in to the function in the var v.
The "should" part is determined by the value in step-in-to-next?, which
gets set to true by the user sending the "step in" command.
Return true if we can and should step in to the function in the var `v`. The "should" part is determined by the value in `step-in-to-next?`, which gets set to true by the user sending the "step in" command.
(try-if-let [sym val] success-expr error-expr)Try binding sym to val end eval success-expr or error-expr on error.
On error send an eval-error message through debugger-message channel.
Try binding `sym` to `val` end eval `success-expr` or `error-expr` on error. On error send an eval-error message through `debugger-message` channel.
(with-initial-debug-bindings & body)Let-wrap body with STATE__ map containing code, file, line, column etc.
STATE__ is an anaphoric variable available to all breakpoint macros. Ends with
__ to avid conflicts with user locals and to signify that it's an internal
variable which is cleaned in `sanitize-env' along other clojure's
temporaries.
Let-wrap `body` with STATE__ map containing code, file, line, column etc. STATE__ is an anaphoric variable available to all breakpoint macros. Ends with __ to avid conflicts with user locals and to signify that it's an internal variable which is cleaned in `sanitize-env' along other clojure's temporaries.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |