Next: Single Stepping, Previous: Information Commands, Up: Debugger
The tracer causes selected functions to print their arguments and their results whenever they are called. Options allow conditional printing of the trace information and conditional breakpoints on function entry or exit.
trace
{Option Global-Value}* {Name {Option Value}*}*
trace
is a debugging tool that provides information when specified functions are called. In its simplest form:(TRACE NAME-1 NAME-2 ...)The NAMEs are not evaluated. Each may be a symbol, denoting an individual function, or a string, denoting all functions fbound to symbols whose home package is the package with the given name.
Options allow modification of the default behavior. Each option is a pair of an option keyword and a value form. Global options are specified before the first name, and affect all functions traced by a given use of
trace
. Options may also be interspersed with function names, in which case they act as local options, only affecting tracing of the immediately preceding function name. Local options override global options.By default,
trace
causes a printout on*trace-output*
each time that one of the named functions is entered or returns. (This is the basic,ansi
Common Lisp behavior oftrace
.) As ansbcl
extension, the:report
sb-ext:profile
option can be used to instead cause information to be silently recorded to be inspected later using thesb-ext:profile
function.The following options are defined:
:report
Report-Type- If Report-Type is
trace
(the default) then information is reported by printing immediately. If Report-Type issb-ext:profile
, information is recorded for later summary by calls tosb-ext:profile
. If Report-Type isnil
, then the only effect of the trace is to execute other options (e.g.:condition
Form:condition-after
Form:condition-all
Form- If
:condition
is specified, thentrace
does nothing unless Form evaluates to true at the time of the call.:condition-after
is similar, but suppresses the initial printout, and is tested when the function returns.:condition-all
tries both before and after. This option is not supported with:report
profile
.:break
Form:break-after
Form:break-all
Form- If specified, and Form evaluates to true, then the debugger is invoked at the start of the function, at the end of the function, or both, according to the respective option.
:print-after
Form:print-all
Form- In addition to the usual printout, the result of evaluating Form is printed at the start of the function, at the end of the function, or both, according to the respective option. Multiple print options cause multiple values to be printed.
:wherein
Names- If specified, Names is a function name or list of names.
trace
does nothing unless a call to one of those functions encloses the call to this function (i.e. it would appear in a backtrace.) Anonymous functions have string names like "DEFUN FOO". This option is not supported with:report
profile
.:encapsulate
{:DEFAULT |t
| NIL}- If
t
, the tracing is done via encapsulation (redefining the function name) rather than by modifying the function.:default
is the default, and means to use encapsulation for interpreted functions and funcallable instances, breakpoints otherwise. When encapsulation is used, forms are *not* evaluated in the function's lexical environment, butsb-debug:arg
can still be used.:methods
{T | NIL}- If
t
, any function argument naming a generic function will have its methods traced in addition to the generic function itself.:function
Function-Form- This is a not really an option, but rather another way of specifying what function to trace. The Function-Form is evaluated immediately, and the resulting function is instrumented, i.e. traced or profiled as specified in
report
.
:condition
,:break
andsb-debug:var
andsb-debug:arg
can be used. The-after
and-all
forms are evaluated in the null environment.
Remove tracing from the specified functions. With no args, untrace all functions.
If the trace indentation exceeds this value, then indentation restarts at 0.