gcov-dump - Linux


Overview

gcov-dump is a tool that generates reports from data collected by the gcov test coverage tool. It creates a structured text report containing line-by-line coverage information for each function in a C or C++ program.

Syntax

gcov-dump [options] file

Options/Flags

  • -a, –all-blocks: Dump all blocks, even those with no counts.
  • -b, –block-notes: Include block notes in the dump.
  • -e, –exclude-all: Exclude all lines from the output.
  • -f, –function: Only dump the specified function.
  • -h, –help: Display help and exit.
  • -n, –numbers: Display line numbers instead of function names.
  • -p, –prefix: Prefix each line in the dump with the specified string.
  • -r, –relative-line-numbers: Display relative line numbers, starting from 1.
  • -s, –summarize: Summarize the coverage results in a single line.
  • -t, –threshold: Set the threshold for line coverage. Lines below the threshold are considered uncovered. (Default: 1)
  • -v, –version: Display version information and exit.

Examples

Simple Usage

To generate a coverage report for a file named main.c:

gcov-dump main.gcda

Summarized Coverage Report

To display a summarized report of the coverage information:

gcov-dump -s main.gcda

Specifying a Function

To dump the coverage information for a specific function:

gcov-dump -f main main.gcda

Common Issues

  • Missing GCDA Files: Ensure that the corresponding .gcda files for the program have been generated using the gcov tool.

Integration

gcov-dump can be used in conjunction with other tools:

  • gcov-genhtml: Generate HTML reports from gcov coverage data.
  • lcov: Collect and analyze the code coverage data in more depth.

Related Commands

  • gcov: Collects test coverage data for a program.
  • gprof2dot: Generates a graph of the program’s profile data.
  • lcov: Tool for measuring code coverage and generating HTML reports.