3.1 About the Debugger
3.1.3 Using the debugging tools
The debugger is only one of the debugging tools provided by Liquid Common Lisp. While a single section cannot describe how to recover from every kind of error that could occur in a program, the following procedures briefly describe how to use Liquid Common Lisp debugging tools to correct errors:- If your program signals an error while it is running, you might automatically enter the Debugger. You can then use the Debugger to examine the state of Lisp and to correct the error without stopping the program. The Debugger commands to examine the stack and to check the values of local variables are especially useful. Often you will discover an error that you must correct in the program's source code.
- If your program runs but produces the wrong answer or behaves unexpectedly, you can use a variety of techniques:
- To stop the execution of a program at places where you believe an error might be occurring, use breakpoints to explicitly enter the Debugger. You can set a breakpoint by calling the function
break
. - To check whether functions are being called in the right circumstances or whether the correct arguments are being passed, use the Tracer (see Chapter 4, "Debugging Tools").
- To examine the performance of a function that might contain an error, use the Stepper, which performs an evaluation one step at a time (see Chapter 4, "Debugging Tools"). The Stepper and the Tracer are especially useful for checking recursive functions.
- To examine or change a data structure's components, use the Inspector (see Chapter 4, "Debugging Tools").
- To examine the flow of program control, use print statements or comment out portions of code.
- If your program runs but never returns to the top level, use the keyboard interrupt to stop the loop and enter the Debugger. You can then use the backtrace command (
:b
) and other Debugger commands to locate and correct the error.
Entry into the Debugger is often caused by simple typing errors, such as typing a function name incorrectly, or by other common mistakes, such as typing too many or too few parentheses. Such common errors include the following:- calling a function with the wrong number of arguments
- calling a function with an inappropriate argument, such as calling the function
car
with an argument that is not a list or calling the function+
with a symbol as an argument - using a global variable before its value has been set
- using a local variable before it has been bound, which often causes Lisp to treat the unbound variable as a special variable
Note: To simplify the discussion about the Debugger, this chapter refers to all exceptional situations that invoke the Debugger as errors. Not every exceptional situation is an error, however, nor does every exceptional situation invoke the Debugger.
The User's Guide - 9 SEP 1996 Generated with Harlequin WebMaker