3.3.3 Examining and moving through the stack

3.3.3.2 Displaying stack frames

You can examine a stack frame by moving to that frame and displaying the function associated with the frame. The Debugger provides the following commands to display stack frames:

The following example calls the previously defined functionsquare 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 <- EVAL

The stack contains the following functions:

Note that the arrows between the function names point toward the top of the stack. The function to the right of an arrow is the calling function; the function to the left is the called function. Thus, the functioneval 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 forsquare 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)

-> :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 >

Once a correct value has been supplied to the function, the function call is completed and a value is returned.


The User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker