Rational Developer for System z, Version 7.6

Debugging a non-Language Environment COBOL program in full-screen mode

The descriptions of basic debugging tasks for non-Language Environment COBOL refer to the following program.

Example: sample non-Language Environment COBOL program for debugging

As you read through the information in this document, remember that OS/VS COBOL programs are non-Language Environment programs, even though you might have used Language Environment libraries to link and run your program.

VS COBOL II programs are non-Language Environment programs when you compile them with the NOTEST compiler option and link them with a non-Language Environment library. VS COBOL II programs are Language Environment programs when you compile them with the TEST compiler option and link them with the Language Environment library.

Read the information regarding non-Language Environment programs for instructions on how to start Debug Tool and debug non-Language Environment COBOL programs, unless information specific to non-Language Environment COBOL is provided.

Example: sample non-Language Environment COBOL program for debugging

The program below is used in various topics to demonstrate debugging tasks. It is an OS/VS COBOL program which is being used as a representative of non-Language Environment COBOL programs.

To run this sample program, do the following steps:

  1. Prepare the sample program as described in Preparing a non-Language Environment COBOL program.
  2. Verify that the debug information for this program is located in the COB03O and COB03AO members of the yourid.EQALANGX data set.
  3. Start Debug Tool as described in Starting Debug Tool for programs that start outside of Language Environment.
  4. To load the debug information for this program, enter the following command:
    LDD (COB03O,COB03AO) ;

This program is a small example of an OS/VS COBOL program (COB03O) that calls another OS/VS COBOL program (COB03A0).

Load module: COB03O

COB03O

      ******************************************************            
      *  PROGRAM NAME: COB03O                              *            
      *                                                    *            
      *  COMPILED WITH IBM OS/VS COBOL COMPILER            *            
      ******************************************************            
                                                                        
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. COB03O.                                              
      ******************************************************************
      *                                                                *
      * LICENSED MATERIALS - PROPERTY OF IBM                           *
      *                                                                *
      * 5655-P14: Debug Tool for z/OS                                  *
      * (C) Copyright IBM Corp. 2005 All Rights Reserved               *
      *                                                                *
      * US GOVERNMENT USERS RESTRICTED RIGHTS - USE, DUPLICATION OR    *
      * DISCLOSURE RESTRICTED BY GSA ADP SCHEDULE CONTRACT WITH IBM    *
      * CORP.                                                          *
      *                                                                *
      *                                                                *
      ******************************************************************
       ENVIRONMENT DIVISION.                                            
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
                                                                        
       01  LOAN          PIC 999999.                                    
       01  INTEREST-RATE PIC 99V99.                                     
       01  INTEREST-DUE  PIC 999999.                                    
       01  INTEREST-SAVE PIC 999999.                                    
       01  INTEREST-AFTER-MULTIPLY PIC 999999.                          
       01  INTEREST-AFTER-DIVIDE PIC 999999.                            
                                                                        
      * DATE THAT WILL RECEIVE INCREMENTED JULIAN-DATE                  
       01  INC-DATE            PIC 9(7).                                
      * LOOP COUNT TO INCREMENT DATE 1000 TIMES *                       
       01  LOOPCOUNT           PIC   9999.                              
                                                                        
      * JULIAN DATE                                               
       01  JULIAN-DATE         PIC 9(7).                          
       01  J-DATE REDEFINES JULIAN-DATE.                          
           05 J-YEAR           PIC 9(4).                          
           05 J-DAY            PIC 9(3).                          
      * SAVE DATE                                                 
       01  SAVE-DATE           PIC 9(7).                          
                                                                        
       PROCEDURE DIVISION.                                        
                                                                  
       PROG.                                                      
           ACCEPT JULIAN-DATE FROM DAY                            
           DISPLAY 'JULIAN DATE: ' JULIAN-DATE                    
           MOVE JULIAN-DATE TO SAVE-DATE                          
                                                                  
           MOVE 10000    TO LOAN                                  
                                                                  
           CALL 'COB03AO' USING LOAN INTEREST-DUE.                
                                                                  
           DISPLAY 'LOAN: ' LOAN                                  
           DISPLAY 'INTEREST-DUE: ' INTEREST-DUE                  
                                                                  
           STOP RUN.                                              

