eclipse tip – debugging in eclipse

10
Eclipse Tip – Debugging in Eclipse Using the Debugger in Eclipse to Find and Correct Run-Time Errors

Upload: gerry

Post on 23-Feb-2016

137 views

Category:

Documents


1 download

DESCRIPTION

Eclipse Tip – Debugging in Eclipse. Using the Debugger in Eclipse to Find and Fix Run-Time Errors. Run-time and Logic Errors. Eclipse provides help in correcting errors at compile-time through messages, tooltips, and other approaches - PowerPoint PPT Presentation

TRANSCRIPT

PowerPoint Presentation

Eclipse Tip Debugging in EclipseUsing the Debugger in Eclipse to Find and Correct Run-Time Errors1Run-time and Logic ErrorsEclipse provides help in correcting errors at compile-time through squiggly lines with messages, error icons, tooltips, and other approachesThis presentation focuses on the other common types of errors: run-time errorsProgram exceptions (crashes)Logic errors: the program finishes normally but produces incorrect results

2The Debugger in EclipseOften, the causes of logic errors and even program crashes can be determined by watching the program run one line at a timeStep through the program by executing one line at a time and watch the results of each line as it executesWhen something unexpected happens, we have identified a segment of the program that requires additional attention3The Debugger in EclipseThe Debugger in Eclipse allows us to execute parts of a program at full speed, pause on certain lines (called breakpoints), and execute subsequent code one line at a timeWhen paused at a breakpoint or executing one line at a time, the debugger allows us to inspect the current values of variables, arrays, ArrayLists, and so forth in scope at the momentThis is a snapshot at that point in the program4Setting a BreakpointSelect a line of executable code where you want the program to pauseDouble-click in the left-margin of the editor to set a breakpoint

Blue ball indicates a breakpoint on this line5BreakpointsYou may set as many breakpoints as you wishBreakpoints can only be set on lines that are executable (not on comments, blank lines, etc.)Breakpoints can be toggled off by double-clicking on the blue ballBreakpoints have no effect when executing the program normallyExecution pauses at every breakpoint when running in debugging mode6Debugging PerspectiveNormally, when editing and testing a program, Eclipse is in the Java Perspective and looks as you have come to expectWhen debugging, the appearance of Eclipse changes to the Debug Perspective (see the next slide)One can go back to the normal Java Perspective by clicking the Java button in the upper right corner of the Eclipse window7

Return to Java PerspectiveExecution paused at breakpointValues of relevant variables shown hereClick this button to run the program in Debug ModeNow in Debug Perspective8

Step intoStep overHover mouse over variable to see its valueTooltip with value9Debugger in Action