Previous Topic: Preliminary ComputationsNext Topic: PL/I Programs


Sample COBOL Online Debugger Session

To use the online debugger with a DC/UCF VS-COBOL program, perform the steps shown below. The steps may vary depending on the release level of the compiler; however, the basic methodology is the same. The following examples correspond to the sample listings shown in Preliminary Computations.

  1. Compile the program with the DMAP and CLIST compiler options before defining it to the DC/UCF system.

    Note: To obtain the complete Assembler source code, substituteCLIST with PMAP as described in Preliminary Computations.

  2. Record breakpoint and storage displacements, as explained earlier under COBOL Programs.
  3. Initiate the debugger session by entering the DEBUG task code from the DC/UCF system. The DEBUG> prompt displays indicating that the debugger is in control:
    ENTER NEXT TASK CODE:
    debug
    
    DEBUG>
    
  4. Specify the program to be debugged by entering DEBUG followed by the program name. The debugger verifies the program name:
    DEBUG>
    debug testprog
    
    DEBUG TESTPROG
    DEBUG> DEBUGGING INITIATED FOR TESTPROG VERSION 1
    DEBUG>
    
  5. Establish breakpoints by issuing the AT command followed by a dollar sign, which signifies the address of the beginning of the program; follow the dollar sign with the command's hexadecimal offset. The debugger verifies the establishment of the breakpoint. The following example sets a breakpoint at line 797 in TESTPROG based on the SOURCE and CLIST shown in Preliminary Computations.
    DEBUG>
    at $ + @1d4c
    
    AT $ + @1D4C
    AT> $ + @1D4C ADDED
    DEBUG>
    

    After all breakpoints have been set, leave the setup phase of the debugger session by issuing the EXIT command:

    DEBUG>
    exit
    

    Note: You will also be able to set new breakpoints whenever you are stopped at a breakpoint during the runtime phase.

  6. Initiate the runtime phase by issuing the task code that invokes the task in which the program participates:
    ENTER NEXT TASK CODE:
    deptmod
    

    When a breakpoint is encountered at runtime, the debugger assumes control and identifies the address, program, and the debugger expression that was used to establish the breakpoint:

    AT OFFSET @1D4C IN TESTPROG EXPRESSION $+@1D4C
    DEBUG>
    
  7. Examine program variable storage by issuing LIST commands. Use indirect addressing and the previously noted register and offset. The following example lists the value of the first 32 bytes of SUBSCHEMA-CTRL. The DMAP listing for SUBSCHEMA-CTRL shows that it is addressed through BL=1 at offset hexadecimal 260. The REGISTER ASSIGNMENT portion of the listing shows that base register 6 contains the value from BL=1.

    Note: Registers are sometimes used for multiple purposes within a COBOL program. When a breakpoint is set using the CLIST value, the equivalent assembler code to load the BL value into R6 may not have occurred. If you are not certain a register contains the appropriate value, use the method for listing LINKAGE SECTION variables described below. That method is also always valid for WORKING STORAGE variables.

    list %:r6 + @260 32
    
    LIST %:R6 + @260 32
    00140270  E3C5E2E3 D7D9D6C7 F0F0F0F0 3D3D4F06 *TESTPROG0000..|.*
    00140280  C4C5D7C1 D9E3D4C5 D5E34040 40404040 *DEPARTMENT      *
    

    To examine LINKAGE SECTION variables, perform the following steps:

    1. Register 13 normally contains the address of the TGT for VS-COBOL programs. Use register 9 for later COBOL compilers. Use the previously determined offset to find the desired BLL cell. The offset of the BLL cells for TESTPROG was found to be X'208', as shown in Preliminary Computations. The following command lists the BLL cells using indirect addressing.
      DEBUG>
      list %:rR13 + @208
      
      LIST %:R13 + @208
                 (BLL1)   (BLL2)   (BLL3)   (BLL4)
      001499E0  00000000 00000000 00000000 00149AC8 *...............H*
      

      Each BLL is 4-bytes long. Note the absolute address located in the BLL for the field that you want to display.

    2. Suppose we wish to display the field named ERROR-DATA. The DMAP shows that its base locator is in BLL=4. List the absolute address to display the first field.
      DEBUG>
      LIST @149ac8 9
      00149AC8  F1F1F1F1 C4C5D7E3 00                *1111DEPT        *
      
    3. Alternatively use an offset from the first field to display another field addressed through the same BLL. For example, use the following command to display ERROR-MESSAGE-CODE.
      DEBUG>
      LIST @149ac8+@4 4
      00149AC8  C4C5D7E3                             *DEPT            *
      
  8. Enter the RESUME command from the DEBUG> prompt to continue program execution:
    DEBUG>
    resume
    
  9. Enter the QUIT command from the DEBUG> prompt to end a debugger session:
    DEBUG>
    quit
    
    QUIT
    QUIT DEBUGGER
    ENTER NEXT TASK CODE: