3.2 Entering and exiting the Debugger
3.2.1 Entering the Debugger You can enter the Debugger in the following ways:
- You automatically enter the Debugger when an error is signaled during the execution of a program or a system function. Thus, calling a function with the wrong number of arguments or attempting to open a nonexistent file invokes the Debugger if no error-handling code exists for that error.
- You can explicitly enter the Debugger by calling the functions
invoke-debugger. Use these constructs when a function is returning the wrong value and you want to stop the function at certain points to examine the current state of Lisp and the values of local variables.
- For example, the following code invokes the Debugger if the function
add-one is called with an argument that is not a number:
> (defun add-one (x)
(unless (numberp x)
(error "Argument must be a number."))
(+ x 1))
> (add-one 'a)
>>Error: Argument must be a number.
Original code: (NAMED-LAMBDA ADD-ONE (X)
(BLOCK ADD-ONE (UNLESS # #) (+ X 1)))
Required arg 0 (X): A
:A 0: Abort to Lisp Top Level
- You can also explicitly enter the Debugger by typing the keyboard interrupt character that has been defined for your system. Throughout this chapter, the keyboard interrupt character is assumed to be Ctrl-c.
The User's Guide - 9 SEP 1996
Generated with Harlequin WebMaker