Progress
Debugger Guide


Executing a Specified Number of Lines

Both the STEP and NEXT commands execute a procedure one or more lines at a time. However, the STEP command “steps into” any called subprocedure, continuing for the specified number of lines in the called subprocedure. The NEXT command “steps over” any called subprocedure, treating it as a statement and continuing execution for the specified number of lines in the current procedure. The NEXT command also honors breakpoints in the current or any called subprocedure, and completes execution at the first breakpoint encountered, stopping in a called subprocedure, if necessary. The STEP command ignores breakpoints; it always executes the number of lines you specify up to the application termination point.

STEP Command Subprocedure Processing

When the STEP command executes any line that calls a subprocedure, it performs these actions:

  1. Executes any statements on the line before the subprocedure call.
  2. Pushes the current (calling) procedure onto the procedure call stack, and executes the called subprocedure.
  3. Continues execution from the first executable line of the called subprocedure up to the last line specified for the STEP command.
  4. When the STEP command stops in a subprocedure, the subprocedure becomes the current procedure and the Debugger displays its listing with the line pointer on the next line to execute.

For example, suppose you are running the procedure fragments dbmain.p and dispmsg.p. In the Debugger, you are stopped on line 23 of dbmain.p and you have set a breakpoint on line 13 of dispmsg.p:

        1   /***** PROCEDURE: dbmain.p *****/ 
        2    
        3   DEFINE NEW SHARED VARIABLE MsgArray 
        4       AS CHARACTER FORMAT "x(40)" EXTENT 10 INITIAL [?]. 
                  . 
                  . 
                  . 
  =>   23   IF dberror THEN DO: 
       24      HIDE. 
       25      DisplayedMsg = TRUE. RUN dispmsg.p. InitialState = TRUE. 
       26      RETURN. 
       27   END. /* dberror */ 

You then enter this STEP command:

STEP 7 

The procedure dbmain.p executes through line 25 (two lines) where it calls dispmsg.p after executing the assignment to DisplayMsg. The procedure dispmsg.p then continues execution for five more executable lines (including the procedure call plus lines 9 through 13), and stops on line 14 displaying the following listing. Note that line 12 is considered nonexecutable and part of line 13 because it contains only part of a statement:

        1   /***** PROCEDURE: dispmsg.p *****/
        2   
        3   DEFINE SHARED VARIABLE MsgArray /* Array of message lines */
        4       AS CHARACTER FORMAT "x(40)" EXTENT 10.
        5   
        6   DEFINE VARIABLE MsgText AS CHARACTER FORMAT "x(4000)".
        7   DEFINE VARIABLE LineNo AS INTEGER.
        8   
        9   LineNo = 1.
       10   MsgText = "".
       11   REPEAT WHILE (LineNo <= EXTENT(MsgArray) AND 
       12                 MsgArray[LineNo] <> ?):
 *     13       MsgText = MsgText + MsgArray[LineNo] + "~012". /* + NL */
  =>   14       LineNo = LineNo + 1.
       15   END.
       16   
       17   MESSAGE MsgText VIEW-AS ALERT-BOX MESSAGE BUTTONS OK.
                  .
                  .
                  .
       24   MsgArray = ?. 

NEXT Command Subprocedure Processing

When the NEXT command executes a line that calls a subprocedure, it performs these actions:

  1. Executes any statements on the line before the subprocedure call.
  2. Executes the called subprocedure.
  3. If there are no breakpoints in the called subprocedure, it completes the called subprocedure and any remaining statements on the line.
  4. If it reaches a breakpoint, it pushes the current (calling) procedure onto the procedure call stack, and stops on the breakpoint line, making the procedure where the breakpoint occurred the current procedure and displaying its listing in the Debugger window.

For example, suppose you are running the procedure fragments dbmain.p and dispmsg.p. In the Debugger, you are stopped on line 23 of dbmain.p and you have set a breakpoint on line 13 of dispmsg.p:

        1   /***** PROCEDURE: dbmain.p *****/ 
        2    
        3   DEFINE NEW SHARED VARIABLE MsgArray  
        4       AS CHARACTER FORMAT "x(40)" EXTENT 10 INITIAL [?]. 
                  . 
                  . 
                  . 
  =>   23   IF dberror THEN DO: 
       24      HIDE. 
       25      DisplayedMsg = TRUE. RUN dispmsg.p. InitialState = TRUE. 
       26      RETURN. 
       27   END. /* dberror */ 

