Setting and Removing Breakpoints - IBM-ILE

The flow of a program can be controlled with breakpoints. You can set unconditional and conditional breakpoints. An unconditional breakpoint stops the program at a specific statement. A conditional breakpoint stops the program when a specific condition at a specific statement is met.

There are two types of breakpoints: job and thread. Each thread in a threaded application may have it’s own thread breakpoint at the same position at the same time. Both ob and thread breakpoints can be unconditional or conditional. In general, there is one set of debug commands and Function keys for job breakpoints and another for thread breakpoints. For the rest of this section on breakpoints, the word breakpoint refers to both job and thread, unless specifically mentioned otherwise.

When the program stops, the Display Module Source display appears. Use this display to evaluate variables, set more breakpoints, and run any of the source debugger commands. The appropriate module is shown with the source positioned to the line where the condition occurred. The cursor will be positioned on the line where the breakpoint occurred if the cursor was in the text area of the display the last time the source was displayed. Otherwise, it is positioned on the debug command line.

If you change the view of the module after setting breakpoints, then the line numbers of the breakpoints are mapped to the new view by the source debugger.

You can set and remove unconditional and conditional breakpoints by using:

  • F13 (Work with module breakpoints)
  • F6 (Add/Clear breakpoint)

You can also add breakpoints with the BREAK or TBREAK debug commands. You can remove one, or all breakpoints from a program by using the Clear Program debug command.

To set a breakpoint on the first statement of a multi-statement macro, the cursor should be on the line containing the macro invocation, not the macro expansion.


This example shows you how to set and remove an unconditional breakpoint using F6 (Add/Clear breakpoint), and add a conditional breakpoint using F13 (Work with module breakpoints).

  1. To work with a module, type DSPMODSRC and press Enter. The Display Module Source display is shown.
  2. If you want to set the breakpoint in the module shown, continue with step 3. If you want to set a breakpoint in a different module, type display module name on the debug command line where name is the name of the module that you want to display.

  3. Type display module T1520IC2, and press Enter.
  4. To set an unconditional breakpoint, place the cursor on line 50.
  5. Press F6 (Add/Clear breakpoint). A breakpoint is added to line 50 as shown:
  6. Setting and Removing Breakpoints

    If there is no breakpoint on the line you specify, an unconditional breakpoint is set on that line.

    Note:If there is a breakpoint on the line you specify, it is removed (even if it is a conditional breakpoint). This function key acts as a toggle key. The clear command can be used to remove a breakpoint. For example, clear 50 removes the breakpoint at line 50.

  7. To set a conditional breakpoint press F13 (Work with module breakpoints). The Work with Module Breakpoints display is shown.
  8. On this display type 1 (Add) on the first line of the list to add a conditional breakpoint.
  9. To set a conditional breakpoint at line 35 when i is equal to 21, enter 35 for the Line field, i==21 for the Condition field, and press Enter as shown:
  10. Setting and Removing Breakpoints

    A conditional breakpoint is set on line 35. The expression is evaluated before the statement is run. If the result is true (in the example, if i is equal to 21), the program stops, and the Display Module Source display is shown. If the result is false, the program continues to run. If you do not want to switch panels, you can set the same breakpoint from the Display Module Source command line by typing:

    break 35 when i==21

    You can set a conditional breakpoint to a statement. For example, if you have a compiler listing that contains line numbers and statement numbers, you can use the statement syntax to set a breakpoint on a specific statement when there are several statements on a single line.

    Line Stmt Source
    33 24 i=j; j=0;
    34 26 array[i] = cost;

    Break myfunction/25 sets a breakpoint on the statement j=0 assuming this is in myfunction. If you then enter Break 33, a breakpoint is set at statement 24, i=j.

    An existing breakpoint is always replaced by a new breakpoint entered at the same location.

  11. Repeat steps 4 or step 5 for each breakpoint that you want to add.
  12. After the breakpoints are set, press F12 (Cancel) to leave the Work with Module Breakpoints display. Press F3 (End Program) to leave the ILE source debugger. Your breakpoints are not removed.
  13. Call the program. When a breakpoint is reached, the program stops, and the Display Module Source display is shown again.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

IBM-ILE Topics