COB03AO

      ******************************************************            
      *  PROGRAM NAME: COB03AO                             *            
      *                                                    *            
      *  COMPILED WITH IBM OS/VS COBOL COMPILER            *            
      ******************************************************            
                                                                        
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. COB03AO.                                             
      ******************************************************************
      *                                                                *
      * LICENSED MATERIALS - PROPERTY OF IBM                           *
      *                                                                *
      * 5655-P14: Debug Tool for z/OS                                  *
      * (C) Copyright IBM Corp. 2005 All Rights Reserved               *
      *                                                                *
      * US GOVERNMENT USERS RESTRICTED RIGHTS - USE, DUPLICATION OR    *
      * DISCLOSURE RESTRICTED BY GSA ADP SCHEDULE CONTRACT WITH IBM    *
      * CORP.                                                          *
      *                                                                *
      *                                                                *
      ******************************************************************
       ENVIRONMENT DIVISION.                                            
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
       77  INTEREST-RATE PIC 99V99 VALUE 0.22.                          
       LINKAGE SECTION.                                                 
       01  USING-LIST.                                                  
           02 LOANAMT   PIC 999999.                                     
           02 INTEREST  PIC 999999.                                     
                                                                        
                                                                        
       PROCEDURE DIVISION USING USING-LIST.                             
                                                                        
       PROG.                                                            
           COMPUTE INTEREST = LOANAMT * INTEREST-RATE.                  
           DISPLAY 'INTEREST-RATE: ' INTEREST-RATE.                     
                                                                        
           GOBACK.                                                       

Defining a compilation unit as non-Language Environment COBOL and loading debug information

Before you can debug a non-Language Environment COBOL program, you must define the compilation unit (CU) as a non-Language Environment COBOL CU and load the debug data for the CU. This can only be done for a CU that is currently known to Debug Tool as a disassembly CU or for a CU that is not currently known to Debug Tool.

You use the LOADDEBUGDATA command (abbreviated as LDD) to define a disassembly CU as a non-Language Environment COBOL CU and to cause the debug data for this CU to be loaded. When you invoke the LDD command, you can specify either a single CU name or a list of CU names enclosed in parenthesis. Each of the names specified must be either:

When the CU name is currently known to Debug Tool, the CU is immediately marked as a non-Language Environment COBOL CU and an attempt is made to load the debug as follows:

When the CU name specified on the LDD command is not currently known to Debug Tool, a message is issued and the LDD command is deferred until a CU by that name becomes known (appears). At that time, the CU is automatically created as a non-Language Environment COBOL CU and an attempt is made to load the debug data using the default data set name or the current SET DEFAULT LISTINGS specification.

After you have entered an LDD command for a CU, you cannot view the CU as a disassembly CU.

If Debug Tool cannot find the associated debug data after you have entered an LDD command, the CU is a non-Language Environment COBOL CU rather than a disassembly CU. You cannot enter another LDD command for this CU. However, you can enter a SET DEFAULT LISTING command or a SET SOURCE command to cause the associated debug data to be loaded from a different data set.

Defining a compilation unit in a different load module as non-Language Environment COBOL

You must use the LDD command to identify a CU as a non-Language Environment COBOL CU. If the CU is part of a load module that has not yet been loaded when you enter the LDD command, Debug Tool displays a message indicating that the CU was not found and that the running of the LDD command has been deferred. If the CU later appears as a disassembly CU, the LDD command is run at that time.

Refer to the following topics for more information related to the material discussed in this topic.

Halting when certain non-Language Environment COBOL programs are called

Example: sample non-Language Environment COBOL program for debugging

To halt after the COB03AO routine is called, enter the following command:

AT ENTRY COB03AO ;

