Common LISP自帶單步跟蹤功能,執行 (step 要跟蹤的命令)便可。以sdraw爲例,跟蹤其執行。函數
【1】啓動單步跟蹤this
SDRAW[60]> (step (sdraw '(a (b c d) c)))lua
step 1 --> (SDRAW '(A (B C D) C)) 顯示下一個要執行的語句spa
Step 1 SDRAW[61]> 等待用戶輸入調試指令調試
【2】輸入help查看幫助,幫助的內容不少,前面一大段和Debug是同樣的。經常使用的指令有四個,Step表示進入表達式內部;Next表示快速執行當前表達式,並移到下一個表達式;Over表示從表達式返回,能夠理解爲從函數返回;Continue表示結束單步跟蹤狀態,快速執行完整個程序。注意一下,不是直接輸入step等命令,而是輸入簡寫「冒號加首字母」。orm
Step 1 SDRAW[61]> help ci
Step :s step into form: evaluate this form in single step modeit
Next :n step over form: evaluate this form at onceio
Over :o step over this level: evaluate at once up to the next returnform
Continue :c switch off single step mode, continue evaluation
-- Step-until :su, Next-until :nu, Over-until :ou, Continue-until :cu --
same as above, specify a condition when to stop
【3】執行幾步看看
Step 1 SDRAW[61]> :s 進入函數調用內部
step 2 --> '(A (B C D) C) 進入函數前,要求值每個參數
Step 2 SDRAW[62]> :s
step 2 ==> value: (A (B C D) C) 顯示上一條命令的執行結果
step 2 --> NIL 表達式是一個樹狀結構,這個分支已經沒有命令了,顯示爲空
Step 2 SDRAW[63]> :s
step 2 ==> value: NIL 上一個表達式爲空,執行結果也爲空
step 2 --> 下面是函數sdraw的、複雜的實現,不少內容省掉了
(LET ((*SDRAW-CIRCULAR-SWITCH* #) (START-COL #)) (INIT-STRUCT1 START-COL)
(CLRHASH *CIRC-HASH-TABLE*) ...)
Step 2 SDRAW[64]>
【4】任什麼時候候均可以查看變量的內容,輸入變量名便可,也能夠執行其餘的表達式
【5】若是輸入了錯誤的命令,會進入Debug狀態,輸入ctrl+d能夠退出Debug狀態