Benjamin Kreuter <
brk...@virginia.edu> writes:
> On Sun, 30 Sep 2012 15:56:41 -0700 (PDT)
> "Yves S. Garret" <
yoursurr...@gmail.com> wrote:
>
>> Hello,
>>
>> I went through the following tutorial in the bottom link:
>>
http://www.cliki.net/TutorialClispDebugger
>>
>> It's all well and good, but I remember in my gdb days where I could
>> step through the code and examine all of the variables as I went
>> through each function. Maybe I missed it in the above tutorial, but
>> how could I do this?
>
> There is "step" in the standard. I use sbcl and not clisp, but just as
> an example:
Unfortunately, ccl doesn't implement CL:STEP.
Fortunately, there's an implementation independant cl-stepper in:
https://gitorious.org/com-informatimago/com-informatimago/trees/master/common-lisp/lisp
cl-user> (ql:quickload :com.informatimago.common-lisp.lisp.stepper)
To load "com.informatimago.common-lisp.lisp.stepper":
Load 1 ASDF system:
com.informatimago.common-lisp.lisp.stepper
; Loading "com.informatimago.common-lisp.lisp.stepper"
[package com.informatimago.common-lisp.lisp.stepper.internal]
[package com.informatimago.common-lisp.lisp.stepper].
......
(:com.informatimago.common-lisp.lisp.stepper)
cl-user> (defpackage :test (:use :cl-stepper))
#<package "TEST">
cl-user> (in-package :test)
#<package "TEST">
test> (defun fact (x) (if (= x 1) 1 (* x (fact (1- x)))))
fact
test> (step (fact 5))
(Will evaluate (fact 5)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (fact 5)
(Will evaluate 5
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(--> 5))
(Entering function fact
(Bind x to 5)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(Will evaluate (if (= x 1) 1 (* x (fact #)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (= x 1)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 5))
(Will evaluate 1
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(--> 1))
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (* x (fact (1- x)))
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 5))
(Will evaluate (fact (1- x))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (fact (1- x))
(Will evaluate (1- x)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (1- x)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 5))
Evaluation of (1- x) returned one result ==> 4)
(Entering function fact
(Bind x to 4)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(Will evaluate (if (= x 1) 1 (* x (fact #)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (= x 1)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 4))
(Will evaluate 1
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(--> 1))
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (* x (fact (1- x)))
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 4))
(Will evaluate (fact (1- x))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (fact (1- x))
(Will evaluate (1- x)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (1- x)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 4))
Evaluation of (1- x) returned one result ==> 3)
(Entering function fact
(Bind x to 3)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(Will evaluate (if (= x 1) 1 (* x (fact #)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?t
Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
(x ==> 3)
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
(x ==> 3)
(Will evaluate (fact (1- x))
(Will evaluate (1- x)
(x ==> 3)
Evaluation of (1- x) returned one result ==> 2)
(Entering function fact
(Bind x to 2)
(Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
(x ==> 2)
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
(x ==> 2)
(Will evaluate (fact (1- x))
(Will evaluate (1- x)
(x ==> 2)
Evaluation of (1- x) returned one result ==> 1)
(Entering function fact
(Bind x to 1)
(Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
(x ==> 1)
Evaluation of (= x 1) returned one result ==> t)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 1)
Exiting function fact returned one result ==> 1)
Evaluation of (fact (1- x)) returned one result ==> 1)
Evaluation of (* x (fact (1- x))) returned one result ==> 2)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 2)
Exiting function fact returned one result ==> 2)
Evaluation of (fact (1- x)) returned one result ==> 2)
Evaluation of (* x (fact (1- x))) returned one result ==> 6)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 6)
Exiting function fact returned one result ==> 6)
Evaluation of (fact (1- x)) returned one result ==> 6)
Evaluation of (* x (fact (1- x))) returned one result ==> 24)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 24)
Exiting function fact returned one result ==> 24)
Evaluation of (fact (1- x)) returned one result ==> 24)
Evaluation of (* x (fact (1- x))) returned one result ==> 120)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 120)
Exiting function fact returned one result ==> 120)
Evaluation of (fact 5) returned one result ==> 120)
120
test>
--
__Pascal Bourguignon__
http://www.informatimago.com/
A bad day in () is better than a good day in {}.