GCOV-TOOL(1)
๐ 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-toolthan 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 usinggcov-toolon the standard output, then exits without doing any further processing. ๐-v,--versionโ Displays thegcov-toolversion 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 ismerged_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 isrewrite_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 as1,2,2/3, and5/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 โ๏ธ
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
- nixos 26.05: coreboot-toolchain-x64 26.06
- nixpkgs unstable: coreboot-toolchain-x64 26.09
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms