#
Chapter 8
Stepping and Debugging

DrScheme offers tools for stepping and debugging. The Stepper presents an algebraic view of program execution, more appropriate for students; the Debugger is closer to a comparable tool in a programming environment for professionals.

## 8.1 The Stepper

The Stepper lets users step through each reduction in their program. It uses colors to highlight the redex and the reduct. Users can step backward and forward through the reduction history. This illustrates the algebraic nature of programming.

The Stepper can even handle programs that use images as values.

## 8.2 The Debugger

Using a language that includes all of Scheme, such as Standard or Pretty Big, changes the Step button into one labeled Debug. You can run programs with or without the Debugger enabled. Using Run executes the program normally. Using Debug is like using Run, except program execution incorporates debugging information. The Debugger provides three buttons: Pause, Continue, and Step.

The unit of stepping is a function application. At each Step, DrScheme indicates the expression that is about to execute with a green arrow:

During execution, you can insert a breakpoint. Hover the mouse over an application, and you will see a red highlight:

Right-click (or, on a Macintosh, control-click) on the dot for a menu that lets you add or remove a breakpoint. The Continue button continues execution until the program terminates, reaches a breakpoint, or halts with an error.

The Pause button enables the user to return control to the debugger in the midst of a long-running computation (such as a loop). A right-click (or control-click) on an identifier will, if it is bound in the current execution context, show the value of the identifier and provide the option of modifying its value.