FUJITSU FS Logo
HomeMigrationsProductsServicesInformationNewsPartnersStudentPricingAbout Us
Quick Search  
spcer
 
DowloadSupport
Home > Support
Support Title   Support graphic
Support
Version 5 and 6
Support Status
Helpful Tips
Sample Programs
Version 4
Support Status
Helpful Tips
ODBC Compatibility
Release Notes 4.2
Sample Programs
Release Notes 4.0 only
Run Time Installers
Version 3
Support Status
Helpful Tips
Using ODBC
Programming Staff
Quick Start Tutorial
Sample Programs
Support FAQ's

Exercise 5:

Debugging Program using WINSVD

Discussion: In this Exercise, we introduce you to WINSVD, the Fujitsu interactive debugger. You will go through the steps to compile and link a program but this time will prepare the load module for debugging. You will see several features of WINSVD including animation, stepping, watch windows and breakpoints.

WINSVD is a powerful tool and it will take you a while to master its commands and features. This brief introduction to WINSVD should get you started.

Step 5.1: Compile a Program for Debugging

In order to use WINSVD the program must be prepared for debugging. Follow the process in Exercise 3 to compile a program, but this time use TUITION5.CBL in folder Chaptr05. Make sure the input file named in the source code is correct.


  Image 147

Figure 5.1 Open Tuition5.Cbl in Chaptr05.

When you have opened the file for compilation set the Compiler Option MAIN, as before. Now, you need to add TEST as an option. Follow the same process but select TEST to add. The Compiler Option dialog box opens.

Image 148

Figure 5.2 Compiler Option Dialog Box.

When you add the TEST option, make sure that you specify a directory for storing the Debugging information. Chaptr05 is a good option, but if you are compiling from a diskette, you might want to consider storing the debugging information on the hard disk.

After adding the TEST option, you can compile as before.

Image 149a

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.

Image 150

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.

Image 151

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.

Image 152

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.

Image 153

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:

  • Set/Delete Breakpoint
  • Re-debug
  • Go
  • Animate
  • Break
  • Step into
  • Data
  • Watch data

Image 153

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.

Image 154

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.

Image 155

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.

Image 156

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.

Image 157

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.


 © 2003 - 2008 Fujitsu Computer Systems Corporation. All Rights Reserved.