Debugging Language; Debugging Lines; Declarative Procedures - Use For Debugging; Example - Cobol Debugging Language - IBM 5280 Programmer's Manual

Distributed data system, cobol
Hide thumbs Also See for 5280:
Table of Contents

Advertisement

Debugging Language
COBOL provides two switches which ease the writing of error-free programs:
• The WITH DEBUGGING MODE switch, which serves as a compile-time
switch for debugging statements written into the source program
• The DEBUG jNODEBUG switch, which serves as an object-time switch
that activates debugging procedures written into your program
Information on how to use these two switches is covered in the sections that
follow. For detailed information, see the section "Debugging" in Part V of the
COBOL Language Reference.
Debugging Lines - WITH DEBUGGING MODE
A debugging line is any COBOL statement you write in your program with a
D in column 7. You can use debugging lines to assist in locating logical errors
in your program. When you write a WITH DEBUGGING MODE clause in
the SOURCE-COMPUTER paragraph of the Configuration Section, the
debugging lines are made a part of the object code and will be executed with
the object program.
If the WITH DEBUGGING MODE clause is removed, the debugging lines
will be treated as comments and will not be executed.
The execution-time options DEBUG or NODEBUG (discussed in Chapter 8)
do not affect debugging lines; they affect only the USE FOR DEBUGGING
declarative, as described in the next section.
Declarative Procedures - USE FOR DEBUGGING
The USE FOR DEBUGGING declarative allows you to create procedures
within your program to examine its internal status during execution. With the
USE FOR DEBUGGING dec1arative, you identify program elements you
wish to monitor. COBOL then gives control to your debugging procedure
when these elements are referenced during execution. Your procedure also
has access to the DEBUG-ITEM special register, which contains information
about the conditions causing the activation of the debugging procedure.
You can control the USE FOR DEBUGGING procedures with two switches:
the WITH DEBUGGING MODE source clause at compile-time, and the
DEBUG jNODEBUG option at execution-time. If you specify WITH
DEBUGGING MODE, COBOL compiles the procedures as executable code;
otherwise COBOL treats them as comments.
If you specify WITH DEBUGGING MODE at compile time, and the
DEBUG option at execution-time, the debugging procedures will be executed;
if you specify WITH DEBUGGING MODE at compile time, and the
NODEBUG option at executi?fi time, the procedures will be bypassed.
Example - COBOL Debugging Language
The example in figure 9.1 shows the use of debugging lines and a debugging
dec1arative procedure. Here is an explanation of some of the statements
(keyed to the example) used:
The WITH DEBUGGING MODE clause of the SOURCE-COMPUTER
paragraph at
II
causes the debugging statements in the program to be
compiled.
Each time the paragraph READ-MASTER at
EJ
is entered, control is passed
to the statements following USE FOR DEBUGGING ON READ-MASTER
at
fJ.
After the statement executes, control is returned to READ- MASTER,
9- 4
IBM 5280 COBOL Programmer's Guide

Advertisement

Table of Contents
loading

Table of Contents