[slime-devel] Debugging variables
Helmut Eller
heller at common-lisp.net
Tue Apr 27 15:05:06 UTC 2010
* Zadirion Fay [2010-04-27 16:26+0200] writes:
> Hello,
>
> I am new to slime and Lisp in general. I did try searching google before
> posting this but I can not seem to find any answer to this, so here goes:
>
> (defun sample-function (x y)
> (if (> (+ x y) 15)
> (+ x y)
> (error "The sum of x and y must be greater than 15")))
>
> (sample-function 3 4)
>
> Given the above code, I can not seem to be able to display the value of x or
> y for that matter once the debugger kicks in on the line with the error.
> Once inside the debugger, I tried pressing 'i' for inspect and entered x.
> Debugger replied with "unbound variable x blabla". Pressed 'e' for eval and
> wrote (sb-debug:var x) with
> same result (using sbcl here).
The simplest way to see all local variables for a frame is to press
RETURN (or t) on that line. After that your example that would look like:
Backtrace:
0: (sample-function 3 4)
Locals:
x = 3
y = 4
1: (sb-int:simple-eval-in-lexenv (sample-function 3 4) #<NULL-LEXENV>)
The compiler could also optimize things away since x and y aren't used
after the call to ERROR. In that case you can play with different
optimize settings or simply write the error message so that it includes
the info you want to know:
(error "The sum of x (~d) and y (~d) must be greater than 15" x y)
Helmut
More information about the slime-devel
mailing list