| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> |
| <html> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| <title> |
| Stepping through the execution of a Java program |
| </title> |
| <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script> |
| </head> |
| <body> |
| <h1> |
| Stepping through the execution of a Java program |
| </h1> |
| <p> |
| When a thread is suspended, the step controls can be used to step through the execution of the program line-by-line. |
| If a breakpoint is encountered while performing a step operation, |
| the execution will suspend at the breakpoint and the step operation is |
| ended. |
| </p> |
| <h2> |
| Step over |
| </h2> |
| <ol> |
| <li> |
| Select a stack frame in the Debug view. The current line of execution in that stack frame is highlighted in the editor in the Debug perspective. |
| </li> |
| <li> |
| Click the <strong>Step Over</strong> button in the Debug view toolbar, or press the <kbd>F6</kbd> key. The currently-selected line is executed and |
| suspends on the next executable line. |
| </li> |
| </ol> |
| <h2> |
| Step into |
| </h2> |
| <ol> |
| <li> |
| Select a stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor in the Debug perspective. |
| </li> |
| <li> |
| Click the <strong>Step Into</strong> button in the Debug view toolbar, or press the <kbd>F5</kbd> key. The next expression on the currently-selected |
| line to be executed is invoked, and execution suspends at the next executable line in the method that is invoked. |
| </li> |
| </ol> |
| |
| <h2> Step into Selection</h2> |
| <ol> |
| <li> Select a stack frame in the Debug view. The current line of execution in |
| the selected frame is highlighted in the editor in the Debug perspective. |
| </li> |
| <li>In the Java editor, within the current line of execution, place the cursor |
| on the name of a method that you would like to step into.</li> |
| <li> Click the <strong>Step into Selection </strong>action in the Run menu or |
| Java editor context menu, or press the <kbd>Ctrl-F5</kbd> key. Execution resumes |
| until the selected method is invoked. </li> |
| </ol> |
| <h2> |
| Step with filters |
| </h2> |
| |
| <ol> |
| <li>Toggle the <strong>Use Step Filters</strong> button in the Debug view toolbar, |
| or use <kbd>Shift+F5</kbd>. When the action is toggled on, each of the step |
| actions (over, into, return) will apply the set of step filters which are |
| defined in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.debug.ui.JavaStepFilterPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <strong>Java > Debug > Step Filtering</strong></a> preference page. When a step action is invoked, |
| stepping will continue until an unfiltered location is reached or a breakpoint |
| is encountered.</li> |
| </ol> |
| <h2> |
| Run to return |
| </h2> |
| <ol> |
| <li> |
| Select a stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor in the Debug perspective. |
| </li> |
| <li> |
| Click the <strong>Run to Return</strong> button in the Debug view toolbar or press the <kbd>F7</kbd> key. Execution resumes until the next return |
| statement in the current method is executed, and execution suspends on the next executable line. |
| </li> |
| </ol> |
| <h2> |
| Run to line |
| </h2> |
| <p> |
| When a thread is suspended, it is possible to resume execution until a specified line is executed. This is a convenient way to suspend execution at a line without setting a |
| breakpoint. |
| </p> |
| <ol> |
| <li> |
| Place your cursor on the line at which you want the program to run. |
| </li> |
| <li> |
| Select <strong>Run to Line</strong> from the pop-up menu or use |
| <kbd>Ctrl+R</kbd>. Program execution is resumed and suspends just before the specified line is to be executed. |
| </li> |
| </ol> |
| <p>It is possible that the line will never be hit and that the program will not suspend. </p> |
| <p> Breakpoints and exceptions can cause the thread to suspend before reaching the specified |
| line.</p> |
| <p> |
| <img border="0" src="../images/ngrelc.png" alt="Related concepts" ><br> |
| <a href="../concepts/cbrkpnts.htm">Breakpoints</a><br> |
| <a href="../concepts/concepts-5.htm">Java perspectives</a> |
| </p> |
| <p> |
| <img border="0" src="../images/ngrelt.png" alt="Related tasks" ><br> |
| <a href="../tasks/tasks-144.htm">Adding breakpoints</a><br> |
| <a href="../tasks/tasks-130.htm">Launching a Java program</a><br> |
| <a href="../tasks/tasks-135.htm">Resuming the execution of suspended threads</a><br> |
| <a href="../tasks/tasks-126.htm">Running and debugging</a><br> |
| <a href="../tasks/tasks-executionArgs.htm">Setting execution arguments</a><br> |
| <a href="../tasks/tasks-134.htm">Suspending threads</a><br> |
| </p> |
| <p> |
| <img border="0" src="../images/ngrelr.png" alt="Related reference" ><br> |
| <a href="../reference/ref-51.htm">Debug view</a> |
| </p> |
| |
| </body> |
| </html> |
| |