Stepping through a program
When a thread is suspended, the step controls can be used to step through the execution of the program line-by-line. While performing a step operation, if a breakpoint is encountered, execution suspends at the breakpoint and the step operation ends.
You can use step commands to step through your program a single line at a time.
Step Over
Issuing a step over allows a thread to run one line in the current stack frame. To execute a step over command:
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. Do one of the following:
- Click the Step Over button (
) in the Debug view toolbar.
- Select Run > Step Over from the workbench menu bar.
- Press F6.
The currently-selected line is executed and execution suspends on the next executable line.
Step Into
Step into resumes the suspended thread by stepping into the method contained on the selected line of code. If no method exists in the line, the step into action will behave the same as the step over action.
To execute a step into command:
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. Do one of the following:
- Click the Step Into button (
) in the Debug view toolbar.
- Select Run > Step Into from the workbench menu bar.
- Press F5.
If the current line is a simple statement, this command executes the statement. If the current line is a function or method call, this command steps into the call and stops on the first line of the called function or method.
Step Return
Issuing a step return allows all threads to run until a return to a calling stack frame or the end of program is reached. To execute a step return command:
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. Do one of the following:
- Click the Step Return button (
) in the Debug view toolbar.
- Select Run > Step Return from the workbench menu bar.
- Press F7.
The current execution point, up to the line immediately following the line that called the function, is executed. Execution stops after exiting the current function. If you issue this command from the main entry point (that is, in main()), the program runs to completion.
Run to Line
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.
- In the editor, place your cursor on the line to which you want the program to run or in the marker bar directly to the left of the line.
- Right-click and choose Run to Line from the pop-up menu.
- Program execution is resumed and suspends just before the specified line is to be executed.
Related tasks
Using the Debug view
Debugging an HTML Script Application
Debugging a Script Host Application
Running an Active Script application
Halting a running program
Terminating a debug session
Setting debug preferences