Previous Topic Next topic Print topic


Debug the Hello PL/I World Application

Modify your application

You are going to add some extra code to your application that will help demonstrate some of the debugging features:

  1. Open the helloworld.pli program in the editor.
  2. Add the following code before the line for 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.

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.exe (Windows) or New_Configuration.bin/HelloPLIWorld (UNIX) as the main program to run.

  4. Click Debug.

    You get prompted to switch to the debug perspective. 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 which 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 exit the program.

    Debugging stops.

You can save the project for future reference.

What Next?

Continue with the section Using Eclipse for PL/I development.

Previous Topic Next topic Print topic