As a programmer, the debugging of a program is a basic skill. When you do not use the IDE, the debugging of the program is mostly through the log or input statement (SYSTEM.OUT.PRINTLN) way. You can show the program running track or the status of the program running process to the user, the user accordingly to the program analysis and debugging. In fact, this kind of debugging is not very convenient. The debug feature is available in most Ides, allowing users to step into the program and view the state of each variable in the program during execution. You can also adjust the value of the state during the program's operation. Here's an example of how to use the Debug debugger with Eclipse. Note: To use the debug functionality provided by Eclipse, you must start the server (for the web app) or run the program (for the Application app) in the eclipse environment. Debugging mainly involves the following aspects: L Set Breakpoints, l single-step tracking; L View the state of a variable or object; L dynamically modify the state of the variable; l stop running; l view toggle; Deletes a breakpoint. The following are described separately.
10.5.1 Setting BreakpointsThe purpose of setting breakpoints is to let the program run to this point when it stops at this place. In general, when you suspect that a place may have an error, you can add a breakpoint before this place, usually by adding the breakpoint to the executable code instead of the variable's declaration statement. To add a breakpoint, double-click in the left margin of the line of code.
10.5.2 Single-Step trackingAfter you set a breakpoint, you run the program, and the program runs to the breakpoint at the line where the breakpoint is located. You can then step into it. Note: When the cursor rests on a line, it indicates that the line is ready to be executed. To single-step debug, use F6. Executes the next line. You can use F5 if the current row is a method call and you want to go into the method to view the execution process. If you want to go up a first-level approach, that is, jump out of the current method, you can use F7. If you want to run directly to the next breakpoint, use F8, or the green arrow. If there is no subsequent breakpoint, the program runs directly to the end of the place.
10.5.3 View the state of a variable or objectThe primary purpose of stepping is to see the state of a variable or object during execution. You can view the status of a variable at any time as you step through the process. There are two ways to view the state of a variable: L put the mouse on top of the variable to be viewed (must be the code that has been executed), the value of the variable is displayed, l usually variable window, if this window is not displayed, you can go through "window" à "show View" à "Variable", so that a window appears, displaying all the variables related to the current running process, which can be used to view the state of the variable.
10.5.4 Changing the value of a variableThe value of the variable is dynamically adjusted during the process of running the program. The adjustment method is as follows: L Select the variable to be modified in the Virables window, click the right-hand button, select Change value, the window will pop up, and enter the modified value in the window to confirm. You can then continue to execute the program. Subsequent executions will use the value of the modified variable. In addition, the procedure can be modified at any time during program execution, and the program will continue to execute after modification.
10.5.5 Terminating program OperationYou can terminate a program if you have found an error during debugging, or if you do not want the program to continue executing down. To terminate the program, you can use the Red Party button. Note: This error will stop the server that was running at the time.
10.5.6 Switching viewsWhen debug starts, the Debug window opens. You can switch to Development view at any time. To switch to a different view, select "Window" à "Open perspective" and select from the list, if you do not see the corresponding view in the list, you can select "Others" and select the appropriate view from it.
10.5.7 Deleting BreakpointsAfter debugging, you need to delete the breakpoint. To delete a breakpoint can be as follows: L double-click where you add a breakpoint, if you double-click where there is a breakpoint, you can cancel the breakpoint, if there is no breakpoint, you can add a breakpoint. L Select a breakpoint in the Breakpoints window in the Debug view, then click the right-hand button, select "Delete" in the pop-up menu, or right-click and select "Remove all Breakpoints". In the "Run" submenu of the main menu, select "Remove All Breakpoints".
For more information on debugging, reference materials: "Java Web Design Basic Tutorial" chapter 15th program debugging
Debugging applied in Eclipse