On this page:
1.8.1 Debugger Buttons
1.8.2 Definitions Window Actions
1.8.3 Stack View Pane
1.8.4 Debugging Multiple Files

1.8 Graphical Debugging Interface

Tip: Changing the name of a file in the middle of a debugging session will prevent the debugger from working properly on that file.

Like the Run button, the Debug button runs the program in the definitions window. However, instead of simply running it from start to finish, it lets users control and observe the program as it executes. The interface includes a panel of buttons above the definitions window, as well as extensions to the definitions window itself.

The program starts out paused just before the first expression is executed. This is indicated in the definitions window by the presence of a green triangle over this expression’s left parenthesis.

1.8.1 Debugger Buttons

While execution is paused, several buttons are available:

If the program is running (not paused), then only the Pause button will be enabled. Clicking it will interrupt execution and pause it. In this case, the current expression may only be known approximately, and it will be represented as a gray triangle. The other features described above will still be available.

At any time, execution may be interrupted by clicking the Stop button. However, unlike with the Pause button, stopped execution cannot be continued.

1.8.2 Definitions Window Actions

When execution is paused, the definitions window supports several additional actions:

1.8.3 Stack View Pane

In addition, while execution is paused, the stack view pane at the right of the DrRacket frame is active. The top of the pane shows a list of active stack frames. Mousing over a frame produces a faint green highlighting of the corresponding expression. Clicking on the frame selects that frame, which makes its lexical variables visible. The selected frame is indicated by a bold font.

The bottom of the pane shows the lexical variables in the selected stack frame.

The following screenshot illustrates several aspects of the debugger interface. The red circle in the body of for/sum is a breakpoint, and the green triangle at the end of the (+ i n) is where execution is currently paused. The expression’s return value is displayed at the left of the button bar, and the value of i and other variables are displayed in the stack view pane.

1.8.4 Debugging Multiple Files

To debug a program that spans several files, make sure that all of the files are open in DrRacket. Click the Debug button in the window containing the main program. As this program loads additional files that are present in other windows or tabs, message boxes will pop up asking whether or not to include the file in the debugging session. Including the file means that it will be possible to set breakpoints, inspect variables, and single-step in that file.

Tip: A file may only be involved in one debugging session at a time. If you try to debug a file that loads another file that is already being debugged, a message box will pop up explaining that the file cannot be included in another debugging session.