This topic describes the techniques you use to debug an application when you encounter a protection violation or an RTS error. It covers working with both intermediate and generated code.The techniques you use to debug a program depend on how the program is loaded or built. For example, if a program is built as an operating system executable file (such as an .exe file or a .dll file) the operating system loads the program and uses special privileges to partition memory for different usages and trap inappropriate references. For example it might split data and procedures and trap attempts to execute data or write over procedure code. When you run a program as an .int file or .gnt file, the operating system loads the run-time system, and the run-time system dynamically loads your COBOL program. In general, the run-time system cannot use the operating system's special privileges to load the COBOL program into protected areas. Instead, where appropriate, the COBOL system sets up its own COBOL traps in conjunction with the operating system general protection violation traps.
When you run a program as intermediate code and the COBOL system traps a protection violation, the run-time system gives an RTS error and identifies the program in which the error occurred. The run-time system also gives a reference to the COBOL source line which caused the failure. In order to identify the COBOL source line from the reference you must compile the source with the Compiler directives LIST() and REF. Each source line then has a reference at the extreme right of the listing which identifies the starting location for the procedure for each statement.
When you run a program as generated code and the COBOL system traps a protection violation, the run-time system gives an RTS error and identifies the program in which the error occurred, together with a reference to the native code instruction that caused the error. The run-time system also gives a reference to the COBOL source line which caused the failure. To match the native code instruction reference to the COBOL source line which caused the error, you need to compile with the Compiler directives SOURCEASM, ASMLIST and ASM. Specifying these directives causes the Compiler to create a .grp file which contains an assembler listing for your program, showing the relationship between COBOL program lines and native instructions.
To eliminate an RTS error use the Run operation of the debugger to run the program until the error occurs, and when control is passed back to the debugger you can identify the line causing the error.
Related Topics: