Debugging PL/I Applications | Getting Started with CICS and PL/I Applications |
This chapter comprises a tutorial-style session showing how you use PL/I Option to include a PL/I application in a Mainframe Express project.
You need to have read the chapter Start Here for the Tutorials in your Getting Started and worked through the first session, Using Mainframe Express, before you do this session.
You need to have installed PL/I Option to do this session. We assume you are familiar with PL/I on a mainframe.
You must be using Windows NT to use the PL/I debugger described in this chapter. The PL/I debugger will not dynamically attach to processes on Windows 95 or Windows 98, which prevents it being used with Mainframe Express on these operating systems. You can still do this tutorial if you omit the debugging sections.
This session takes you through maintaining and running a PL/I application on your PC.
The demo application used in this session is a simple PL/I application that you might have downloaded from a mainframe. In this session, you get it working on your PC. It copies records from one data set to another and, to illustrate program calls, it calls a subprogram which writes a message to the screen.
If you have closed Mainframe Express, open it as before. If any project window or other windows are open, close them.
In this session you:
To create the project:
You now get a page asking whether this project uses PL/I (and CICS, IMS or SQL if they are installed). It uses PL/I, but not the other three.
Because you have said this project uses PL/I, you next get a page asking if the project uses only AMODE 31 load modules.
To add your files to the project:
The files are added to the project.
To add a data set to the project:
DS Name | PC Filename | DSORG | RECFM | LRECL |
---|---|---|---|---|
TESTDATA.INPUT.DATA | testdata.dat | PS | FB | 400 |
The project contains two source files which need to be built to create two separate executable .dll files.
Also, before building these files, ensure that Create debug information is checked on the General page of the PL/I page of the Build Settings dialog box.
To build the project:
As you saw in the chapter Using Mainframe Express in your Getting Started, the correct compiler is automatically called for each source file - in this case, for the PL/I and JCL files.
The build finishes with "Build finished with no errors".
There are no source errors in this application.
The method of handling source errors in a PL/I program is the same as in a COBOL program, as shown in the chapter Using Mainframe Express in your Getting Started. Error messages appear in the Output window, and you can click on a message to view the source program at the point of the error, and then edit, save and rebuild. All the same facilities, such as Compress and Expand, are available.
To run the application without debugging:
The application runs. The Application Output window appears and shows the job starting and running to completion.
If you use Run again, it uses the same settings as the first time; you have no opportunity to change them. If you want to change the settings, click Start Debugging on the Debug menu, as described in the next section.
The PL/I debugger has an extensive set of debugging facilities which enable you, for example, to step through a PL/I application, set breakpoints, and monitor and change data values.
To debug the application:
The Application Output window appears and shows the job starting. When the PL/I program is loaded, the PL/I debugger is invoked. Its title window might be displayed for a few seconds.
Then the Disassembly and Session Control windows are displayed. Close the Disassembly window as it is not needed. You can then see the Session Control window as shown in Figure 3-1.
Figure 3-1: PL/I Debugger - Session Control Window
This expands the list, as shown in figure 3-2.
Figure 3-2: Expanded Session Control Window
The source file for PLIMAIN is displayed in the Source window, as shown in Figure 3-3.
Figure 3-3: Source Window for the First Part of PLIMAIN
The window that you see might be smaller or larger than this, but you can resize it in the usual way by dragging its borders. All the debugging operations described in the following sections start from the Source window.
The program PLIMAIN has not been invoked at this point, so the debugging operations that are available are limited. Notice that the number of line 1 is highlighted.
We will now invoke the program.
The program is run to the highlighted line number. In this case, line 1 had been automatically selected as the location by the debugger, but you can select any line by single-clicking its line number. This is a convenient way to run to any line that is in the future execution path of the program.
You will see that the whole of line 1 is now highlighted. This is how the debugger shows the line about to be executed.
To step through the program:
START OF PLIMAIN
has been written to the screen, as
requested by line 16.To step into a subprogram:
The program stops at line 22, which calls the subprogram PLISUB. When the FETCH statement on line 21 is executed, an entry for the PLISUB.DLL component is added to the Session Control window, as shown in Figure 3-4.
Figure 3-4: Session Control Window with PLISUB Added
At this point, you could expand the PLISUB.DLL component and double-click PLISUB.OBJ to display its source code and set up debugging controls, but we will see the source anyway when we step into the subprogram in the next step.
The Source window changes to show PLISUB with line 1 highlighted, as shown in Figure 3-5.
Figure 3-5: Source Window for PLISUB
You can now perform debugging operations on the subprogram. We will just run the subprogram and return to the main program.
The Source window changes to show the main program PLIMAIN again, as shown in Figure 3-6. The current line might still be shown as 22, but that line has now been executed.
Figure 3-6: Source Window for the Second Part of PLIMAIN
If you had used Step over instead of Step into in the previous step, execution would have continued to line 23 without stopping in the subprogram.
To monitor the value of the variable LINECNT, which is a count of the number of lines read from the input file:
The Monitor Expression window is displayed, as shown in Figure 3-7. The Expression field is already set to LINECNT.
Figure 3-7: Monitor Expression Window
A Popup Monitor window is displayed, as shown in Figure 3-8.
Figure 3-8: Popup Monitor Window
Another way to monitor variables is as follows.
The Program Monitor window is displayed, as shown in Figure 3-9.
Figure 3-9: Program Monitor Window for One Variable
You can monitor several variables on the Program Monitor window, whereas each Popup Monitor window is for a single variable.
The window now contains EOD_DATA, as shown in Figure 3-10.
Figure 3-10: Program Monitor Window for Two Variables
To set a breakpoint:
This sets a line breakpoint on this line. The line number is highlighted in red.
Alternatively, you could use the Breakpoints menu to set this or any other type of breakpoint, or to specify conditions to control the use of the breakpoint.
The program runs to the breakpoint on line 31. On the Popup Monitor window that you setup earlier you will see that the value of LINECNT has changed from 0 to 1.
Nothing changes on the Source window but the program has executed one iteration of the DO WHILE loop and the value of LINECNT is now 2.
The value of LINECNT increases to 3.
Next we want to run to the point where we exit from the loop.
The line number reverts to normal color.
When the program stops on line 42, the value of LINECNT is now 50, showing that 50 lines have been read from the SYSUT1 file. You can also see in the Program Monitor window that the value of EOD_DATA is now '1', indicating that end-of-file has been reached.
Now to complete the execution of the program:
All the debugger windows close and you can see the job ending in the Application Output window.
Hide the Application Output window and close the project.
If you want to take a break before going on to the next session, you can close Mainframe Express.
Return to the Tutorials Map in the chapter Start Here for the Tutorials in your Getting Started and choose which session to go on to next, depending on your interests.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Debugging PL/I Applications | Getting Started with CICS and PL/I Applications |