Understanding Debug and ILE RPG compile options

Compiling ILE RPG programs with different debugging view options can make a big difference. Understanding these options can make debugging ILE RPG a breeze.

Debugging View:
(*SOURCE)
  • No copy (/CPY) included in debug source view
  • No watch variables
  • File I/O causes debug to stop on file specifications
(*COPY)
  • Same as *SOURCE except copy (/CPY) statements can be viewed.
(*LIST)
  • Copy source allow can be viewed
  • Watch variable can be used
  • File I/O will not stop on file specifications. Rather the source lines continue after the file (READ, CHAIN, READP, etc.)

(*ALL)
  • Simliar to *LIST but also depends on the parameters set in the Compiler options (OPTION) field.

Another method to prevent your debug session from stepping through file I/O is to specify *NODEBUGIO on an H specification in your program. It is also best to specify *SRCSTMT to match the debug output with the actual source code. In other words, *SRCSTMT will deny the compiler the right to renumber source lines.

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
H option(*SRCSTMT *NODEBUGIO)


Conclusion: Compiler default debugging view should be set to *LIST or *ALL (in a developer's environment). Compiler options entered on H-specs will override whatever parameters are used when compiling the program. The compiler defaults can be overridden by entering options on the header (H spec) of the RPG program.  Be aware that optimizing programs can affect your debug results.  With an Optimize setting of Full, 30, or 40 the field values may not be current!