Exercise 5.3: Setting breakpoints

Before you begin, you must complete Exercise 5.2: Starting the integrated debugger.

You can only set breakpoints at executable lines. All executables lines are displayed in blue. One way to set a breakpoint is to right-click on the line in the Source view.

To set a breakpoint:

  1. Position the cursor on line 11.
  2. Right-click anywhere on line 11.
    Add Breakpoint to CLR1 program
  3. Click Add breakpoint on the pop-up menu.

    A dot with a checkmark in the prefix area indicates that a breakpoint has been set for that line. The prefix area is the small grey margin to the left of the source lines.

    Now you add a conditional breakpoint to stop in the loop when it loops the 99th time.

Adding a conditional breakpoint

To add a conditional breakpoint:

  1. Position the cursor on line 8.
  2. Right-click on line 8.
  3. Click Add breakpoint on the pop-up menu.
    Add another Breakpoint to CLR1
  4. Click the Breakpoints tab in the upper right pane of the Debug perspective.

    The Breakpoints view opens.
    Edit break point

  5. In the Breakpoints view right-click the breakpoint for line 8.
  6. Click Edit Breakpoint on the pop-up menu.

    The Edit a Line Breakpoint window opens.
    Edit break point

  7. Click Next.
    Edit break point

    You only want to stop in the loop when it executes for the 99th time or more. You can do that by setting the From field of the Frequency group to 99.

  8. Under Frequency in the From field, type 99.
  9. Click Finish.

You have added a breakpoint including a conditional breakpoint to your source and now you are ready to begin Exercise 5.4: Monitoring variables.