The USE FOR DEBUGGING Statement

General Format


*

RTS switches

  1. The following RTS switch may impact either the syntax or semantics described in this section.
    • D – Activates ANSI Debug facilities

Syntax Rules

  1. Debugging section(s), if specified, must appear together immediately after the DECLARATIVES header.
  2. Except in the USE FOR DEBUGGING statement itself, there must be no reference to any non-declarative procedure in the debugging section.

    OSVSVSC2MF This restriction is not enforced.

  3. Statements appearing outside of the set of debugging sections must not reference procedure-names defined in the set of debugging sections.
  4. Except for the USE FOR DEBUGGING statement itself, statements appearing in a given debugging section can reference procedure-names defined in a different USE procedure only with a PERFORM statement.
  5. Procedure-names defined in debugging sections must not appear in USE FOR DEBUGGING statements.
  6. Any given identifier, file-name, or procedure-name can appear in only one USE FOR DEBUGGING statement and can appear only once in that statement.
  7. The ALL PROCEDURES phrase can appear only once in a program.
  8. When the ALL PROCEDURES phrase is specified, procedure-name-1 must not be specified in any USE FOR DEBUGGING statement.
  9. If the data description entry of the data item referenced by identifier-1 contains an OCCURS clause or is subordinate to a data description entry that contains an OCCURS clause, identifier-1 must be specified without the subscripting or indexing normally required.
  10. References to the special register DEBUG-ITEM are restricted to references from within a debugging section.

