gcov-tool—an Offline Gcda Profile Processing Tool#

gcov-tool [global-options] SUB_COMMAND [sub_command-options] profile_dir

Description#

gcov-tool is an offline tool to process gcc’s gcda profile files.

Current gcov-tool supports the following functionalities:

  • merge two sets of profiles with weights.

  • read a stream of profiles with associated filenames and merge it with a set of profiles with weights.

  • read one set of profile and rewrite profile contents. One can scale or normalize the count values.

Examples of the use cases for this tool are:

  • Collect the profiles for different set of inputs, and use this tool to merge them. One can specify the weight to factor in the relative importance of each input.

  • Collect profiles from target systems without a filesystem (freestanding environments). Merge the collected profiles with associated profiles present on the host system. One can specify the weight to factor in the relative importance of each input.

  • Rewrite the profile after removing a subset of the gcda files, while maintaining the consistency of the summary and the histogram.

  • It can also be used to debug or libgcov code as the tools shares the majority code as the runtime library.

Note that for the merging operation, this profile generated offline may contain slight different values from the online merged profile. Here are a list of typical differences:

  • histogram difference: This offline tool recomputes the histogram after merging the counters. The resulting histogram, therefore, is precise. The online merging does not have this capability – the histogram is merged from two histograms and the result is an approximation.

  • summary checksum difference: Summary checksum uses a CRC32 operation. The value depends on the link list order of gcov-info objects. This order is different in gcov-tool from that in the online merge. It’s expected to have different summary checksums. It does not really matter as the compiler does not use this checksum anywhere.

  • value profile counter values difference: Some counter values for value profile are runtime dependent, like heap addresses. It’s normal to see some difference in these kind of counters.

Options#

-h, --help#

Display help about using gcov-tool (on the standard output), and exit without doing any further processing.

-v, --version#

Display the gcov-tool version number (on the standard output), and exit without doing any further processing.

merge#

Merge two profile directories.

-o directory, --output directory#

Set the output profile directory. Default output directory name is merged_profile.

-v, --verbose#

Set the verbose mode.

-w w1,w2, --weight w1,w2#

Set the merge weights of the directory1 and directory2, respectively. The default weights are 1 for both.

merge-stream#

Collect profiles with associated filenames from a gcfn and gcda data stream. Read the stream from the file specified by file or from stdin. Merge the profiles with associated profiles in the host filesystem. Apply the optional weights while merging profiles.

For the generation of a gcfn and gcda data stream on the target system, please have a look at the __gcov_filename_to_gcfn() and __gcov_info_to_gcda() functions declared in #include <gcov.h>.

-v, --verbose#

Set the verbose mode.

-w w1,w2, --weight w1,w2#

Set the merge weights of the profiles from the gcfn and gcda data stream and the associated profiles in the host filesystem, respectively. The default weights are 1 for both.

rewrite#

Read the specified profile directory and rewrite to a new directory.

-n long_long_value, --normalize <long_long_value>#

Normalize the profile. The specified value is the max counter value in the new profile.

-o directory, --output directory#

Set the output profile directory. Default output name is rewrite_profile.

-s float_or_simple-frac_value, --scale float_or_simple-frac_value#

Scale the profile counters. The specified value can be in floating point value, or simple fraction value form, such 1, 2, 2/3, and 5/3.

-v, --verbose#

Set the verbose mode.

overlap#

Compute the overlap score between the two specified profile directories. The overlap score is computed based on the arc profiles. It is defined as the sum of min (p1_counter[i] / p1_sum_all, p2_counter[i] / p2_sum_all), for all arc counter i, where p1_counter[i] and p2_counter[i] are two matched counters and p1_sum_all and p2_sum_all are the sum of counter values in profile 1 and profile 2, respectively.

-f, --function#

Print function level overlap score.

-F, --fullname#

Print full gcda filename.

-h, --hotonly#

Only print info for hot objects/functions.

-o, --object#

Print object level overlap score.

-t float, --hot_threshold <float>#

Set the threshold for hot counter value.

-v, --verbose#

Set the verbose mode.