Go to main content
Oracle® Developer Studio 12.5: Code Analyzer User's Guide

Exit Print View

Updated: June 2016
 
 

Collecting Code Coverage Data

Collecting code coverage data on your C or C++ program is a three-step process:

  1. Instrumenting the binary with uncover.

  2. Running the instrumented binary.

  3. Running uncover again to generate a coverage report for use by Code Analyzer.

You can run the instrumented binary multiple times after instrumenting it, and accumulate data over all of the runs before generating the coverage report.

How to Collect Code Coverage Data From the Binary

Before You Begin

To instrument your program with uncover to collect data for use by Code Analyzer, you must have compiled the program with Oracle Developer Studio version 12.3, 12.4, or 12.5 C or C++ compiler. Compiling with the –g option generates debug information that enables Code Analyzer to use source code level coverage information.


Note -  If you saved a copy of the binary when you compiled your program for instrumenting with discover, you can rename the copy to the original binary name and use it for instrumenting with uncover. For example:
cp a.out.save a.out

  1. Instrument the binary with Uncover:
    % uncover binary-name
  2. Run the instrumented binary one or more times.

    The code coverage data is written to a binary-name.uc directory.

  3. Generate the code coverage report from the accumulated data using Uncover with the –a option:
    % uncover -a  binary-name.uc

    The coverage report is written to the coverage subdirectory in the binary-name.analyze directory.


    Note -  You must use the version of uncover in Oracle Developer Studio version 12.3, 12.4, or 12.5. The –a option is not available in earlier versions of uncover.