3.3.3 Examining and moving through the stack
:b
command shows a backtrace, the sequence of function calls from the current frame to the bottom of the stack.:d
command displays the current frame, including the current function name, its arguments, and the original condition description.:v
command verbosely displays the current frame, including the current function name, its arguments, and the values of local variables.:pp
command produces a formatted display of the source code, if any, of the function in the current frame. The function must be interpreted.square
with a symbol as an argument:> (square 'a) >>Error: The value of RESULT, A, should be a NUMBER *: Rest arg 0 (RESTARG): (A A) :C 0: Use a new value :A 1: Abort to Lisp Top Level ->Entering the
:b
command at the Debugger prompt shows the contents of the stack from the current function to the function at the bottom of the stack:-> :b * <- SQUARE <- EVALThe stack contains the following functions:
eval
, the Lisp interpreter, is at the bottom of the stack; that is, it is the first function that was called.square
is the function that you defined.*
, the function that signaled the error, is displayed as the current frame when you enter the Debugger.eval
calls the user-defined functionsquare
, and the functionsquare
calls the Common Lisp function*
. You can move to the frame that contains the call to the functionsquare
and display that frame by using the:n
command:
-> :n SQUARE: Original code: (NAMED-LAMBDA SQUARE (X) (BLOCK SQUARE (* X X))) Required arg 0 (X): A ->To examine the frame and its local variables more closely, use the
:v
command:-> :v SQUARE: Original code: (NAMED-LAMBDA SQUARE (X) (BLOCK SQUARE (* X X))) Required arg 0 (X): A Source code: (BLOCK SQUARE (* X X)) Catch for tag: (#<Return-From-Closure 71A> . SQUARE) ->This stack frame displays the source code for the original function,
square
, the argument tosquare
, the source code for the expression that is currently being evaluated, and a catch. To see a formatted version of the original source code for the functionsquare
, use the:pp
command:
-> :pp (NAMED-LAMBDA SQUARE (X) (BLOCK SQUARE (* X X))) ->Note that the source code for
square
contains references tonamed-lambda
andblock
, which name and group expressions that have been defined as a function by a call todefun
. You can complete the evaluation by moving to the frame that contains the call to the function*
and supplying a valid argument to that function. The following interaction uses the command:d
to redisplay the available restart options and then selects the continue restart option to finish the evaluation. Notice that the new value fora
must be supplied twice, once for the first argument to*
and once for the second argument to*
:
-> :p *: Rest arg 0 (RESTARG): (A A)Once a correct value has been supplied to the function, the function call is completed and a value is returned.-> :d >>Error: The value of RESULT, A, should be a NUMBER *: Rest arg 0 (RESTARG): (A A) :C 0: Use a new value :A 1: Abort to Lisp Top Level
-> 0 Use a new value Value to use instead: 5 >>Error: The value of VAR, A, should be a NUMBER *: Rest arg 0 (RESTARG): (A A) :C 0: Use a new value :A 1: Abort to Lisp Top Level
-> 0 Use a new value Value to use instead: 5 25 >
Generated with Harlequin WebMaker