Debugging: cobcdebug and -g
| Compile with -g | |
| Run the debugger | |
| DISPLAY as a poor man debugger |
Compile with -g
Add -g when compiling to keep source lines in the object. Without it the debugger shows machine-level views only:
cobc -x -free -g -o payroll payroll.cob
Run the debugger
GnuCOBOL ships cobcdebug, a source-level debugger. Set breakpoints by paragraph name, step sentence by sentence, and print any working-storage field by name:
cobcdebug ./payroll
break PROCESS-ROW
run
display WS-TOTAL-PAY
DISPLAY as a poor man debugger
In production shops, a temporary DISPLAY of the suspect field is still the fastest way to see a value. Remove it before release: stray DISPLAY lines are a classic mainframe audit finding.
Next: Encodings: EBCDIC, ASCII and UTF-8
Article author: Arthur Isaev