You then enter this NEXT command:

NEXT 3 

The procedure dbmain.p executes through line 25 (two lines) where it calls dispmsg.p after executing the assignment to DisplayMsg. The procedure dispmsg.p then continues execution through line 12, and stops at the breakpoint on line 13 displaying the following listing:

        1   /***** PROCEDURE: dispmsg.p *****/ 
        2   
        3   DEFINE SHARED VARIABLE MsgArray /* Array of message lines */ 
        4       AS CHARACTER FORMAT "x(40)" EXTENT 10. 
        5    
        6   DEFINE VARIABLE MsgText AS CHARACTER FORMAT "x(4000)". 
        7   DEFINE VARIABLE LineNo AS INTEGER. 
        8    
        9   LineNo = 1. 
       10   MsgText = "". 
       11   REPEAT WHILE (LineNo <= EXTENT(MsgArray) AND  
       12                 MsgArray[LineNo] <> ?): 
 *=>   13       MsgText = MsgText + MsgArray[LineNo] + "~012". /* + NL */ 
       14       LineNo = LineNo + 1. 
       15   END. 
       16    
       17   MESSAGE MsgText VIEW-AS ALERT-BOX MESSAGE BUTTONS OK. 
                  . 
                  . 
                  . 
       24   MsgArray = ?. 

Without the breakpoint in dispmsg.p, dbmain.p executes three executable lines stopping on line 26 at the RETURN statement.

STEP and NEXT Commands Inside a Subprocedure

From the current stopping point in the subprocedure, you can now execute any control flow command. If you invoke a STEP or NEXT command on the last executable line of the subprocedure, it performs these actions:

  1. Executes the last line of the subprocedure.
  2. Returns to the calling procedure, executing any remaining statements on the line of the subprocedure call.
  3. Continues on to the next executable line after the subprocedure call and executes the number of executable lines specified for the STEP or NEXT command minus one.

Thus if you invoke a one-line STEP or NEXT command on the last line of the subprocedure, it stops execution on the next line after the subprocedure call.

For example, suppose you are stopped on the last executable line of dispmsg.p:

        1   /***** PROCEDURE: dispmsg.p *****/
        2   
        3   DEFINE SHARED VARIABLE MsgArray /* Array of message lines */
        4       AS CHARACTER FORMAT "x(40)" EXTENT 10.
        5   
        6   DEFINE VARIABLE MsgText AS CHARACTER FORMAT "x(4000)".
        7   DEFINE VARIABLE LineNo AS INTEGER.
        8   
        9   LineNo = 1.
       10   MsgText = "".
       11   REPEAT WHILE (LineNo <= EXTENT(MsgArray) AND 
       12                 MsgArray[LineNo] <> ?):
       13       MsgText = MsgText + MsgArray[LineNo] + "~012". /* + NL */
       14       LineNo = LineNo + 1.
       15   END.
       16   
       17   MESSAGE MsgText VIEW-AS ALERT-BOX MESSAGE BUTTONS OK.
                  .
                  .
                  .
  =>   24   MsgArray = ?. 

You then enter the NEXT command:

NEXT 

This both executes the last line in dispmsg.p and completes execution of the line in dbmain.p (line 25) that called dispmsg.p, stopping on line 26 of dbmain.p and displaying the following listing:

        1   /***** PROCEDURE: dbmain.p *****/
        2   
        3   DEFINE NEW SHARED VARIABLE MsgArray 
        4       AS CHARACTER FORMAT "x(40)" EXTENT 10 INITIAL [?].
                  .
                  .
                  .
       23   IF dberror THEN DO:
       24      HIDE.
       25      DisplayedMsg = TRUE. RUN dispmsg.p. InitialState = TRUE.
  =>   26      RETURN.
       27   END. /* dberror */ 

Menu Options for the STEP and NEXT Commands

You can execute the STEP and NEXT commands by choosing the corresponding Debug Step and Debug Next options. Each option immediately invokes the specified command to execute a single line.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095