All Manuals > LispWorks User Guide and Reference Manual > 5 The Trace Facility

NextPrevUpTopContentsIndex

5.1 Simple tracing

This section shows you how to perform simple traces.

  1. Enter this definition of the factorial function fac into the listener:
  2. (defun fac (n)
     (if (= n 1) 1
       (* n (fac (- n 1)))))
  3. Now trace the function by entering the following into the listener.
  4. (trace fac)
  5. Call the function fac as follows:
  6. (fac 3)

    The following trace output appears in the listener.

0 FAC > ...
  >> N : 3
  1 FAC > ...
    >> N : 2
    2 FAC > ...
      >> N : 1
    2 FAC < ...
      << VALUE-0 : 1
  1 FAC < ...
    << VALUE-0 : 2
0 FAC < ...
  << VALUE-0 : 6

Upon entry to each traced function call, trace prints the following information:

Each line is indented according to the level of tracing for the call.

> denotes entry to a function, and >> denotes an argument.

Upon exit from each traced function call, trace prints the following information:

< denotes exit from a function, and << denotes a returned value.

Output produced in this way is always sent to a special stream, *trace-output*, which is either associated with the listener, or with background output.

Calling trace with no arguments produces a list of all the functions currently being traced. In order to cease tracing a function the macro untrace should be called with the function name. All tracing can be removed by calling untrace with no arguments.

CL-USER 5 > (untrace fac)
(FAC)
 
CL-USER 6 > (fac 4)
24
 
CL-USER 7 >

LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex