Freedom251 › Test Coverage Tools
gcov

What gcov is
gcov is a free coverage analysis tool used with GCC to show where a program’s code executes during testing. It reports how often source lines run and creates a .gcov logfile with per-line counts. Coverage reports can include line, function, branch, condition, prime-path, and basic-block data. Options can show branch frequencies or indicate whether conditions independently affected a Boolean expression’s result. The --include and --exclude options filter reports to functions matching regular expressions. Reports can be written as .gcov text or gzip-compressed JSON; JSON output does not require source code to generate. Developers can use gcov with gprof to assess computing time, although optimization may combine source lines and reduce detail for locating performance hotspots. The companion gcov-tool can merge and adjust profiles offline, while gcov-dump can inspect profile files. gcov supports Linux, macOS, and Windows, and is self-hosted. Programs must be compiled with GCC’s --coverage option before gcov can process their profiling data. It works only with GCC-compiled code and is not compatible with other profiling or coverage mechanisms.
Who it suits
It suits software developers using test suites who want coverage results to find where additional tests may be needed. It also offers reports for developers examining branches, conditions, or performance profiles.
What it does well
- Reports line, function, branch, and other coverage types.
- Filters reports by function-name regular expressions.
- Outputs .gcov text or compressed JSON.
- Companion tools merge or inspect profiles offline.
What to know first
- Programs require GCC’s --coverage option.
- Works only with code compiled using GCC.
- Optimization can reduce detail for locating hotspots.
Limits
The free plan requires code compiled with GCC and coverage instrumentation to generate coverage data. gcov processes GCC-compiled code only.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| gcov | Requires code compiled with GCC; requires coverage instrumentation to generate coverage data | Free |
As gcc.gnu.org lists them, read 7 Oct 2026. The maker's own page has the final word.
Getting started
- Visit the GCC gcov documentation.
- Compile the program with GCC’s `--coverage` option.
- Run the program to generate profiling data.
- Use gcov to produce coverage reports.
Verdict
gcov provides several coverage views for GCC-compiled programs, including machine-readable output. Its instrumentation and compiler requirements make GCC compatibility the key constraint to check.
Questions
How much does gcov cost?
The listed plan is free.
Which platforms does gcov support?
Linux, macOS and Windows.
Which languages are supported?
C, C++, Objective-C, Objective-C++, Fortran, Ada, D and Go.
What report formats are available?
gcov provides `.gcov` text reports and gzip-compressed JSON reports.
Does gcov work with code compiled by other compilers?
No. It works only with code compiled using GCC and is not compatible with other profiling or test coverage mechanisms.
How do I get coverage data?
Compile the program with GCC’s `--coverage` option before processing it with gcov.
Facts from gcov's own pages
- Branch coverage
- The --branch-probabilities option reports branch frequencies in the output file and branch summary information on standard output. · gcc.gnu.org, 7 Oct 2026
- Compatibility limit
- gcov works only on code compiled with GCC and is not compatible with other profiling or test coverage mechanisms. · gcc.gnu.org, 7 Oct 2026
- Compiler compatibility
- gcov works only on code compiled with GCC and is not compatible with other profiling or test coverage mechanisms. · gcc.gnu.org, 7 Oct 2026
- Condition coverage
- The --conditions option reports whether conditions independently affected the outcome of a Boolean expression. · gcc.gnu.org, 7 Oct 2026
- Coverage modes
- Its options include branch, condition, and prime-path coverage reporting. · gcc.gnu.org, 7 Oct 2026
- Distribution
- GCC source releases are distributed through mirror sites and source can also be retrieved using Git. · gcc.gnu.org, 7 Oct 2026
- Founded
- 1987 · gcc.gnu.org, 28 Sept 2026
- Instrumentation requirement
- Programs must be compiled with GCC's --coverage option before gcov can process the generated profiling data. · gcc.gnu.org, 7 Oct 2026
- Intended users
- The documentation describes software developers using coverage results with test suites to find where additional tests are needed. · gcc.gnu.org, 7 Oct 2026
- Line coverage
- gcov reports how often each source line executes and creates a .gcov logfile with per-line execution counts. · gcc.gnu.org, 7 Oct 2026
- Line statistics
- gcov reports how often each line executes and which lines are executed. · gcc.gnu.org, 7 Oct 2026
- Machine-readable output
- The --json-format option produces gzip-compressed JSON output that does not require source code to generate. · gcc.gnu.org, 7 Oct 2026
- Optimization caveat
- The documentation says optimization can combine source lines and reduce the information available for finding performance hotspots. · gcc.gnu.org, 7 Oct 2026
- Output files
- gcov produces coverage output files for source files containing code compiled to produce the data files. · gcc.gnu.org, 7 Oct 2026
- Profile inspection
- The companion gcov-dump can dump the contents of gcda and gcno profile files offline. · gcc.gnu.org, 7 Oct 2026
- Profile processing
- The companion gcov-tool can merge weighted profile sets, merge streamed profiles, and scale or normalize profile counts offline. · gcc.gnu.org, 7 Oct 2026
- Profiling
- The documentation describes using gcov with gprof to assess computing time and fine-tune performance. · gcc.gnu.org, 7 Oct 2026
- Project status
- The GCC homepage listed GCC 16.2 as released on August 7, 2026 and GCC 17.0 as in development. · gcc.gnu.org, 7 Oct 2026
- Purpose
- gcov is a test coverage program used with GCC to find untested parts of programs and guide code optimization. · gcc.gnu.org, 7 Oct 2026
- Reporting filters
- The --include and --exclude options let users limit reports to functions matching specified regular expressions. · gcc.gnu.org, 7 Oct 2026
- Setup requirement
- Programs must be compiled with GCC's --coverage option before gcov can report coverage. · gcc.gnu.org, 7 Oct 2026
- Support
- The GCC project directs users to its manuals and the gcc-help mailing list for usage questions. · gcc.gnu.org, 7 Oct 2026
- Use cases
- It can help identify untested parts of a program and guide code optimization. · gcc.gnu.org, 7 Oct 2026
- Use with gprof
- gcov can be used alongside gprof to assess which parts of a program use the most computing time. · gcc.gnu.org, 7 Oct 2026
Where gcov stands on Freedom251
- Test Coverage Tools#10 of 27