Previous: Debugging Aids, Up: Debugging
Giving advice to procedures is a powerful debugging technique.
trace
and break
are useful examples of advice-giving
procedures.
Note that the advice system only works for interpreted procedures.
Causes an informative message to be printed whenever procedure is entered. The message is of the form
[Entering #[compound-procedure 1 foo] Args: val1 val2 ...]where val1, val2 etc. are the evaluated arguments supplied to the procedure.
(trace-entry fib) (fib 3) -| [Entering #[compound-procedure 19 fib] -| Args: 3] -| [Entering #[compound-procedure 19 fib] -| Args: 1] -| [Entering #[compound-procedure 19 fib] -| Args: 2] => 3
Causes an informative message to be printed when procedure terminates. The message contains the procedure, its argument values, and the value returned by the procedure.
(trace-exit fib) (fib 3) -| [1 -| <== #[compound-procedure 19 fib] -| Args: 1] -| [2 -| <== #[compound-procedure 19 fib] -| Args: 2] -| [3 -| <== #[compound-procedure 19 fib] -| Args: 3] => 3
Equivalent to calling both
trace-entry
andtrace-exit
on procedure.trace
is the same astrace-both
.(trace-both fib) (fib 3) -| [Entering #[compound-procedure 19 fib] -| Args: 3] -| [Entering #[compound-procedure 19 fib] -| Args: 1] -| [1 -| <== #[compound-procedure 19 fib] -| Args: 1] -| [Entering #[compound-procedure 19 fib] -| Args: 2] -| [2 -| <== #[compound-procedure 19 fib] -| Args: 2] -| [3 -| <== #[compound-procedure 19 fib] -| Args: 3] => 3
Stops tracing the entry of procedure. If procedure is not given, the default is to stop tracing the entry of all entry-traced procedures.
Stops tracing the exit of procedure. If procedure is not given, the default is all exit-traced procedures.
Stops tracing both the entry to and the exit from procedure. If procedure is not given, the default is all traced procedures.
Like
trace-entry
with the additional effect that a breakpoint is entered when procedure is invoked. Both procedure and its arguments can be accessed by calling the procedures*proc*
and*args*
, respectively. Userestart
orcontinue
to continue from a breakpoint.
Like
trace-exit
, except that a breakpoint is entered just prior to leaving procedure. Procedure, its arguments, and the result can be accessed by calling the procedures*proc*
,*args*
, and*result*
, respectively. Userestart
orcontinue
to continue from a breakpoint.
Sets a breakpoint at the beginning and end of procedure. This is
break-entry
andbreak-exit
combined.
Discontinues the entering of a breakpoint on the entry to and exit from procedure. If procedure is not given, the default is all breakpointed procedures.
Discontinues the entering of a breakpoint on the entry to procedure. If procedure is not given, the default is all entry-breakpointed procedures.
Discontinues the entering of a breakpoint on the exit from procedure. If procedure is not given, the default is all exit-breakpointed procedures.
The following three procedures are valid only within the dynamic extent of a breakpoint. In other words, don't call them unless you are stopped inside a breakpoint.
Returns the arguments to the procedure in which the breakpoint has stopped. The arguments are returned as a newly allocated list.
Returns the result yielded by the procedure in which the breakpoint has stopped. This is valid only when in an exit breakpoint.
The following procedures install advice procedures that are called when the advised procedure is entered or exited. An entry-advice procedure must accept three arguments: the advised procedure, a list of the advised procedure's arguments, and the advised procedure's application environment (that is, the environment in which the procedure's formal parameters are bound). An exit-advice procedure must accept four arguments: the advised procedure, a list of the advised procedure's arguments, the result yielded by the advised procedure, and the advised procedure's application environment.
Note that the trace and breakpoint procedures described above are all implemented by means of the more general advice procedures, so removing advice from an advised procedure will also remove traces and breakpoints.
Advice must be an entry-advice procedure. Advice is attached to procedure, so that whenever procedure is entered, advice is called.
Advice must be an exit-advice procedure. Advice is attached to procedure, so that whenever procedure returns, advice is called.
Returns the advice procedures, if any, that are attached to procedure. This is returned as a list of two lists: the first list is all of the entry-advice procedures attached to procedure, and the second is all of the exit-advice procedures.
Removes all entry-advice procedures from procedure. If procedure is not given, the default is all entry-advised procedures.