Debugging with conditional breakpoints

Debugging has come a long, long way since the STRISDB and command line ADDBKP days. When used properly the ILE source debug is an awesome, robust tool.

In previous articles we have talked about;
control specifications for *srcstmt and *nodebugio,
compile time debug options, and
debugging submitted jobs.

Many who have used the ILE RPG source debug facility setting breakpoints and stepping through programs is probably routine. One key feature that some programmers either inadvertently miss or incorrectly ignore is setting conditional breakpoints. For example, you are debugging some code that is within a read loop. The loop may iterate many times and stopping at an unconditional breakpoint repeatedly is time consuming and, as it should become apparent, unnecessary.

During the read loop let's say you only want to stop the program to review field values when a certain condition is met. In this case the only time the program really needs to be interrupted is when the condition is met. With this method it is not even necessary for the file to be keyed or read in any particular order. The program will proceed as it normally would and only reach the breakpoint for the record(s) that meet your criteria.

After issuing a STRDBG command (preferably with debug source view set to *LIST, *SOURCE, or *ALL) add a breakpoint with F6 and use "F13=work with module breakpoints".

Next, set the conditional breakpoint, the condition upon which the program should stop and redisplay the source debug screen.

Many thanks to alert reader Yan Shargorodsky who pointed out the preferable method of entering the condition on the debug line;

Conclusion: While this is just "refresher" material for many, for any ILE programmer who has not used conditional breakpoints, stop, take the time to learn how! Getting the hang of this debug feature will be well worth the time invested.