One of the most common debugging procedures is stepping — executing code one line at a time.
The Debug menu provides three commands for stepping through code:
- Step Into
- Step Over
- Step Out
Step Into and Step Over differ in only one respect — the way they handle function calls. Either command instructs the debugger to execute the next line of code. If the line contains a function call, Step Into executes only the call itself, then halts at the first line of code inside the function. Step Over executes the entire function, then halts at the first line outside the function. Use Step Into if you want to look inside the function call. Use Step Over if you want to avoid stepping into functions.
On a nested function call, Step Into steps into the most deeply nested function. If you use Step Into on a call like
Func1(Func2()), the debugger steps into the function
Func2. If you want to select which nested function to step into, use the Step Into Specific command from the shortcut menu (native C/C++ only — if you are using Managed Extensions for C++, this command is disabled). For more information, see Stepping Into a Specific Function.
Use Step Out when you are inside a function call and want to return to the calling function. Step Out resumes execution of your code until the function returns, then breaks at the return point in the calling function.
You cannot access the Step commands if your application is running. Step commands are valid only in break mode or before you start the application. For more information, see Breaking Execution.
To step into a program that is not yet executing
- From the Debug menu, choose Step Into.
To step while debugging
- The debugger must be in break mode.
- From the Debug menu, choose Step Into, Step Out, or Step Over.