Previous Topic Next topic Print topic


Debugging a COBOL Application

You can debug entire projects as well as single files which are not part of a project.

To debug a COBOL application that has a project:

  1. Ensure that the current active build configuration is compiling the project for debugging. See Compile for Debugging.
  2. Compile the program by clicking Project > Build Project, unless it is already compiled because Project > Build Automatically is turned on.
  3. Choose or create a debug configuration by clicking Run > Debug Configurations. Different types of COBOL debug configurations are available for different types of debug sessions, where each type of configuration offers different options and requires different specifications. Like build configurations, you can have multiple debug configurations and swap between them. These settings override the project's run-time settings.
  4. Click Debug.

    Eclipse opens the Debug perspective that provides views that facilitate debugging.

  5. Use the options on the Run menu to step through the program, stop at breakpoints and query data item values and so on.
    Tip: Use the following techniques to help you debug programs:
    Keyboard shortcuts
    • F5 = Step into the next statement at the current line of code and suspend execution. Equivalent of clicking .
    • F6 = Step over the next statement at the currently executing line of code without entering it, and suspend execution. The method will be executed normally. Equivalent of clicking .
    • F7 = Return from a method or paragraph that has been stepped into, and suspend execution. The remainder of the code inside the method is executed normally. Equivalent of clicking .
    • F8 = Resume execution of the program from a suspended line of code. Equivalent of clicking .
    You can also click the Drop to Frame button to reposition you at the start of the current method.
    To query the value of a data item or the file status of an internal file name
    Hold the mouse pointer over a data item or internal file name and the current value or file status displays as a Text Hover. The values of variables and file statuses of internal file names contained on the current execution line and previous line are displayed in Variables View (usually displayed in the top right of the IDE).
    To deal with unassigned linkage items

    If the debugger steps on a line with an unassigned linkage item (for example, if you are debugging only a part of your application and no memory has been allocated to that linkage item), debugging terminates. To assign linkage to that data item and continue debugging, you need to select the data item, right-click it and click Inspect COBOL. When prompted, confirm and assign a value to the data item. Alternatively, to assign linkage, you can right-click the data item in the Variables view and click Change Value.

  6. To stop debugging, click Run > Terminate.
  7. To leave the Debug perspective and return to the COBOL perspective, click COBOL at the top right of the Eclipse window.

The following only applies to native COBOL code. To debug a single file which is opened in the IDE without a project, the file must be opened in the editor:

  1. Ensure the file is compiled. If necessary, right-click in the editor and click Compile to produce the program executables.
  2. Right-click the file in the editor and click Debug As > COBOL Application.

    This starts debugging and the IDE switches to the Debug perspective.

  3. Step through the program in the usual way.
Previous Topic Next topic Print topic