Setting Breakpoints

The Visual Studio 2005 debugger allows the user to set breakpoints that will stop running the code at that point. The user can then step through the code and also step into function calls for which debugging information is available. Breakpoints can be set before or while the code is running. When a breakpoint is set, the debugger will break the next time that line of code runs.

In Visual Studio 2005, a breakpoint can be set in various ways. One way is to right-click the mouse in the code window on the line of code on which the breakpoint should be set, and selecting Breakpoint and then Insert Breakpoint. Another way to add a breakpoint is to place the caret in the code window on the line of code on which the breakpoint should be set, select Debug then New Breakpoint, and use the New Breakpoint window to add the breakpoint.

A breakpoint can be removed by right-clicking the mouse in the code window on the line of code that contains the breakpoint to be removed and selecting Remove Breakpoint. All breakpoints can be removed at one time by selecting Debug, and then Delete All Breakpoints.

When the debugger is stopped at a particular line of code, that line of code has not yet been executed. At this point, the user can use the following commands on the Debug menu to navigate through the code:

  • The Step Over command will step to the next executable line of code.
  • The Step Into command will step into the function at the executable line of code, if possible. If no debugging information is available for the current function, the Step Into command will step to the next executable line of code.
  • The Step Out command will step out of the current function back into the point from which the current function was called.

For more information about breakpoints, see Breakpoints in the Visual Studio 2005 documentation.

Send comments about this topic to Microsoft

Build date: 2/16/2009