Share via


Setting Breakpoints

Home Page (Debugger)OverviewHow Do I... Topics

Use the Breakpoints dialog box (accessed by the Breakpoints command on the Edit menu), to set, remove, disable, enable, or view breakpoints. The breakpoints you set will be saved as a part of your project.

Note   You must have a project open before you can set a breakpoint. With no project open, the Breakpoints command does not appear on the Edit menu.

You can set breakpoints on a source-code line or in the Disassembly or Call Stack window.

What do you want to do?

Set a breakpoint at a source-code line

Set a breakpoint at the beginning of a function

Set a breakpoint at the return point of a function

Set a breakpoint at a label

To set a breakpoint at a source-code line

  1. In a source window, move the insertion point to the line where you want the program to break.

  2. Choose the Insert/Remove Breakpoint toolbar button.

    A red dot appears in the left margin, indicating that the breakpoint is set.

    Note   If you want to set a breakpoint on a source statement extending across two or more lines, you must set the breakpoint on the last line of the statement.

To set a breakpoint at the beginning of a function

  1. In the Find box on the Standard toolbar type the function name.

  2. Click the Insert/Remove Breakpoint toolbar button.

    While in debug mode a red dot appears in your source code in the left margin at the beginning of the function, indicating that the breakpoint is set.

To set a breakpoint at the return point of a function

  1. Start debugging, and pause the debugger in break mode (program is waiting for user input after completing a debugging command).

  2. On the View menu, click Debug Windows, then click Call Stack.

  3. In the Call Stack window, move the insertion point to the function where you want the program to break.

  4. Click the Insert/Remove Breakpoint toolbar button.

    While in debug mode a red dot appears in the left margin of your source code, indicating that the breakpoint is set.

To set a breakpoint at a label

  1. In the Find box on the Standard toolbar type the name of the label.

  2. Click the Insert/Remove Breakpoint toolbar button.

    While in debug mode a red dot appears in your source code, in the left margin at the line containing the label, indicating that the breakpoint is set.