Skip to content

Compile, Run, Debug

Key Concepts

  • Main Toolbar
    Project>Build All and Project>Build Project can be used to Compile, and not Run a Program A Build can be “forced” by using the Clean function before running any of the Build, Run, or Debug functions. The Run toolbar button on the Developer Studio main toolbar builds (if necessary) and runs the program.

  • Compiler Console Window
    Results of the Compile can be checked in the Compiler Console Window.

Clean, then Build

Select Project from the Main Menu, and then Clean… from the dropdown menu to open the Clean dialog screen.

Clean Navigation

The Clean Dialog Screen

Retain the defaults, which will Clean all projects, Start a build immediately, and Build the entire workspace.

Note

When you have multiple projects in your Workspace, it may be convenient to only build selected projects.

The Clean will force a compile of the Project. The Build that is executed automatically is a compile of all the programs in the project, using the compiler flags set earlier in this exercise.

Clean and Build does not trigger a Run of the program.

Clean>Build updates in the COBOL-IT Compiler console

The COBOL-IT Compiler Console Window is updated with the results of the Build. In between informational messages that reference the Build function, you will see the command-line that is being executed, with cobc, the compiler flags that are being used, and the program name.

When the compile is successful, as in the example below, you will see the name of the C program that was successfully compiled by the host C compiler, and information on intermediate files that were created.

When the compile is not successful, you will see compiler error reports, as they would appear if you had executed the compile command on the command line. We will examine this case more closely later in this document.

Build Updates

Clean, Build, and Rebuild a single program

Right click on a program in the Navigator Window, and select Cobol>Clean to clean a single program. Select Cobol>Build to build a single program. Select Cobol>Rebuild to rebuild a single program. Use these functions when you are working on a single program in a larger project.

Cobol Clean, Build and Rebuild

Use the Show Build Command to review the build command prior to executing the build:

Build Command

Open With…>Text Editor to view text files

In this example, we have created a list file, called hello.lst in the lst folder. The list file is a text file.

To open hello.lst in an Editor Window, single-click hello.lst to select it, then right-click, and select Open With>Text Editor.

Open With Text Editor

Running the COBOL program

To run hello.cbl, first open the file in the Code Editor. This places focus on the source file in the Navigator View, and makes the Run button on the main toolbar visible. Then, click on the Run button to run hello.cbl.

Run COBOL Program

Running in the Debugger Perspective

You are now ready to Run the COBOL program in the Debugger Perspective.

We included the –g compiler flag in our compile string, and our Window>Preferences>Run/Debug>Perspectives dialog has been set to open the Debugger Perspective when we launch the debugger.

To run hello.cbl in the Debugger Perspective, first open the file in the Code Editor. This places focus on the source file in the Navigator view, and makes the Debug button on the main toolbar visible. Then, click on the Debug button.

Debugger Icon on the Developer Studio toolbar.

This will cause the Debugger Perspective to open and run hello.cbl.

Debugger Perspective

Single step through the STOP RUN command to terminate the program.

Toggle Perspectives to re-enter the Developer Studio Perspective

After terminating a debug session, you can toggle back to the Developer Studio Perspective, and resume development. You can widen the tab area that displays available perspectives by dragging it to the left. When you have widened the tab, you will see the two perspectives, COBOL-IT Debugger Perspective and COBOL-IT Developer Studio Perspective. To toggle between the two, just click on from one tab to the other.

Toggle Debugger and Developer Perspective

Correcting compiler errors from the Problems view

Compiler errors are recorded on the Problems View, which records program name, and line number, and provides a clickable interface to go to the error. In the example below, a variable has been misspelled, in the statement ACCEPT w-dummy. In the Problems View, click on the red (x) next to the informational message w-dummy undefined to select it, and then double-click, and the error line is located.

You will notice that the error line in the source has also been marked with a red (x), and that the line in which the error is located has been highlighted in blue.

Errors in Problems View

Correcting compiler errors from the Compiler Console view

Compiler errors are also recorded on the Compiler Console View, as follows:

C:/COBOL/CobolIT/train/project1/hello.cbl: In paragraph 'main':
C:/COBOL/CobolIT/train/project1/hello.cbl:27: Error: 'ws-dummy' undefined

This output is not in a clickable interface. However, you can easily isolate the line number in which the error occurred, and use the Go To Line Number (Ctl + L ) function in the Code Editor to locate the error.

Go to Line

After correcting a compiler error, you should:

  • SAVE your changes
  • CLEAN
  • BUILD, ( or REBUILD, from the Project Cobol>Rebuild function)
  • Verify that the problem has been corrected in the Compiler Console Window and/or the Problems Window.
  • Run to validate that the problem is fixed.

Hello World

Back to top