A Quick Start Guide to DrJava | ||
---|---|---|
<<< Previous | Advanced Features | Next >>> |
The debugger allows you to step through the execution of a program and stop at any point you choose so that you can track down bugs in your code. What makes our debugger an unusually powerful tool is that it allows you to modify the values of fields and variables while debugging!. First, we will explain a little bit about how the debugger works in general, and then we will explain how you can use the Interactions Pane to modify field and variable values during runtime and thus more quickly zero in on problems in your code.
To enable the debugger, select "Debugger, Debug Mode". This will launch the debug panel in the lower part of DrJava, right above the Interactions Pane.
Debug Panel: The Debug Panel has four tabs to help you track control flow in your program. These tabs are labeled Watches, Breakpoints, Stack, and Threads.
Watches: This is a table that displays the instantaneous values of specified fields and variables given the current line that the debugger is on. To add a watch, click in the leftmost column on the first empty row. A cursor should appear and you can type in the name of the field or variable. You can also put in expressions that require evaluation such as x + 1 or array accesses.
Breakpoints: This is a tree displaying the files that contain breakpoints and the corresponding line numbers. Double-click a breakpoint in the tree to center the screen on the corresponding code. Right-click on a breakpoint to scroll to it or to remove it.
Stack: This a table that lists the current stackframes. Use this to determine the trail of methods that have been invoked to arrive at the current line in the execution. You can double-click on a particular stack frame to scroll to center it in the Definitions Pane.
Threads: This is list of the threads that are running in the virtual machine. If there are multiple threads that are suspended, you can set the active thread (the thread whose execution you're examining) by double-clicking on the desired thread.
<<< Previous | Home | Next >>> |
Generating JavaDoc Documentation | Up | Using the Debugger: |