Debugging optimized COBOL programs

Before you debug an optimized COBOL program, you must compile it with the correct compiler options. See Choosing TEST or NOTEST compiler suboptions for COBOL programs.

The following list describes the tasks that you can do when you debug optimized COBOL programs:

  • You can set breakpoints. If the optimizer moves or removes a statement, you cannot set a breakpoint at that statement.
  • You can display the value of a variable by using the LIST or LIST TITLED commands. z/OS® Debugger displays the correct value of the variable.
  • You can step through programs one statement at a time, or run your program until you encounter a breakpoint.
  • You can use the SET AUTOMONITOR and PLAYBACK commands.
  • You can modify variables in an optimized program that was compiled with one the following compilers:
    • Enterprise COBOL for z/OS, Version 4 and 5
    • Enterprise COBOL for z/OS and OS/390®, Version 3 Release 2 or later
    • Enterprise COBOL for z/OS and OS/390, Version 3 Release 1 with APAR PQ63235 installed
    • COBOL for OS/390 & VM, Version 2 Release 2
    • COBOL for OS/390 & VM, Version 2 Release 1 with APAR PQ63234 installed
    However, results might be unpredictable. To obtain more predictable results, compile your program with Enterprise COBOL for z/OS, Version 4, and specify the EJPD suboption of the TEST compiler option. However, variables that are declared with the VALUE clause to initialize them cannot be modified.
  • If you are using Enterprise COBOL for z/OS, Version 4 and 5, and specify the EJPD suboption of the TEST compiler option, the JUMPTO and GOTO commands are fully enabled by the compiler for use in a debugging session.
  • If you are using Enterprise COBOL for z/OS Version 4 and using OPT and the NOHOOK or NONE, and NOEJPD suboptions of the TEST compiler option, the GOTO and JUMPTO commands are not enabled by the compiler. In this case, there is limited support for GOTO and JUMPTO when you run the commands with SET WARNING OFF. However, the results of using GOTO or JUMPTO in this case might be unpredictable and any problems encountered are not investigated by IBM® service.
  • If you are using Enterprise COBOL for z/OS Version 5 or later, and the programs are complied with OPT and NOEJPD of the TEST compiler option or optimized by Automatic Binary Optimizer for z/OS, the GOTO and JUMPTO are still allowed but you need to first execute the SET WARNING OFF command. However, the results of using GOTO or JUMPTO in this case might be unpredictable and any problems encountered are not investigated by IBM service.
  • If you are using Enterprise COBOL for z/OS Version 4 or earlier and using OPT, the information about section and paragraph names is not predictable. Commands LIST NAMES LABELS and AT LABEL are affected, as well as the ability of the remote debugger to list the section and paragraph names when the module is expanded in the Modules view.

The enhancements to the compilers help you create programs that can be debugged in the same way that you debug programs that are not optimized, with the following exceptions

  • You cannot change the flow of your program.
  • You cannot use the AT CALL entry_name command. Instead, use the AT CALL * command.
  • If the optimizer discarded a variable, you can refer to the variable only by using the DESCRIBE ATTRIBUTES command. If you try to use any other command, z/OS Debugger displays a message indicating that the variable was discarded by the optimization techniques of the compiler.
  • If you use the AT command, the following restrictions apply:
    • You cannot specify a line number where all the statements have been removed.
    • You cannot specify a range of line numbers where all the statements have been removed.
    • You cannot specify a range of line numbers where the beginning point or ending point specifies a line number where all the statements have been removed.

The Source window does display the variables and statements that the optimizer removed, but you cannot use any z/OS Debugger commands on those variables or statements. For example, you cannot list the value of a variable removed by the optimizer.