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.
  • SOURCE-COMPUTER statement, an important part of your code, should always include 'WITH DEBUGGING MODE' in the CONFIGURATION-SECTION of ENVIRONMENT DIVISION. This enables the debugging mode in the program.
  • 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, it should be coded in Area-B in PROCEDURE DIVISION.

Syntax -

Parameters -

  • computer-name - Specifies which 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 -


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

Code -

----+----1----+----2----+----3----+----4----+----5----+
       ...
       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".
	       ...

Output -

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