Debugging Programs
Debugging allows you to detect, diagnose, and eliminate run-time errors in a program. You can debug ILE and OPM programs using the ILE source .
Use the debugger in Rational® Developer for i. This is the recommended method and documentation about debugging programs appears in that product's online help. 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 Rational Developer for i 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 window. Each session you debug is listed separately in the Debug view.
- Prepare your ILE RPG 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 breakpoints and watch conditions
- Step through a program
- Display and change the value of fields
- Display the attributes of fields
- Equate a shorthand name to a field, 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.
- Use the Start Debug (STRDBG) command and retain the default *NO for the UPDPROD 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 and specify UPDPROD NO
See the chapter on debugging in ILE Concepts for more information on the ILE source (including authority required to debug a program or service program and the effects of optimization levels).
- ===> CRTBNDRPG QTEMP/PROOF DBGVIEW(*ALL)
- ===> STRDBG QTEMP/PROOF
- Set a breakpoint on one of the calculation lines by putting your cursor on the line and pressing F6
- Exit the DSPMODSRC screen with F12
- ===> CALL QTEMP/PROOF
You will see the source again, with your breakpoint line highlighted .
- Move your cursor over one of the variables in the program source (Definition, Input, Calculation or Output Specifications) and press F11. The value of the variable will appear at the bottom of the screen
- Step through the rest of the program by pressing F10, or run to the end with F12
After setting breakpoints, you do not have to call the program directly. You can start an application that will eventually call the program.
If you step through the whole program, it will step through the Input and Output specifications. If you prefer to skip over Input and Output specifications, you can specify OPTION(*NODEBUGIO) in your Header specification or when you compile your program.
More details on these steps will be given in the rest of this chapter.