There are a number of options available when using the trace facilities, which allow you both to restrict or expand upon the information printed during a trace. For instance, you can restrict tracing of a function to a particular process, or specify additional actions to be taken on function call entry and exit.
Note that the options and values available only apply to a particular traced function. Each traced function has its own, independent, set of options.
This section describes the options that are available. Each option can be set as described in the next subsection.
Here is an example of its use.
*traced-arglist* is bound to the list of arguments given to the function being traced. In this example, it is used to accumulate a list of all the arguments to
fac across all iterations.
(setq args-in-reverse ())
facfunction used earlier, set the value of
(trace (fac :before ((push (car *traced-arglist*) args-in-reverse))))
This option is used in exactly the same way as
:before. For instance, using the example for
:before as a basis, create a list called
results-in-reverse, and set the value of
:after so that
(car *traced-results*) is pushed onto this list. After calling
results-in-reverse contains the results returned from
fac, in reverse order.
This option allows you to supply a list of forms for evaluation upon entering the traced function. The forms are evaluated after printing out the arguments to the function, but unlike
:before their results are not printed.
This option allows you to supply a list of forms for evaluation upon leaving the traced function. The forms are evaluated after printing out the results of the function call, but unlike
:after their results are not printed.
If form evaluates to non-nil, the debugger is entered directly from trace. If it returns
nil, tracing continues as normal. This option lets you force entry to the debugger by supplying a form as simple as
:break, this option allows you to enter the debugger from trace. It differs in that the debugger is entered
the function call is complete.
:bq debugger command.
:b debugger command.
:b :verbose debugger command.
:bug-form debugger command.
This option controls the printing of information on entry to a traced function. form is evaluated upon entry to the function, and information is printed if and only if form evaluates to
t. This allows you to turn off printing of function entry information by supplying a form
nil, as in the example below.
This option controls the printing of information on exit from a traced function. form is evaluated upon exit from the function, and, like
:entrycond, information is printed if and only if form evaluates to a non-nil value. This allows you to turn off printing of function exit information by supplying a form
facfunction, set the values of
CL-USER 24 > (fac 10)
This option allows you to direct trace output to a stream other than the listener in which the original function call was made. By using this you can arrange to dispatch traced output from different functions to different places.
:trace-outputoption for the function
facfunction, and then close the file stream as follows:
This lets you restrict tracing of a function to a particular process. If process evaluates to
t, then the function is traced from within all processes (this is the default). Otherwise, the function is only traced from within the process that process evaluates to.
This lets you invoke the tracing facilities on a traced function selectively. Before each call to the function, form is evaluated. If form evaluates to
nil, no tracing is done. The contents of *traced-arglist* can be examined by form to find the arguments given to trace.
If form is non-nil, this prints the memory allocation, in bytes, made during a function call. The symbol that form evaluates to is used to accumulate the amount of memory allocated between entering and exiting the traced function.
facfunction, set the value of
fac, and then evaluate
The functions given in the argument to
:inside should reference the traced function in their implementation. The traced function is then only traced in calls to any function in the list of functions, rather than in direct calls to itself.
fac2, which calls
fac, as follows:
facfunction, set the value of
(trace (fac :inside fac2))
fac, and notice that no tracing information is produced.
fac2, and notice the tracing information.
LispWorks User Guide and Reference Manual - 20 Sep 2017