Running and Debugging

Applications you create with Eclipse need a launch configuration to execute. A launch configuration describes the way an application should be run or debugged.

Some launch configurations apply to running and debugging, while some apply only to debugging. It is possible to configure multiple launch configurations of the same, or different types, and you can give them meaningful names.

You create configurations by clicking Run > Run Configurations or Debug > Debug Configurations - the dialog box that these open enables you to manage the launch configurations. Click a type of configuration in the pane on the left-hand side of the dialog box - a description of the intended usage of the type is shown in the banner at the top.

Launch Configurations

Debugging applications

Debugging your program opens the Debug perspective. You can step through code in the Debug view or use the Run to cursor feature to run from the current execution point to where you have placed the cursor.

The IDE offers a flexible debugging environment. When you debug the code you can step through it so that each line of the source is highlighted in turn as each statement is executed, showing the effect of each statement. You can interrupt execution to examine and change data items.


GUID-85CC777A-7D9D-42E2-85BA-17BEC5077F43-low.png

You can set breakpoints to control the way The following breakpoint are available:

  • Standard breakpoints, breakpoint - these are set against a line of code in the Procedure Division of the code and have properties which control when the breakpoint is activated.
  • Program breakpoints, program breakpoint - these activate when a program of the given name is called.
  • Watchpoints, watchpoint - these activate when a data item changes value.

    Note that since execution breaks when the item has been changed, the cursor position will be on the statement after the statement that caused the data item to change value.

The Debug perspective comes with a number of views tailored to support the debugging process:

  • Debug view - when debugging, the Debug view shows details of what is being debugged. Specifically, it shows a hierarchy where the first level is the launch configuration used, next is the built article that is being debugged (process), then the thread, and within that are the layers of performs and/or calls (stack frames).

    A number of debugger functions are sensitive to the item that is selected in the Debug view (so as to cope with different scopes for variables, and the debugging of multiple threads), so if a function that you expect to be enabled is not, check which item is selected in the view. If you want to step, you need to have selected the first code line within the thread.

    Selecting different stack frames controls which variables are shown in the variables view, and also switches the editor to the relevant line of code.

  • Other views in debugging - the following views in the Debug perspective enable you to monitor how the data and variables change in your applications:
    • The Breakpoints view shows all the current breakpoints. From here you can disable all breakpoints with a single click.

      Breakpoints View

    • The Expressions view shows the value of any variables that you add to it, as evaluated in the context of the current location selected in the Debug view.
    • The Variables view shows the values of variables and file statuses of internal file names in use on the current or previous line of code. Those which have just changed in the last statement executed are highlighted. Again, the values displayed are sensitive to the current location selected in the Debug view.

      Variables view

    • The Memory view shows the memory at any given address. Note that the Memory view is not shown by default. To display it, click Window > Show View > Other and type Memory to locate the view.

      You can directly enter a numerical address or the name of a pointer variable. Alternatively, you can enter the name of a non-pointer variable and the memory of that variable is shown. Both ASCII and EBCDIC renderings are available for the memory along with the default hexadecimal rendering - click the New Renderings tab in the toolbar of the view to add new rendering.

      Memory View

Debugging techniques

There are various ways in which you can debug an application depending on its type and whether it resides on the local or a remote machine. See Debugging COBOL applications in your product help for detailed explanation of the different debugging scenarios.

What next?

Now that you have read this brief introduction into running and debugging applications, practice what you've learned with the tutorial that follows, Debugging the Hello COBOL World Application.