Debug the Hello PL/I World Application

Walks you through the process of modifying your application in Eclipse, and then debugging it using the Eclipse debugger.

Modify your application

Here, you modify the code of the original HelloWorld program for the purposes of this demonstration:

  1. In the program editor, add the following code on the line before the put skip list statement:
      DCL SourceString    CHAR(10);
      DCL testchar        CHAR;
      DCL loop            FIXED BIN(8);
      
      SourceString = "AAbbAAbbCC";
      DO loop = 1 TO 10 BY 1;
        testchar = SUBSTR(SourceString, loop, 1);
        IF testchar = "A" THEN
          SUBSTR(SourceString, loop, 1) = "D";
      END;
      PUT SKIP LIST(SourceString);
      
      loop = 1;
      DO WHILE (loop < 10) UNTIL (SUBSTR(SourceString, loop, 1) = "C");
        SUBSTR(SourceString, loop, 1) = "Q";
        loop = loop + 1;
      END;

    The SourceString variable is a string that has an initial value of AAbbAAbbCC. Some of the string characters are replaced during the execution of this program.

  2. Save the changes.

    This initiates a rebuild of the project.

  3. Check the Console window to be sure that the project recompiled without errors.

Set breakpoints

Before starting the debugger, set a breakpoint to stop program execution before exiting the console so you can see the output.

  1. In the program editor, double-click in the left-most column on line 8, which reads:
    DO loop = 1 TO 10 BY 1;

    A dot appears in the column to indicate the breakpoint.

  2. Now, double-click in the left-most column on the last line of the program, which reads:
    end HelloPLIWorld;

    Again, a dot appears in the column to indicate the breakpoint.

Debug HelloWorld.pli

Enterprise Developer uses the Eclipse debugger to debug PL/I applications.

Create a debug configuration
  1. Select HelloPLIWorld in PL/I Explorer and from the main menu click Run > Debug Configurations.
  2. Double-click the PL/I Application tree item to create a new debug configuration.
  3. Specify HelloPLIWorld as the name of the configuration.

    This configuration uses HelloPLIWorld as the project to run and New_Configuration.bin/HelloPLIWorld as the main program to run.

  4. Click Debug.

    You are prompted to save and launch before you start debugging.

  5. Click OK.

    You are prompted to switch to the debug perspective.

  6. Click Yes to confirm.

    This starts the debugger and it stops on the first line of the program - on the PROC statement.

    Some of the views of the Debug perspective you can see are:

    • Debug view - shows the currently active threads.
    • Editor - shows the helloworld.pli program and the position of the debugger in the program.
    • Expressions - to monitor expressions.
    • Outline - shows an outline of the structure of the program you're stepping through.
    • Breakpoints - to monitor breakpoints.
Step through the code
You can now step through the code and see how the value of the SourceString changes:
  1. Press F5 (Step Into) to start stepping the code.

    The first line in the program executes and the cursor moves to the next line in the code.

  2. Open the Expressions view.
  3. Click the + in it and type SourceString as you are going to monitor this variable during debugging.
  4. Press F5 again.

    This executes the statement that initializes the value for SourceString.

  5. Step through the next few lines in the same way and see how the value of the SourceString variable changes in the Expressions view.
  6. Press F8 to continue to the next breakpoint.
  7. Press F8 again to exit the program.

    Debugging stops.

This completes the tutorial.