COBOL - Group home

Debug Tool support for COBOL 5.1: STEP OVER an out-of-line PERFORM

  

This blog points out some of the improvements you'll see compared to debugging earlier versions of Enterprise COBOL regarding Debug Tool's behaviour when stepping over an out-of-line PERFORM. An out-of-line PERFORM is like a procedure call that entails a branch to a named paragraph and an implicit return from that paragraph. This is somewhat similar to calling a sub-program using the CALL statement, although in the case of a PERFORM there is no stack frame created, no parameters passed, etc.              
With previous versions of Enterprise COBOL, it was not possible to step over an out-of-line PERFORM and continue at the next statement following the PERFORM, as one could do with a CALL to a sub-program. The stepping behaviour was to always step into the paragraph that is the target of the PERFORM, and from there you would then step through the statements in that paragraph until control returns to the statement following the PERFORM. This can be very tedious and time-consuming if one has no interest in stepping through the statements in the target paragraph.

With COBOL V5.1, step over behaves the same for an out-of-line PERFORM as it does for a CALL to a sub-program: Instead of stepping into the target paragraph, the STEP OVER command runs the program until control reaches the statement following the PERFORM. Debug Tool then stops execution at that statement and waits for your next command.

To illustrate the COBOL V4.2 behaviour, I've annotated the following simple program to show what a STEP OVER command will do when execution is at the PERFORM statement:

 IDENTIFICATION DIVISION.
PROGRAM-ID blog.

PROCEDURE DIVISION.

PERFORM PARA1 <=== Do a STEP OVER here
STOP RUN.

PARA1.
DISPLAY 'Start of PARA1' <=== You will end up here
* Do a bunch of stuff
DISPLAY 'End of PARA1'.

END PROGRAM blog

As you can see, the STEP OVER command has actually stepped into the paragraph PARA1 instead of stepping to the statement following the PERFORM (STOP RUN in this case). In order to replicate the proper STEP OVER behaviour one would have to set a breakpoint or use the RUNTO command to get execution to stop at the statement following the PERFORM.

By contrast, here's what will happen when debugging a COBOL V5.1 program:
 IDENTIFICATION DIVISION.
PROGRAM-ID blog.

PROCEDURE DIVISION.

PERFORM PARA1 <=== Do a STEP OVER here
STOP RUN. <=== You will end up here

PARA1.
DISPLAY 'Start of PARA1'
* Do a bunch of stuff
DISPLAY 'End of PARA1'.

END PROGRAM blog

In this case Debug Tool has executed the paragraph PARA1 and then stopped execution at the STOP RUN statement.


If you really do want to step into the paragraph that is the target of the PERFORM you can still use the STEP INTO command to do so:

 IDENTIFICATION DIVISION.
PROGRAM-ID blog.

PROCEDURE DIVISION.

PERFORM PARA1 <=== Do a STEP INTO here
STOP RUN.

PARA1.
DISPLAY 'Start of PARA1' <=== You will end up here
* Do a bunch of stuff
DISPLAY 'End of PARA1'.

END PROGRAM blog

To summarize, with COBOL V5.1 Debug Tool treats an out-of-line PERFORM statement similar to a CALL statement when it comes to the behaviour of the STEP OVER command - when the step is done you will end up on the statement following the PERFORM instead of inside the paragraph being performed.