Previous: Encapsulation Functions, Up: Function Tracing [Contents][Index]
Here is an example of tracing with some of the possible options. For simplicity, this is the function:
(defun fact (n) (declare (double-float n) (optimize speed)) (if (zerop n) 1d0 (* n (fact (1- n))))) (compile 'fact)
This example shows how to use the :condition option:
(trace fact :condition (= 4d0 (debug:arg 0))) (fact 10d0) -> 0: (FACT 4.0d0) 0: FACT returned 24.0d0 3628800.0d0
As we can see, we produced output when the condition was satisfied.
Here’s another example:
(untrace) (trace fact :break (= 4d0 (debug:arg 0))) (fact 10d0) -> 0: (FACT 5.0d0) 1: (FACT 4.0d0) Breaking before traced call to FACT: [Condition of type SIMPLE-CONDITION] Restarts: 0: [CONTINUE] Return from BREAK. 1: [ABORT ] Return to Top-Level. Debug (type H for help)
In this example, we see that normal tracing occurs until we the argument reaches 4d0, at which point, we break into the debugger.