Debugging a Program

Debugging allows you to detect, diagnose, and eliminate errors in a program.

Use Rational® Developer for i, integrated IBM i debugger. This is the recommended method and documentation about debugging ILE COBOL programs and appears in that product's online help.

With the integrated debugger you can debug your program running on the IBM i from a graphical user interface on your workstation. You can also set breakpoints directly in your source before running the debugger. The integrated debugger client user interface also enables you to control program execution. For example, you can run your program, set line, watch, and service entry point breakpoints, step through program instructions, examine variables, and examine the call stack. You can also debug multiple applications, even if they are written in different languages, from a single debugger window. Each session you debug is listed separately in the Debug view.

You can also debug your OPM and ILE COBOL programs using the ILE source debugger. This chapter describes how to use the ILE source debugger to:
  • Prepare your ILE COBOL program for debugging
  • Start a debug session
  • Add and remove programs from a debug session
  • View the program source from a debug session
  • Set and remove conditional and unconditional breakpoints
  • Set and remove watch conditions
  • Step through a program
  • Display the value of variables, records, group items, and arrays
  • Change the value of variables
  • Change the reference scope
  • Equate a shorthand name to a variable, expression, or debug command.

While debugging and testing your programs, ensure that your library list is changed to direct the programs to a test library containing test data so that any existing real data is not affected.

You can prevent database files in production libraries from being modified unintentionally by using one of the following CL commands:
  • Use the Start Debug (STRDBG) command and specify the UPDPROD(*NO) parameter
  • Use the Change Debug (CHGDBG) command, and specify the *NO value of the UPDPROD parameter
  • Use the SET debug command in the Display Module Source display. The syntax for preventing file modification would be:
    SET UPDPROD NO
    which can be abbreviated as
    SET U N

See the chapter on debugging in the ILE Concepts book for more information on the ILE source debugger (including authority required to debug a program object or a service program and the affects of optimization levels).