Setting and Removing Breakpoints

You can use breakpoints to halt a program object at a specific point when it is running. An unconditional breakpoint stops the program object at a specific statement. A conditional breakpoint stops the program object 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 job 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.

Note: Breakpoints are automatically generated for input and output specifications if the default OPTION(*DEBUGIO) is specified. If you do not want to generate breakpoints, specify OPTION(*NODEBUGIO).

You set the breakpoints prior to running the program. When the program object stops, the Display Module Source display is shown. The appropriate module object is shown with the source positioned at the line where the breakpoint occurred. This line is highlighted. At this point, you can evaluate fields, set more breakpoints, and run any of the debug commands.

You should know the following characteristics about breakpoints before using them:
  • When a breakpoint is set on a statement, the breakpoint occurs before that statement is processed.
  • When a statement with a conditional breakpoint is reached, the conditional expression associated with the breakpoint is evaluated before the statement is processed. If the expression is true, the breakpoint takes effect and the program stops on that line.
  • If the line on which you want to set a breakpoint is not a runnable statement, the breakpoint will be set on the next runnable statement.
  • If a breakpoint is bypassed that breakpoint is not processed.
  • Breakpoint functions are specified through debug commands. These functions include:
    • Adding breakpoints to program objects
    • Removing breakpoints from program objects
    • Displaying breakpoint information
    • Resuming the running of a program object after a breakpoint has been reached
    • You can either have a job or thread breakpoint on a specified position at the same time, but not both.

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 .

If you are debugging a module or program created with a statement view, then you can set or remove breakpoints using statement numbers obtained from the compiler listing. For more information on using statement numbers, see Setting and Removing Job Breakpoints Using Statement Numbers.