CL Programming

Debug Mode

To begin testing, your program must be put in debug mode. Debug mode is a special environment in which the testing functions can be used in addition to the normal system functions. Testing functions cannot be used outside debug mode. To start debug mode, you must use the Start Debug (STRDBG) command. In addition to placing your program in debug mode, the STRDBG command lets you specify certain testing information such as the programs that are being debugged. Your program remains in debug mode until an End Debug (ENDDBG) or Remove Program (RMVPGM) command is encountered or your current routing step ends.

Note: If the System Debug Manager function in iSeries Navigator has been used to select Debug in order to check the system, then issuing the Start Debug (STRDBG) command will cause the graphical interface to be presented. In this case, whenever one of the users specified in the user list issues the STRDBG command, they will see the iSeries Navigator System Debug Manager rather than the Command Entry display. If the ENDDBG command is entered and Debug in the System Debug Manager is not currently selected, then issuing the STRDBG command will again invoke the system debugger using the Command Entry display.

The following STRDBG command places the job in debug mode and adds program CUS310 as the program to be debugged.

STRDBG  PGM(CUS310)

The option exists to use the ILE source debugger to debug OPM programs. To create OPM programs that contain source debug data, specify the OPTION(*SRCDBG) parameter on the Create CL Program (CRTCLPGM) command. The source debug data is actually part of the program object.

To add OPM programs that get created containing source debug data to the ILE source debugger, use the Program (PGM) and OPM Source Level Debug (OPMSRC) parameters on the STRDBG command. To start a debug session with an OPM program created with source debug data, type:

STRDBG PGM(*LIBL/MYOPMPGM) OPMSRC(*YES) DSPMODSRC(*YES)

For more information on ILE source debugging , see Debugging ILE Programs.

Adding Programs to Debug Mode

Any program can be run in debug mode, but before you can debug it, you must put it in debug mode. You can place a program in debug mode by specifying it in the PGM parameter on the STRDBG command or by adding it to the debugging session with an Add Program (ADDPGM) command. You can specify as many as twenty (20) programs to be debugged simultaneously in a job. You must have *CHANGE authority to add a program to debug mode.

If you specified twenty (20) programs for debug mode (using either the STRDBG or ADDPGM command or both commands) and you want to add more programs to the debug job, you must remove some of the previously specified programs. Use the Remove Program (RMVPGM) command. When debug mode ends, all programs are automatically removed from debug mode.

When you start debug mode, you can specify that a program be a default program. By specifying a default program, you can use any debug command that has the PGM parameter without having to specify a program name each time a command is used. This is helpful if you are only debugging one program. For example, in the Add Breakpoint (ADDBKP) command, you would not specify a program name on the PGM parameter because the default program is assumed to be the program the breakpoint is being added to. The default program name must be specified in the list of programs to be debugged (PGM parameter). If more than one program is listed to be debugged, you can specify the default program on the DFTPGM parameter. If you do not, the first program in the list on the PGM parameter on the STRDBG command is assumed to be the default program.

The default program can be changed any time during testing by using either the Change Debug (CHGDBG) or the ADDPGM command.

Note:
If a program that is in debug mode is deleted, re-created, or saved with storage freed, references made to that program (except a RMVPGM command) may result in a function check. You must either remove the program using a RMVPGM command or end debug mode using an ENDDBG command. If you want to change the program and then debug it, you must remove it from debug mode and after it is re-created, add it to debug mode (ADDPGM command).

Preventing Updates to Database Files in Production Libraries

You can use files in production libraries while you are in debug mode. To prevent database files in production libraries from being unintentionally changed, you can specify UPDPROD(*NO) or default to *NO on the STRDBG command. Then, only files in test libraries can be opened for updating or adding new records. If you want to open database files in production libraries for updating or adding new records or if you want to delete members from production physical files, you can specify UPDPROD(*YES).

You can use this function with the library list. In the library list for your debug job, you can place a test library before a production library. You should have copies of the production files that might be updated by the program being debugged in the test library. Then, when the program runs, it uses the files in the test library. Therefore, production files cannot be unintentionally updated.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]