首页 > 解决方案 > 如何在 Common Lisp ECL 中执行分步调试?

问题描述

我正在使用 ECL 学习 Common Lisp。我尝试参考https://malisper.me/debugging-lisp-part-1-recompilation/的调试方法,但步骤执行没有正常工作。

当我插入“(中断)”并选择“重试”时,处理首先在中断处停止。这是如上页所示的预期行为。

(defun fib (n)
  (break)
  (if (<= 0 n 1)
      (/ 1 0)
      (+ (fib (- n 1))
         (fib (- n 2)))))
Break
   [Condition of type SIMPLE-CONDITION]

下一次我按下 S 键时,显示以下错误消息,即使它应该已被踩。

SWANK/BACKEND: ACTIVATE-STEPPING not implemented
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [ABORT] Return to sldb level 1.
 1: [CONTINUE] Return from BREAK.
 2: [RETRY] ​​Retry SLIME REPL evaluation request.
 3: [* ABORT] Return to SLIME's top level.
 4: [ABORT] ABORT

这在ECL的实现中可能是个问题,但是我想知道在ECL中通常会做什么样的调试。

最好的问候, NOEU

标签: common-lispslimestepperecl

解决方案


一种选择:STEP在 ECL 中。用于:h查看步进器中的命令。

> (defun fib (n)                                                                                                             
    (if (<= 0 n 1)                                                                                                             
        (/ 1 0)                                                                                                                
        (+ (fib (- n 1))                                                                                                       
           (fib (- n 2)))))

FIB
> (step (fib 3))
 (FIB 3) -
 (BLOCK FIB ...) -
 (IF (<= 0 ...) ...) -
 (<= 0 ...) -
 (+ (FIB #) ...) -
 (FIB (- N ...)) -
 (- N ...) -
 (BLOCK FIB ...) -
 (IF (<= 0 ...) ...) -
 (<= 0 ...) -
 (+ (FIB #) ...) -
 (FIB (- N ...)) -
 (- N ...) -
 (BLOCK FIB ...) -
 (IF (<= 0 ...) ...) -
 (<= 0 ...) -
 (/ 1 ...) -

Condition of type: DIVISION-BY-ZERO
#<a DIVISION-BY-ZERO>

Available restarts:

1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.

Broken at FIB. In: #<process TOP-LEVEL 0x104f16f80>.

推荐阅读