Using Sun WorkShop

Stepping Through Your Code

You can view your code by stepping--that is, moving through your code one line at a time. As you step, a green highlighted line known as the program counter marks your place in the program. With each step, the program counter moves to the source line which is next to be executed, always showing you the next line to be executed.

There are three ways to step:

Step Into 

Proceed forward one source line; if the source line is a function call, the debugger stops before the first statement of the function. 

Step Over 

Proceed forward one source line; if the source line is a function call, the debugger executes the entire function without stepping through the individual function instructions. 

Step Out 

Finish execution of the present function and stop on the source line immediately following the call to that function. 


Note -

Sometimes after the current function finishes executing, the highlight returns to the line of the call. In such cases, some extra post-call instructions remain to be executed. Stepping into or over again does not call the function again.


To view your code by stepping:

  1. Wait until your program stops, or interrupt execution by choosing Execute > Interrupt, clicking the Interrupt button, or pressing Ctrl+Break.

  2. In the editor window, step through your code one line at a time, moving through functions, around functions, or out of functions:

    • To step forward in your program one source line, choose Execute > Step Into or click the Step Into button (see Figure 5-1 or Figure 5-2) or press F8.

    • To step forward one source line in the current function, choose Execute > Step Over or click the Step Over button or press F7.

    • To finish executing the current function and stop execution on the source line immediately following the call to the function, choose Execute > Step Out or click the Step Out button.

  3. Continue executing your program by clicking on Go or choosing Execute > Go.