rgb_logo_pc_250.jpg (7844 bytes)

Getting started


With Purify, you can deliver cleaner code in a few easy steps:

  1. Run your program with Purify to collect:
    • Error data
    • Coverage data (if you have PureCoverage installed)
  2. Analyze the error data and correct your source code.
  3. If you've collected coverage data, analyze it to find any parts of your code that you have not Purify'd®.
  4. Rerun your program with Purify.

This chapter shows you how to use Purify in Microsoft Developer Studio 97 or later. But you can also use Purify independently of Developer Studio. Read "Using Purify standalone"and "Testing with Purify's command-line interface."


Running a program with Purify

Open your project in Developer Studio, then engage Purify from the Purify toolbar.

Set Purify to collect coverage data, as well as checking for errors and memory leaks.

1devtoolbarpurify.GIF (2988 bytes)

Build and execute your program using commands from the Developer Studio Build menu. (To get the maximum level of detail in Purify error reports, build your program with debug and relocation data.)

More information? For an explanation of how Purify uses debug and relocation data for error checking and coverage monitoring, look up debug data in the Purify online Help index.

Purify copies the program and each library it calls, then instruments the copies using Object Code Insertion (OCI) technology. The instrumentation process inserts instructions that validate every read, write, and allocation and deallocation of memory. If you're collecting coverage data, Purify also inserts instructions that increment counters when you exercise specific lines and functions.

Purify reports its progress as it instruments each module.

2-inst-small.gif (1647 bytes)
Click to enlarge

Purify instruments each module at a default instrumentation level, but you can customize the instrumentation level to provide more or less detail for special cases.

More information? For an explanation of instrumentation levels and how to use them, read "Customizing instrumentation". For more detail, look up instrumenting in the Purify online Help index.

Purify caches the instrumented version of each module. When you rerun a program, Purify saves time and resources by using the cached modules, re-instrumenting only those that have changed since the previous run.

As you exercise your program, Purify detects run-time errors and memory leaks and displays them in an Error View tab in the Purify Data Browser window.

 


Click to enlarge

More information? Look up error view in the Purify online Help index.

Note: If you're debugging client/server and multi-process applications, you can debug several processes and see the error reports for each running application simultaneously. To do this, run each process in a separate instance of Developer Studio with Purify engaged. Alternatively, you can use the standalone Purify user interface. See "Using Purify standalone".


Seeing all your errors at a glance

Purify displays error and warning messages about run-time errors and memory leaks, and informational messages about the progress of your program's execution.



Click to enlarge

When you exit the program, Purify reports memory leaks. In addition to memory leaks, you can set Purify to report memory in use at exit and handles in use at exit.

More information? Look up error and leak settings in the Purify online Help index.

When identical errors repeat

An error often repeats many times in a program, particularly if it occurs inside a loop. To provide a succinct overview of a program's errors, Purify by default displays each error message only once, the first time an error occurs, and then updates a counter whenever the error repeats.

         


Click to enlarge

More information? If you want Purify to display each occurrence of a message individually, instead of reporting counts, you can change the default setting. Look up error and leak settings in the online Help index.


Focusing on critical errors first

A large program can generate hundreds of messages. To focus on the most critical error messages quickly, create filters to hide all other messages from the display.

You can filter messages individually, or you can filter them based on their type and source. Consider hiding all informational messages, for example, or all messages originating from a specific file.




Click to enlarge

Once created, error filters apply to the current run and to all future runs of the program until you disable them. Disabling a filter causes hidden messages to be redisplayed in the error view.


Working with error-data filters

Purify filters are very flexible. Click the Filter Manager tool to create individual filters or groups of filters, and to apply them to specific programs or modules. You can also create global filters that apply to all programs and modules. And you can share filters, which Purify saves as .pft files, with other members of your team.




Click to enlarge

More information? Purify provides filters for coverage data as well as for error data. Look up filtering data in the Purify online Help index.

In addition to filtering, you can also use Purify's PowerCheck feature to focus on specific modules and simultaneously minimize instrumentation time. For information about the PowerCheck feature, read "Customizing instrumentation" .


Analyzing Purify error data

You can expand Purify messages to pinpoint where errors occur and to obtain diagnostic information for understanding why they occur.

Here's an example of an expanded ABW (array bounds write) error message:




Click to enlarge

The level of detail provided in call stacks depends on the availability of debug and relocation data. Even if you build your program in release mode, you can still get the highest possible level of detail. For more information, look up debug data, doing data, release builds in the Purify online Help index.

You can customize the format of Purify's messages. For example, you can increase the number of lines of source code that are displayed, or include instruction pointers and offsets to make locating errors easier.

More information? Look up preferences, source code in the Purify online Help index.


Correcting errors

Purify makes it easy to correct errors.




Click to enlarge

More information? Look up source code in the Purify online Help index.


Checking code coverage

To make sure that you find errors in your code wherever they occur, use Purify to monitor code coverage each time you run your program. With Purify's coverage feature, you can check that you're exercising all your code, especially those parts that have recently been added or modified.

Purify displays coverage data in views that you can sort to find the largest gaps in your testing.

10-modview-small.GIF (9185 bytes)

Click to enlarge

Purify can also display line-by-line coverage information marked directly on a copy of your code in an Annotated Source window. The color of each line of code indicates whether it is tested, untested, or partially tested, so that you can tell at a glance where you need to tighten up your testing.

11-annsrc-small.GIF (7701 bytes)

Click to enlarge

Based on the coverage data, refine your approach to exercising your code to make sure you are testing all the critical lines and functions. If you are testing manually, try different menu commands, or enter new values for variables. If you are testing automatically, revise or add test scripts.

More information? Look up coverage data in the Purify online Help index.


Comparing program runs

When you are satisfied that you've made good progress in eliminating errors, and that you can exercise the parts of your program that most need testing, rebuild. Then rerun the program under Purify.

After rerunning your corrected program, you can easily compare runs to verify your corrections. Purify's Navigator window, which you can display from the Purify View menu, helps you keep track of multiple runs and multiple programs.




Click to enlarge

More information? You can compare coverage data from different runs using the Compare Runs tool diff.gif
    (933 bytes).  Look up diffing runs in the Purify online Help index.


Saving Purify data

You can save Purify error data from a run in order to analyze it later, share it with other members of your team, or include it in reports. Purify can save data in the following formats:

More information? Look up saving data in the Purify online Help index.

Back| Next| Table of contents





Copyright © 1999 by Rational Software Corporation. All rights reserved.