General Rules

  1. Automatic execution of a debugging section is not caused by a statement appearing in a debugging section.
  2. When file-name-1 is specified in a USE FOR DEBUGGING statement , that debugging section is executed:
    1. After the execution of any OPEN or CLOSE statement that references file-name-1, and:
    2. After the execution of any READ statement (after any other specified USE procedure) not resulting in the execution of an associated AT END or INVALID KEY imperative statement, and:
    3. After the execution of any DELETE or START statement that references file-name-1.
  3. When procedure-name-1 is specified in a USE FOR DEBUGGING statement that debugging section is executed:
    1. Immediately before each execution of the named procedure.
    2. Immediately after the execution of an ALTER statement which references procedure-name-1.
  4. The ALL PROCEDURES phrase causes the effects described in General Rule 3 to occur for every procedure-name in the program, except those appearing in a debugging section.
  5. When the phrase, ALL REFERENCES OF identifier , is specified, that debugging section is executed for every statement that explicitly references identifier-1 at each of the following times:
    1. In the case of a WRITE or REWRITE statement immediately before the execution of that WRITE or REWRITE statement and after the execution of any implicit move resulting from the presence of the FROM phrase.
    2. In the case of a GO TO statement with a DEPENDING ON phrase, immediately before control is transferred and prior to the execution of any debugging section associated with the procedure-name to which control is to be transferred.
    3. In the case of a PERFORM statement in which a VARYING, AFTER, or UNTIL phrase references identifier-1, immediately after each initialization, modification or evaluation of the contents of the data item referenced by identifier-1.
    4. In the case of any other COBOL statement, immediately after execution of that statement.

    If identifier-1 is specified in a phrase that is not executed or evaluated, the associated debugging section is not executed.

  6. When identifier-1 is specified without the ALL REFERENCES OF phrase , that debugging section is executed at each of the following times:
    1. In the case of a WRITE or REWRITE statement that explicitly references identifier-1, immediately before the execution of that WRITE or REWRITE statement and after the execution of any implicit move resulting from the presence of the FROM phrase.
    2. In the case of a PERFORM statement in which a VARYING, AFTER or UNTIL phrase references identifier-1, immediately after each initialization, modification or evaluation of the contents of the data item referenced by identifier-1.
    3. Immediately after the execution of any other COBOL statement that explicitly references and causes the contents of the data item referenced by identifier-1 to be changed.

    If identifier-1 is specified in a phrase that is not executed or evaluated, the associated debugging section is not executed.

  7. The associated debugging section is not executed for a specific operand more than once as a result of the execution of a single statement, regardless of the number of times that operand is explicitly specified. In the case of a PERFORM statement which caused iterative execution of a referenced procedure, the associated debugging section is executed once for each iteration.

    Within an imperative statement, each individual occurrence of an imperative verb identifies a separate statement for the purpose of debugging.

  8. A reference to file-name-1, identifier-1, or procedure-name-1 as a qualifier does not constitute reference to that item for the debugging described in the General Rules above.
  9. Associated with each execution of a debugging section is the special register DEBUG-ITEM , which provides information about the conditions that caused the execution of a debugging section . DEBUG-ITEM has the following implicit description:
     01 debug-item.
         02 debug-line      pic x(6).
         02 filler          pic x value space.
         02 debug-name      pic x(30).
         02 filler          pic x value space.
         02 debug-sub-1     pic s9999 sign is leading separate character.
         02 filler          pic x value space
         02 debug-sub-2     pic s9999 sign is leading separate character.
         02 filler          pic x value space.
         02 debug-sub-3     pic s9999 sign is leading separate character.
         02 filler          pic x value space.
         02 debug-contents  pic x(n).
  10. Prior to each execution of a debugging section, the contents of the data item referenced by DEBUG-ITEM are space-filled. The contents of data items subordinate to DEBUG-ITEM are then updated, according to the following general rules, immediately before control is passed to that debugging section. The contents of any data item not specified in the following general rules remains spaces.

    Updating is accomplished in accordance with the rules for the MOVE statement, the sole exception being the move to DEBUG-CONTENTS when the move is treated exactly as if it was an alphanumeric to alphanumeric elementary move with no conversion of data from one form of internal representation to another.

  11. The contents of DEBUG-LINE is the relevant COBOL source line number. This provides the means of identifying a particular source statement.
  12. DEBUG-NAME contains the first 30 characters of the name that caused the debugging section to be executed.

    All qualifiers of the name are separated in DEBUG-NAME by the word IN or OF.

    Subscripts/indices, if any, are not entered into DEBUG-NAME.

  13. If the reference to a data item that causes the debugging section to be executed is subscripted or indexed, the occurrence number of each level is entered in DEBUG-SUB-1, DEBUG-SUB-2, DEBUG-SUB-3, respectively, as necessary.
  14. DEBUG-CONTENTS is a data item that is large enough to contain the data required by the following General Rules.
  15. If the first execution of the first nondeclarative procedure in the program causes the debugging section to be executed, the following conditions exist:
    1. DEBUG-LINE identifies the first statement of that procedure.
    2. DEBUG-NAME contains the name of that procedure.
    3. DEBUG-CONTENTS contains "START PROGRAM".
  16. If a reference to procedure-name-1 in an ALTER statement causes the debugging section to be executed, the following conditions exist:
    1. DEBUG-LINE identifies the ALTER statement that references procedure-name-1.
    2. DEBUG-NAME contains procedure-name-1.
    3. DEBUG-CONTENTS contains the applicable procedure-name associated with the TO phrase of the ALTER statement.
  17. If the transfer of control associated with the execution of a GO TO statement causes the debugging section to be executed, the following conditions exist:
    1. DEBUG-LINE identifies the GO TO statement whose execution transfers control to procedure-name-1.
    2. DEBUG-NAME contains procedure-name-1.
  18. If reference to procedure-name-1 in the INPUT or OUTPUT phrase of a SORT or MERGE statement causes the debugging section to be executed, the following conditions exist:
    1. DEBUG-LINE identifies the SORT or MERGE statement that references procedure-name-1.
    2. DEBUG-NAME contains procedure-name-1.
    3. DEBUG-CONTENTS contains:
      1. If the reference to procedure-name-1 is the INPUT phrase of a SORT statement, "SORT INPUT".
      2. If the reference to procedure-name-1 is in the OUTPUT phrase of a SORT statement, "SORT OUTPUT".
      3. If the reference to procedure-name-1 is in the OUTPUT phrase of a MERGE statement, "MERGE OUTPUT".
  19. If the transfer to control from the control mechanism associated with a PERFORM statement causes the debugging section associated with procedure-name-1 to be executed, the following conditions exist:
    1. DEBUG-LINE identifies the PERFORM statement that references procedure-name-1.
    2. DEBUG-NAME contains procedure-name-1.
    3. DEBUG-CONTENTS contains "PERFORM LOOP".
  20. If procedure-name-1 is a USE procedure that is to be executed, the following conditions exist:
    1. DEBUG-LINE identifies the statement that causes execution of the USE procedure.
    2. DEBUG-NAME contains procedure-name-1.
    3. DEBUG-CONTENTS contains "USE PROCEDURE".
  21. If an implicit transfer of control from the previous sequential paragraph to procedure-name-1 causes the debugging section to be executed, the following conditions exist:
    1. DEBUG-LINE identifies the previous statement.
    2. DEBUG-NAME contains procedure-name-1.
    3. DEBUG-CONTENTS contains "FALL THROUGH".
  22. If references to file-name-1 cause the debugging section to be executed, then:
    1. DEBUG-LINE identifies the source statement that references file-name-1 .
    2. DEBUG-NAME contains the name of file-name-1 .
    3. For READ, DEBUG-CONTENTS contains the entire record read.
    4. For all other references to file-name-1, DEBUG-CONTENTS contains spaces.
  23. If a reference to identifier-1 causes the debugging section to be executed, then:
    1. DEBUG-LINE identifies the source statement that references identifier-1,
    2. DEBUG-NAME contains the name of identifier-1, and:
    3. DEBUG-CONTENTS contains the contents of the data item referenced by identifier-1 at the time that control passes to the debugging section (see General Rules 5 and 6).