COBOL - Group home

Debug Tool support for COBOL 5.1: LENGTH OF and ADDRESS OF in AUTOMONITOR output

  

One of the improvements you'll see when debugging IBM Enterprise COBOL for z/OS V5.1 using Debug Tool compared to debugging earlier versions of Enterprise COBOL is regarding Debug Tool's AUTOMONITOR feature. Specifically, it is about how AUTOMONITOR handles statements that use the LENGTH OF or ADDRESS OF special registers.

I'll use this simple example program to illustrate the differences between COBOL 5.1 and earlier versions:

 IDENTIFICATION DIVISION. 
PROGRAM-ID blog.
DATA DIVISION.
WORKING-STORAGE SECTION.

01 STR PIC X(10) VALUE 'Hello'.
01 LEN PIC 9(9) USAGE BINARY VALUE 0.
01 PTR POINTER.

PROCEDURE DIVISION.
MOVE LENGTH OF STR TO LEN
SET PTR TO ADDRESS OF STR
STOP RUN.
END PROGRAM blog.

Our focus is on the statements that use LENGTH OF and ADDRESS OF:

 MOVE LENGTH OF STR TO LEN 
SET PTR TO ADDRESS OF STR
With previous versions of Enterprise COBOL, AUTOMONITOR would show you the value of the variable STR instead of showing you the length and address of that variable. With COBOL 5.1, AUTOMONITOR will now show you the length and address instead of the value.

To illustrate, when execution is on the first statement, this is the output for COBOL 4.2:

********** AUTOMONITOR ********** 
01 STR 'Hello '
01 LEN 0000000000

And this is the output for COBOL 5.1, showing you the length of STR instead of its value:

********** AUTOMONITOR ********** 
LENGTH OF STR 10
LEN 0000000000

Similarly, when execution is on the second statement, this is the output for COBOL 4.2:

********** AUTOMONITOR ********** 
01 PTR X'00000000'
01 STR 'Hello '

And this is the output for COBOL 5.1, showing you the address of STR instead of its value:

********** AUTOMONITOR ********** 
PTR X'472E6578'
ADDRESS OF STR X'27625500'

The length and address of STR are what the COBOL statements are using, and therefore showing these things in Debug Tool is more relevant than showing the value of STR. This also keeps the output of AUTOMONITOR more concise, especially if STR (or some other variable being used in the statement) was very long.

If one actually wants to see the value of STR, a LIST command can still be used to do so:

LIST STR ; 
STR = 'Hello '