GCOV-TOOL(1)

๐Ÿ“ฆ version 26.09, in nixos 26.05, nixpkgs unstable

๐ŸŽ€ GCOV-TOOL(1) ยท GNU ๐ŸŽ€


๐Ÿ’– NAME ๐Ÿ’–

okay so gcov-tool is an offline gcda profile processing tool ๐Ÿงš It takes gcc's gcda profile files and does stuff to them without needing the program to be running. Iconic.

๐Ÿ“œ SYNOPSIS ๐Ÿ“œ

gcov-tool [-v|--version] [-h|--help]

gcov-tool merge [merge-options] directory1 directory2
     [-o|--output directory]
     [-v|--verbose]
     [-w|--weight w1,w2]

gcov-tool merge-stream [merge-stream-options] [file]
     [-v|--verbose]
     [-w|--weight w1,w2]

gcov-tool rewrite [rewrite-options] directory
     [-n|--normalize long_long_value]
     [-o|--output directory]
     [-s|--scale float_or_simple-frac_value]
     [-v|--verbose]

gcov-tool overlap [overlap-options] directory1 directory2
     [-f|--function]
     [-F|--fullname]
     [-h|--hotonly]
     [-o|--object]
     [-t|--hot_threshold] float
     [-v|--verbose]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

gcov-tool is an offline tool to process gcc's gcda profile files. Literally its whole job. ๐Ÿ’…

Current gcov-tool supports the following functionalities, bestie:

  • 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. You can scale or normalize the count values. ๐Ÿ”ฅ

Examples of the use cases for this tool are:

  • Collect the profiles for different sets of inputs, and use this tool to merge them. You 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. You 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, since the tool shares the majority of its code with the runtime library. ๐Ÿ™ˆ
Heads up! For the merging operation, the profile generated offline may contain slightly different values from the online merged profile. Here is a list of typical differences:
  • histogram difference: This offline tool recomputes the histogram after merging the counters, so the resulting histogram 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 than in the online merge, so 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 kinds of counters. ๐Ÿง 

โœจ OPTIONS โœจ

  • -h, --help โ€” Displays help about using gcov-tool on the standard output, then exits without doing any further processing. ๐Ÿ†˜
  • -v, --version โ€” Displays the gcov-tool version number on the standard output, then exits without doing any further processing. ๐Ÿท๏ธ

๐Ÿซง merge

Merges two profile directories. ๐Ÿซถ

  • -o directory, --output directory โ€” Sets the output profile directory. The default output directory name is merged_profile. ๐Ÿ“
  • -v, --verbose โ€” Turns on verbose mode. ๐Ÿ“ข
  • -w w1,w2, --weight w1,w2 โ€” Sets the merge weights of directory1 and directory2, respectively. The default weights are 1 for both. โš–๏ธ

๐Ÿฆ‹ merge-stream

Collects profiles with associated filenames from a gcfn and gcda data stream. It reads the stream from the file specified by file or from stdin, then merges the profiles with associated profiles in the host filesystem. You can apply the optional weights while merging. ๐ŸŒŠ

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

  • -v, --verbose โ€” Turns on verbose mode. ๐Ÿ“ข
  • -w w1,w2, --weight w1,w2 โ€” Sets 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

Reads the specified profile directory and rewrites it to a new directory. ๐Ÿ’ซ

  • -n long_long_value, --normalize <long_long_value> โ€” Normalizes the profile. The specified value is the max counter value in the new profile. ๐ŸŽš๏ธ
  • -o directory, --output directory โ€” Sets the output profile directory. The default output name is rewrite_profile. ๐Ÿ“
  • -s float_or_simple-frac_value, --scale float_or_simple-frac_value โ€” Scales the profile counters. The value can be a floating point value or a simple fraction, such as 1, 2, 2/3, and 5/3. ๐Ÿ“
  • -v, --verbose โ€” Turns on verbose mode. ๐Ÿ“ข

๐Ÿ” overlap

Computes the overlap score between the two specified profile directories. The overlap score is based on the arc profiles, and it's defined as the sum of min (p1_counter[i] / p1_sum_all, p2_counter[i] / p2_sum_all) for all arc counter i. Here p1_counter[i] and p2_counter[i] are two matched counters, and p1_sum_all and p2_sum_all are the sums of counter values in profile 1 and profile 2, respectively. Big math, but it's giving clarity. ๐Ÿงฎ

  • -f, --function โ€” Prints the function level overlap score. ๐ŸŽฏ
  • -F, --fullname โ€” Prints the full gcda filename. ๐Ÿ—‚๏ธ
  • -h, --hotonly โ€” Only prints info for hot objects/functions. ๐Ÿ”ฅ
  • -o, --object โ€” Prints the object level overlap score. ๐Ÿงฑ
  • -t float, --hot_threshold <float> โ€” Sets the threshold for the hot counter value. ๐ŸŒก๏ธ
  • -v, --verbose โ€” Turns on verbose mode. ๐Ÿ“ข

๐Ÿ”— SEE ALSO ๐Ÿ”—

gpl(7), gfdl(7), fsf-funding(7), gcc(1), gcov(1) and the Info entry for gcc. Go check them out, they're the main character's supporting cast. ๐ŸŽฌ

Copyright (c) 2014-2025 Free Software Foundation, Inc. ๐ŸŒˆ

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being "GNU General Public License" and "Funding Free Software", the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the gfdl(7) man page.

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.


gcc-15.2.0 ยท 2025-08-08 ยท GCOV-TOOL(1) ๐ŸŒˆ๐Ÿ’œ bye bestie, you're literally ready to profile things now ๐Ÿซถ๐Ÿ’…

๐Ÿ“ฆ where this page comes from