Debugging Lines


  • A debugging line is any line with a 'D' or 'd' in column 7 (indicator area) used to debug the program flow when no debugging tools are available.
  • The SOURCE-COMPUTER statement should code "WITH DEBUGGING MODE" in the CONFIGURATION-SECTION of ENVIRONMENT DIVISION to enable the debugging line.
  • Debugging lines can code in the ENVIRONMENT DIVISION, the DATA DIVISION, and the PROCEDURE DIVISION.
  • The debugging line code can start in either Area-A or Area-B. However, the debugging line should code in Area-B in PROCEDURE DIVISION.

Syntax -

SOURCE-COMPUTER Paragraph Syntax

Parameters -

  • computer-name - Specifies on which the source code is to be compiled.
  • WITH DEBUGGING MODE -
    • WITH DEBUGGING MODE is a compile-time switch that activates the debugging lines as executable code.
    • If SOURCE-COMPUTER WITH DEBUGGING MODE is coded, the program recognizes the statements with 'D' in the 7th column as part of the code. During the execution, the statements get executed along with the flow.
    • If SOURCE-COMPUTER WITH DEBUGGING MODE is not coded, the program doesn't recognize the statements with 'D' in the 7th column as a part of the code. The statements are not considered and ignored during the program execution.

Practical Examples -


Scenario1 - Describes how the DEBUGGING LINES enabled in COBOL programming.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. DEBUGLIN.
       AUTHOR. MTH. 
	   
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE. 
       OBJECT-COMPUTER. IBM-370.

       DATA DIVISION.
       WORKING-STORAGE SECTION. 
      D 01 WS-VAR1       PIC X(10) VALUE "MAINFRAMES". 

       PROCEDURE DIVISION.

      D    DISPLAY "DEBUGGING MODE ON".
           DISPLAY "DEBUGGING MODE EXAMPLE".
      D    DISPLAY "WS-VAR1: " WS-VAR1.
      D    DISPLAY "DEBUGGING MODE END".

           STOP RUN.

Output -

DEBUGGING MODE ON
DEBUGGING MODE EXAMPLE
WS-VAR1: MAINFRAMES
DEBUGGING MODE END

Explaining Example -

DEBUGGING MODE is ON. So, all the statements with D in the 7th column are considered part of the code and produce the above result.

Scenario2 - Describes how the DEBUGGING LINES disabled in COBOL programming.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. DEBUGLIN.
       AUTHOR. MTH.

       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION. 
       SOURCE-COMPUTER. IBM-370.
       OBJECT-COMPUTER. IBM-370. 

       DATA DIVISION.
       WORKING-STORAGE SECTION. 
      D 01 WS-VAR1       PIC X(10) VALUE "MAINFRAMES".

       PROCEDURE DIVISION. 

      D    DISPLAY "DEBUGGING MODE ON". 
           DISPLAY "DEBUGGING MODE EXAMPLE". 
      D    DISPLAY "WS-VAR1: " WS-VAR1.
      D    DISPLAY "DEBUGGING MODE END".

           STOP RUN.

Output -

DEBUGGING MODE EXAMPLE

Explaining Example -

DEBUGGING MODE is OFF. So, all statements with D in the 7th column are considered dummy lines. The statements that do not have D in the 7th column are considered part of the code and produce the above output.