Finding unexpected storage overwrite errors in COBOL
During program run time, some storage might unexpectedly change
its value and you want to find out when and where this happened.
Consider this example where the program changes more than the caller
expects it to change.
05 FIELD-1 OCCURS 2 TIMES
PIC X(8).
05 FIELD-2 PIC X(8).
PROCEDURE DIVISION.
* ( An invalid index value is set )
MOVE 3 TO PTR.
MOVE "TOO MUCH" TO FIELD-1( PTR ).
Find the address
of FIELD-2
with the command: DESCRIBE ATTRIBUTES FIELD-2
Suppose the result is X'0000F559'. To set a breakpoint that
watches for a change in storage values starting at that address for
the next 8 bytes, issue the command: AT CHANGE %STORAGE(H'0000F559',8)
When the program runs, z/OS® Debugger halts
if the value in this storage changes.