在SBCL中使用步进器的一个简单示例

时间:2011-12-23 14:14:29

标签: debugging lisp common-lisp sbcl stepper

使用LispWorks步进器进行计算是相当直观的,但我无法在SBCL中找到它。有人可以给我一个如何在REPL中使用SBCL步进器的一些简单函数的分步示例吗?感谢。

1 个答案:

答案 0 :(得分:23)

* (proclaim '(optimize (debug 3)))

* (defun foo (a b) (* (+ a b) b))

FOO
* (step (foo 1 2))
; Evaluating call:
;   (FOO 1 2)
; With arguments:
;   1
;   2

1] step
; Evaluating call:
;   (+ A B)
; With unknown arguments

0] step
; Evaluating call:
;   (* (+ A B) B)
; With unknown arguments

0] step
; (FOO 1 2) => 6

命令:

Stepping:
  START Selects the CONTINUE restart if one exists and starts
        single-stepping. Single stepping affects only code
        compiled with under high DEBUG optimization quality.
        See User Manual for details.
  STEP  Steps into the current form.
  NEXT  Steps over the current form.
  OUT   Stops stepping temporarily, but resumes it when the topmost
        frame that was stepped into returns.
  STOP  Stops single-stepping.

请参阅SBCL手册:single stepping