![]() |
![]() |
|
|
|
|
|
|
|
|
|
|
|
||
|
Figure 5.1 Open
Tuition5.Cbl in Chaptr05.
Figure 5.2 Compiler
Option Dialog Box. After adding the TEST option, you can compile as before.
Figure 5.3 MAIN and TEST Options Specified. Step 5.2: Link for Debugging After compiling the program, you now have to link for debugging. Open WINLINK as before. Open the Tuition5.cbl program, but click on Options before linking.
Figure 5.4 Linker Options Set for Debugging. Once you have opened the Linker Options Window, click on Debug. The Linker Option box will display "/DEBUG/DEBUGTYPE:COFF". Click OK to return to the linker and link as usual. Step 5.3: Start WINSVD From P-Staff, this time select WINSVD instead of WINEXEC. The Debugger opens with a blank screen similar to P-Staff. Start the debugging process by clicking on the "Open File" icon or the "Start Debugging" option of the file menu.
Figure 5.5 Debugger Main Window. The Start Debugging Window opens. You need to specify an application. This is the load module for Tuition5. Use Browse to find the program and open it. The name is entered into the Application box and you can click on OK to continue.
Figure 5.6 Start Debugging Dialog Box. There are number of advance options available, but they are not necessary to perform basic debugging operations. Step 5.4: Begin Debugging After going through the Environment Setup Window (We discuss the use of this feature in Exercise 6.) The debugger window now displays the source listing with the first executable statement highlighted. The program is ready to run.
Figure 5.7 Program Ready to Run in Debugging Mode. Before running the program, take some time to explore the icons across the top. Simply move the mouse across the icons without clicking and allow the icon to tell you what it does. Be patient, depending upon the power of your computer, the icon names may take a few seconds to appear. Note particularly the following buttons:
Figure 5.8 Debugger Tool Bar. Step 5.5: Test the Buttons Click on the Animate Button of the Tool Bar to watch the program step through the process slowly. This method technique allows you to view the operation of program in "slow-motion." Often logic errors can be spotted this way. You may want to click on Break to stop the program from running. When the execution has been stopped, you can click on Animate again or on GO. GO runs the program at full speed until it stops. Another option is to use Step into. This button executes the program one step at a time. You have to click on the button each time to execute a step. You may find that you want to start the program all over again without running to the conclusion. The Re-debug button does this for you. In some cases, there is a problem in a certain area of code and you do not want to have to wait for Animate to reach that point. You would rather have the program run directly to the problem area of code and stop. At that point, you could use Animate or Step into to see what is wrong. The Set/Delete Breakpoint button is what you need. Find a line of code just before the problem area and click this button.
Figure 5.9 Source Code with Breakpoint Set. The line is highlighted to show that it is a breakpoint. You can then start the program and use Go to run the program and it will stop at the breakpoint. So far, all you have seen is how to move around in the program, but many times it is not enough to just see the flow of the logic. You also may want to see what is happening to the data. The Data button allows you to place the cursor on a data item and see what is in that field. Figure 5.10 show the value of IND-BILL.
Figure 5.10 Data Contents Box. At times, you may want to see how the data is changing as the program progresses. The Watch Data button allows you monitor the data. You have to choose the particular items that you want to watch and the debugger creates a window that shows the current value of the data as the program runs. As before, place the cursor on the data item you want to watch. Click on Watch Data. This opens the Watch Data dialog box.
Figure 5.11 Watch Data Dialog Box. Click on Set to add the data name to the List of watched data. Click on Close to exit the box. WINSVD creates a new window with the value of the data item. From the Windows menu, you can have WINSVD tile the windows horizontally or vertically. You can rearrange the windows any way you wish.
Figure 5.12 Source and Watch Windows Horizontally Tiled. Step 5.6: Conclusion This exercise has been just an introduction to the capabilities to the interactive debugger. You should read the Help messages supplied on-line and the Fujitsu COBOL Debugging Guide on the CD for more information and debugging techniques. |
|
|
||
| All
Rights Reserved, Copyright © FUJITSU SOFTWARE CORPORATION 2003 |