A breakpoint indicates a line of code, a program, or a method at which you want the execution of an application to pause. When the application is paused, you can view and change the values of data items at that particular step.
Breakpoints in Eclipse are set in source files, not in programs (as they are in other Micro Focus products). This means that a single breakpoint may actually be encountered many times if the source file is used in multiple programs or used multiple times in the same program.
For example, consider the following program, Main.cbl:
Procedure division. Copy "Code.cpy". … Copy "Code.cpy".
The copybook, Code.cpy, has the following code:
Add 1 to count // set breakpoint here
When a breakpoint is set before debugging is started, or no program that uses the copybook is active, the breakpoint is pending. This means that it has not been resolved to a real code position. When debugging is started or a new program is called, the debugger attempts to resolve all pending breakpoints and bind them to actual code positions.
In the above example, when the main executable is loaded by the debugger it binds the single (pending) breakpoint to two actual (bound) breakpoints. The breakpoints are then shown with a plus sign added to the breakpoint icon , both in the margin of the editor and in the Breakpoints view.
A watchpoint is a type of breakpoint that 'watches' an area of memory associated with a data item; the application breaks when that memory is updated. You set this type of breakpoint on a data item, as opposed to a particular line of code.
You can set breakpoints and watchpoints in one of the following ways:
Perform any of the above methods on the Procedure Division heading creates a program breakpoint; similarly, performing them on a method-id header (COBOL JVM only) creates a method breakpoint. When these types of breakpoints are hit, execution stops on the first valid line after the header.
If the editor is not open, you can still create some types of breakpoint. You can create a program breakpoint for any program in the workspace by clicking Run > Add Program Breakpoint, or clicking the icon in the Breakpoints view, and entering the name of the file.
The icon appears in the marker bar when a breakpoint is set, and the icon when a watchpoint is set. A tick mark is added to these icons when the breakpoint or watchpoint is bound to the program currently attached to the debugger. A program breakpoint is indicated by the icon.
The Breakpoints view shows a list of all breakpoints and watchpoints, active and dormant, in the workspace. To view the properties of each, right-click the entry and select Breakpoint Properties. This displays a Properties... dialog box shows details for the breakpoint or watchpoint, and enables you to configure its behavior.
You can add conditions to both types of breakpoints. A condition can be a hit count - for example, for a conditional breakpoint on line 15 of a program, where hit count > 2 is set, execution will only break when an attempt is made to execute that line for the third time. If you are reverse debugging, the hit count still increments when you step backwards.
A condition can also be a coded expression - for example, for a conditional watchpoint set on my-variable, with an expression of my-variable > your-variable, would only break execution when the memory for my-variable was updated and the value of my-variable was greater than your-variable. You can also combine both types of condition, where both conditions must be true before execution will break.
See Setting conditional breakpoints and watchpoints.