Using Breakpoints in the Debugger

The Developer Studio debugger lets you set breakpoints at certain locations, when certain conditions are met at a certain location, or when a variable changes its value. This section discusses the following topics:

Viewing and Using Location Breakpoints

To view the breakpoints currently set:

  1. In the Edit menu, click Breakpoints.
  2. Scroll up or down in the Breakpoints list to view the breakpoints. Enabled breakpoints have a check mark in the check box and disabled breakpoints have an empty check box. The Edit Breakpoints dialog box displays all types of breakpoints (not just location breakpoints).

Alternatively, for smaller programs you can view location breakpoints set in the text editor window. Enabled location breakpoints are identified as a red circle in the left margin (see Debugging the Squares Example Program). Disabled location breakpoints are identified as a hollow circle in the left margin. You can also remove a breakpoint.

To set a location breakpoint:

  1. After you open the project workspace, open the source file within which you will set a location breakpoint in the text editor (double-click the file name in the FileView pane).
  2. In a text editor window (or in the Call Stack or Disassembly window), click the line at which you want to enable a location breakpoint.
  3. Do one of the following:

To disable or enable a location breakpoint:

  1. In a text editor window (or in the Call Stack or Disassembly window), click the line containing the location breakpoint you want to disable.
  2. Do one of the following:

To remove a location breakpoint:

  1. In a text editor window (or in the Call Stack or Disassembly window), click the line containing the location breakpoint you want to remove.
  2. Do one of the following:

To view the source code where a location breakpoint is set:

  1. In the Edit menu, select Breakpoints.
  2. In the Breakpoints list, click (select) a location breakpoint.
  3. Click the Edit Code button (upper right corner).

    This action takes you to the source code for a breakpoint set at a line number or function (or subroutine) name. In the case of function (or subroutine) names, the debugger must be running for this to work.

To remove all breakpoints:

  1. In the Edit menu, select Breakpoints. Click on the Remove All button. Click OK.

Setting Location Condition Breakpoints

Like a location breakpoint, a location condition breakpoint occurs only at a certain location. Instead of the break always occurring when the program executes at that location, a location condition breakpoint occurs when the program executes at that location and the specified condition is met (such as when the value of an array element is greater than 1). The following procedure applies to source code within the current scope.

Unlike location breakpoints, location condition breakpoints must be set only using the Edit Breakpoints dialog box:

To set a location condition breakpoint:

  1. In a text editor window (or in the Call Stack or Disassembly window), click the line at which you want to enable a location condition breakpoint.
  2. Do the following:

To disable, enable, and remove a location condition breakpoint, follow the general procedures for a location breakpoint. Under certain conditions, the debugger may disable the location condition breakpoint. In this case, you should either try to enable it or remove and set it again.

When the program is run and if the specified condition occurs at the chosen location, a message box similar to the following appears:

Message box after condition met

Using Data Breakpoints (Current Scope)

A data breakpoint displays a message box when the value of a variable changes or when a specified condition is met. Unlike a location condition breakpoint, data breakpoints are not associated with a specific source location. The following procedure applies to debugging the current routine (current scope).

To set a data breakpoint:
  1. In the Edit menu, select Breakpoints.
  2. Click the Data tab.
  3. Either type the variable name alone if you want a data breakpoint to occur whenever its value changes or type the desired condition, such as:
    A(1) .eq. 0
  4. Click OK to dismiss the Breakpoint dialog.

To disable, enable, or remove a data breakpoint, do one of the following:

  1. In the Edit menu, select Breakpoints.
  2. To disable or enable the data breakpoint, use the check box to the left of the data breakpoint (check indicates enabled).
  3. To remove a data breakpoint, click (select) the data breakpoint and click the Remove button.

Under certain conditions, the debugger may disable the data breakpoint. In this case, you should either try to enable it or remove and set it again.

Setting Advanced Data Breakpoints

You can request that your program stop execution when a specific variable is set to a specific logical expression (data breakpoint or watchpoint). To properly instruct the debugger to watch for a change of a certain data value (variable), you should specify the routine name (scope) within which the data value condition will be watched. When the data value condition for the variable occurs within the specified scope, a message box window is displayed informing you that the condition has been met.

To set a data breakpoint for a specific local variable:

  1. In the Edit menu, select Breakpoints.
  2. Click the Data tab
  3. Enter the logical expression to be evaluated, such as K .GT. 2
  4. Unless the data value being watched is in the main program code, specify the scope of the data breakpoint as follows:
  5. Start the debugger (Build menu). Consider displaying the source file associated with the data expression being watched.
  6. If you have previously set an initial breakpoint for the program, in the Debug menu, click Go. Execution stops at the initial breakpoint.
  7. In the Debug menu, click Go. Execution continues until the specified data value expression is met. A message box similar to the following appears when the specified data expression is met:

    Message box after stop at watchpoint

  8. You can now view the source line just executed, examine current variable values, execute the next instruction, and so on to help you better understand that part of your program. If the error is related to an I/O statement, also see Viewing the Call Stack and Context Menu.

Some limitations with the current implementation: