Maintaining and Creating Data Files | Assembler Applications |
Use the debugger in Mainframe Express to single-step an application. You can watch the flow of control through the COBOL source and use an extensive set of debugging facilities.
You need to have read the chapter Start Here for the Tutorials and worked through the first session, Using Mainframe Express, before you do this session.
The debugging tool in Mainframe Express consists of a large number of interactive debugging facilities, many of which are used in this session.
The debugger was introduced briefly in the first session, Using Mainframe Express. This session goes deeper into the use of the debugger. You use the same demo application as you used in the chapter Using Mainframe Express.
This demo uses the project idedemo.mvp that you created and built in the chapter Using Mainframe Express.
The full path is \mfuser\projects\gsdemo\idedemo\idedemo.mvp. If you use Open on the File menu, you need the Files of Type field on the Open dialog box set to Project files (*.mvp) to see this file.
In this session you:
To start debugging:
As you saw in the first session, the Application Output window appears and shows the job steps as the JCL executes, then when the COBOL program is entered the source view window shown in Figure 13-1 appears and execution pauses.
Figure 13-1: Starting Debugging of Vsamdemo
The new window shows the COBOL source file. The highlighted line is the line about to be executed.
To step through the code:
This executes the highlighted line of code. The Step function on the menu and the button on the toolbar are completely equivalent.
If at any time during this session you inadvertently edit the displayed source code - for example by accidentally typing a letter - then when you try to execute the edited line you get "Execution point is on a modified line". You can undo the change by clicking Undo on the Edit menu, or using the equivalent shortcut key Ctrl+Z.
MOVE 1 TO SUBSCRPT ...
SUBSCRPT
,
without clicking, and wait a moment.
With this option set, putting the mouse pointer on a data item displays the item's value. This is very quick and convenient, but you may not want this to happen every time you put the mouse on a data item. It's up to you whether you leave this option set or not.
Now let's go on to look at more advanced ways of viewing data items.
SUBSCRPT
.
This displays a dialog box showing the value of the data item.
An extra window appears showing the data item's name and value. It is called the Watch List window, or simply the Watch window.
TEMP-SORT-RECORD
a few lines
further down the program; then click Add to list.
TEMP-SORT-RECORD
changes.
TEMP-SORT-RECORD
.
This shows the individual subordinate items, as in Figure 13-2.
Figure 13-2: Watch List
TEMP-SALESREP
in the
Watch List.
This displays this data item in a small separate monitor window as well as in the Watch List. If the monitor window isn't big enough to show the dataname or value in full, you can drag its edges to make it bigger.
To change the value of TEMP-SALESREP
:
TEMP-SALESREP
in the Watch
List.
JOHN HAWK
alongside TEMP-SALESREP.
JIM HAWK
,
then click Apply.
You'll see in the monitor window and the Watch List that the value alters.
You can also use the Watch List to alter a value, as follows.
TEMP-SALESREP
, alter the name to JIM
HAWKINS
, then (with the Watch
List still selected) press Enter.SORT-FILE
.
The Watch List window - and the Call/Perform Stack window, also used in debugging - behave like the Application Output window, as described in the section Before Continuing in the chapter Using Mainframe Express. If you click Dockable Windows on the View menu you'll see a dialog box for showing and hiding them. If you don't hide this window, it disappears when you stop debugging, but appears again every time you run or debug an application.
To find where data items are used in your program:
IF PERFORM-FLAG EQUAL TO 1
.
PERFORM-FLAG
, and on the
popup menu click COBOL Find "PERFORM-FLAG".
This highlights all lines where this data item is referenced.
This compresses the listing to show just lines that reference PERFORM-FLAG. A note on the left of each line shows whether the line defines, modifies or tests the item. See Figure 13-3.
Figure 13-3: Data Item Find list
This expands the listing again, positioned such that the line you had selected is visible on the screen.
PERFORM-FLAG
, that is, the
line containing UNTIL PERFORM-FLAG EQUAL TO ZERO
.
This removes the highlighting from the lines containing PERFORM-FLAG
You can use these functions in exactly the same way on procedure-names.
To set a breakpoint:
CLOSE INQUIRY
FOREIGN-REGION.
Notice the symbol that appears alongside the line.
PERFORM WRITE-BAD-DATA
(both occurrences)
PERFORM WRITE-WEST-RECORD
PERFORM WRITE-EAST-RECORD
This runs the program without animation up to the first breakpoint. The display is not updated till the execution pauses at the breakpoint.
This is a quick way of clearing all breakpoints. You can use this function while debugging or, as in this case, after you finish debugging.
To locate various major parts of the program:
You can use this function while debugging or, as in this case, after you finish debugging.
To see a variety of COBOL reports:
This displays a list of all data items not directly referenced in the program. This window can be docked and undocked, like the Output window. By default is it undocked. It is shown in Figure 13-4.
Figure 13-4: Unreferenced data list
Clicking Dead Data would show you a list of all data in the program which is not referenced either directly or indirectly. This program has no dead data.
This displays a list of statistics about this program, as shown in Figure 13-5. You don't need to close the previous report first.
Figure 13-5: Program Statistics list
This displays the window shown in Figure 13-6.
Figure 13-6: Copybook Structure
VSAM-FS.CPY
to take you to
the start of the copybook in the main window.
VSAM-WS.CPY
to take you to
the start of the other copybook.
This closes the report windows.
You can use this function while debugging or, as in this case, after you finish debugging.
To demonstrate this function we will debug the program again.
PERFORM SORT-STATES
as a single step.
(You are now ready to execute the line OPEN INPUT INQUIRY
).
OPEN OUTPUT FOREIGN-REGION...
,
and click Skip to Cursor.
This moves the execution point to the next line without executing
the OPEN INPUT.
READ INQUIRY
.
You get an error message, since you are trying to read a file that you have not opened.
OPEN INPUT...
, right-click on the statement and click Skip
to Cursor.
READ INQUIRY...
,
right-click and click Skip to Cursor.
The file is now read successfully.
Close the source view window and hide the Application Output window.
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 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.
Maintaining and Creating Data Files | Assembler Applications |