Chapter 4: Debugging
Tracing causes actions to be taken when a function is called and when it returns. The default tracing actions print the function name and arguments when the function is called and print the values returned when the function returns.
Other actions can be specified. These include entering a break loop when the function is entered or exited, or stepping the function.
Note that self-recursive function calls are normally compiled inline. In order to be able to trace such calls, the function must be declared not-inline.
? (defun fact (num)
(declare (notinline fact))
(if (= num 0)
1
(* num (fact (- num 1)))))
FACT
Here the trace macro is used on fact:
?(trace fact)NIL ?(fact 5) Calling (FACT 5) Calling (FACT 4) Calling (FACT 3) Calling (FACT 2) Calling (FACT 1) Calling (FACT 0) FACT returned 1 FACT returned 1 FACT returned 2 FACT returned 6 FACT returned 24 FACT returned 120 120
To turn trace off, use untrace on the same function:
? (untrace fact)(FACT)
The Trace window is accessible through the Trace... command on the Tools menu. It shows you which functions are currently being traced, and lets you select functions to trace with a number of options. For example, it lets you easily choose methods to trace within a generic function.
Generated with Harlequin WebMaker