Try OpenEdge Now
skip to main content
Debugging and Troubleshooting
OpenEdge Debugger : Using System Handles for Debugging : Using the DEBUGGER system handle to start and control the Debugger : Using the DEBUGGER system handle in application mode : Debugging a called subprocedure
Debugging a called subprocedure
To debug a subprocedure called from the invoking procedure:
1. Optionally, add a DEFINE VARIABLE statement that defines a logical variable you can use to assign the return value for DEBUGGER system handle methods.
2. Add a DEBUGGER system handle statement that invokes the INITIATE( ) method before the point where you want to begin debugging the called subprocedure. This initializes the Debugger but does not immediately make it visible.
3. Add a DEBUGGER system handle statement that invokes the SET-BREAK( ) method to set a breakpoint at the first executable line of the subprocedure you want to debug. This statement must execute after the statement that invokes the INITIATE( ) method in the previous step, but before the statement that calls the subprocedure.
4. Run the invoking procedure.
The following listing fragment prompts the user to enter the name (procname) of a procedure to debug (line 30). It then initializes the Debugger (line 33) and sets a breakpoint on the first executable line of procname (line 34). When the invoking procedure calls procname (line 35), procname breaks immediately on its first executable line and gives control to the Debugger. The Debugger then displays the listing for procname in the Debugger window as the current procedure, as shown:
            . . .
30 SET procname LABEL "Enter name of procedure to debug" DEBLANK
32 IF procname <> "" THEN DO:
33     debug = DEBUGGER:INITIATE().
34     debug = DEBUGGER:SET-BREAK(procname).
35     RUN VALUE(procname).
36 END.
            . . .
Note: Using this technique, the invoking procedure becomes part of the Debugger context; thus, the invoking procedure appears on the call stack. You can set breakpoints in the invoking procedure and break into it with the Debugger. In this type of application, you might not want the invoking procedure running in the Debugger context like this. You can prevent the invoking procedure from entering the Debugger context by prepending its procedure name with an underscore (_). In this case, the Debugger ignores the invoking procedure completely, and it never appears on the call stack.
Although this is a simple example, it illustrates the basic elements required to build an OpenEdge development tool that can start debugging sessions for specified application procedures.