The AT CALL command is not supported for non-Language Environment COBOL routines. Do not use the AT CALL command to halt Debug Tool when a non-Language Environment COBOL routine is called.

Identifying the statement where your non-Language Environment COBOL program has stopped

If you have many breakpoints set in your program and you want to know where your program was halted, you can enter the following command:

QUERY LOCATION

The Debug Tool Log window displays a message similar to the following message:

QUERY LOCATION 
You are executing commands in the ENTRY COB03O ::> COB03AO breakpoint.
The program is currently entering block COB03O ::> COB03AO.

Displaying and modifying the value of non-Language Environment COBOL variables or storage

To display the contents of a single variable, move the cursor to an occurrence of the variable name in the Source window and press PF4 (LIST). The value is displayed in the Log window. This is equivalent to entering the LIST variable command on the command line.

For example, run the COB03O program to the CALL statement by entering AT 56 ; GO ; on the Debug Tool command line. Move the cursor over LOAN and press PF4 (LIST). Debug Tool displays the following message in the Log window:

LIST ( 'LOAN ')
LOAN = 10000 

To change the value of LOAN to 100, type 'LOAN' = '100' in the command line and press Enter.

To view the attributes of variable LOAN, enter the following command:

DESCRIBE ATTRIBUTES LOAN

Debug Tool displays the following messages in the Log window:

ATTRIBUTES for LOAN 
   Its address is 0002E500 and its length is 6
   LOAN PIC 999999 

To step into the call to COB03AO, press PF2 (STEP).

Halting on a line in non-Language Environment COBOL only if a condition is true

Often a particular part of your program works fine for the first few thousand times, but it fails under certain conditions. Setting a line breakpoint is inefficient because you will have to repeatedly enter the GO command.

Example: sample non-Language Environment COBOL program for debugging

In the COB03AO program, to halt Debug Tool when the LOANAMT variable is set to 100, enter the following command:

AT 36 DO; IF 'LOANAMT ^= 100' THEN GO; END;

Line 36 is the line COMPUTE INTEREST = LOANAMT * INTEREST-RATE. The command causes Debug Tool to stop at line 36. If the value of LOANAMT is not 100, the program continues. The command causes Debug Tool to stop on line 36 only if the value of LOANAMT is 100.

Debugging non-Language Environment COBOL when debug information is only available for a few parts

Example: sample non-Language Environment COBOL program for debugging

Suppose you want to set a breakpoint at the entry point to COB03AO program and that debug information is available for COB03AO but not for COB03O. In this circumstance, Debug Tool would display an empty Source window. To display a list of compile units known to Debug Tool, enter the following commands:

SET ASSEMBLER ON 
LIST NAMES CUS 

The LIST NAMES CUS command displays a list of all the compile units that are known to Debug Tool. If COB03AO is fetched later on by the application, it might not be known to Debug Tool. Enter the following commands:

LDD COB03AO
AT ENTRY COB03AO
GO

Getting a non-Language Environment COBOL program traceback

Often when you get close to a programming error, you want to know what sequence of calls lead you to the programming error. This sequence is called a traceback or a traceback of callers. To get the traceback information, enter the following command:

LIST CALLS

Example: sample non-Language Environment COBOL program for debugging

For example, if you run the example with the following commands, the Log window displays the traceback of callers:

LDD (COB03O,COB03AO) ;
AT ENTRY COB03AO ;
GO ;
LIST CALLS ;

The Log window displays information similar to the following:

At ENTRY in non-LE COBOL program COB03O ::> COB03AO.
From LINE 74 in non-LE COBOL program COB03O ::> COB03O.

Finding unexpected storage overwrite errors in non-Language Environment COBOL

While your program is running, some storage might unexpectedly change its value and you want to find out when and where this happened. Suppose in the example described in Getting a non-Language Environment COBOL program traceback, the program finds the value of LOAN unexpectedly modified. To set a breakpoint that watches for a change in the value of LOAN, enter the following command:

AT CHANGE 'LOAN';

When the program runs, Debug Tool stops if the value of LOAN changes.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)