This completes the tutorial. The debugger can be extremely useful, even for smaller projects, so we strongly advise that you become familiar with how to use it effectively.
Fix the one remaining bug in the Aquarium and go through this tutorial until you feel you are comfortable with all of the debugging features that were described. Reminder: The number of food points
was showing 0 instead of a correct value. Hint: Check the FoodCenter.java
source code.
Be sure to terminate any debugging sessions you may have started before continuing with the assignment's debugging exercises.
Here is a summary of the various buttons and controls associated with debugging.
Perspective Switching Buttons |
The buttons at the top right corner of your Eclipse window allow you to easily switch from the Debug perspective to the Java perspective and back again. | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Panes | Breakpoints | View and manage all breakpoints using this pane. | ||||||||||||||||||
Variables | Displays all the variables, that are currently in scope,
and their current values. You can expand references to objects to examine the
state of the object in more detail.
Double-clicking on an entry for a primitive variable in this window will open a dialog window that allows you to set the value of the variable. Explore the other options of the Variables pane to show the variable types and be able to collapse and expand the fields of reference variables. |
|||||||||||||||||||
Text | Displays the source code for the classes you are debugging. The next line to be executed will be highlighted in this view. You can set and remove breakpoints by double-clicking to the left of the appropriate line of code. | |||||||||||||||||||
Debug | Displays the call stack. When a method is called, an entry for the method is added to the top
of the call stack. When a method finishes execution its entry is removed from the call stack.
View the variables in the scope of any of the method by single-clicking on that method in the Debug pane. The Variables pane will be updated to show the highlighted method's variables. Navigate to the corresponding source code for a method by double-clicking on the entry for that method.
|