Code Coverage with gcov

Add gcov code coverage instrumentation to C/C++ projects

25 stars

Best use case

Code Coverage with gcov is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Add gcov code coverage instrumentation to C/C++ projects

Teams using Code Coverage with gcov should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/gcov-coverage/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/gadievron/raptor/gcov-coverage/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/gcov-coverage/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Code Coverage with gcov Compares

Feature / AgentCode Coverage with gcovStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Add gcov code coverage instrumentation to C/C++ projects

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Code Coverage with gcov

## Purpose
Instrument C/C++ programs with gcov to measure test coverage.

## How It Works

### Build with Coverage
```bash
gcc --coverage -o program source.c
```

### Run Program
```bash
./program
# Creates .gcda files with execution data
```

### Generate Reports

**Text report:**
```bash
gcov source.c
# Creates source.c.gcov with line-by-line coverage
```

**HTML report:**
```bash
gcovr --html-details -o coverage.html
```

## Coverage Flags

- `--coverage` (shorthand for `-fprofile-arcs -ftest-coverage -lgcov`)
- Add to both `CFLAGS` and `LDFLAGS`

## Build System Integration

### Makefile
```makefile
ENABLE_COVERAGE ?= 0
ifeq ($(ENABLE_COVERAGE),1)
    CFLAGS += --coverage
    LDFLAGS += --coverage
endif
```

### CMake
```cmake
option(ENABLE_COVERAGE "Enable coverage" OFF)
if(ENABLE_COVERAGE)
    add_compile_options(--coverage)
    add_link_options(--coverage)
endif()
```

## When User Requests Coverage

### Steps
1. Detect build system (Makefile/CMake/other)
2. Add `--coverage` to CFLAGS and LDFLAGS
3. Clean previous build: `make clean` or `rm -f *.gcda *.gcno`
4. Build with coverage: `make ENABLE_COVERAGE=1` or `cmake -DENABLE_COVERAGE=ON`
5. Run tests: `make test` or `./test_suite`
6. Generate report: `gcovr --html-details coverage.html --print-summary`
7. Present summary and path to HTML report

## Output

**Text (.gcov files):**
```
        -:    0:Source:main.c
        5:   42:    int x = 10;
    #####:   43:    unused_code();
```
- `5:` = executed 5 times
- `#####:` = not executed
- `-:` = non-executable

**HTML:** Interactive report with color-coded coverage

## Metrics
- **Line coverage**: Executed lines / total lines
- **Branch coverage**: Taken branches / total branches  
- **Function coverage**: Called functions / total functions

Target: 80%+ line coverage, 70%+ branch coverage

Related Skills

coverage-report-analyzer

25
from ComeOnOliver/skillshub

Coverage Report Analyzer - Auto-activating skill for Test Automation. Triggers on: coverage report analyzer, coverage report analyzer Part of the Test Automation skill category.

pytest-coverage

25
from ComeOnOliver/skillshub

Run pytest tests with coverage, discover lines missing coverage, and increase coverage to 100%.

Coverage Analysis

25
from ComeOnOliver/skillshub

Coverage analysis is essential for understanding which parts of your code are exercised during fuzzing. It helps identify fuzzing blockers like magic value checks and tracks the effectiveness of harness improvements over time.

../../../engineering-team/playwright-pro/skills/coverage/SKILL.md

25
from ComeOnOliver/skillshub

No description provided.

test-coverage-advisor

25
from ComeOnOliver/skillshub

Reviews test coverage and suggests missing test cases for error paths, edge cases, and business logic. Activates when users write tests or implement new features.

test-coverage-analyzer

25
from ComeOnOliver/skillshub

Analyzes test coverage gaps and suggests test cases for untested code paths. Use when user requests test improvements, coverage analysis, or wants to increase test coverage.

coverage-analyzer

25
from ComeOnOliver/skillshub

Advanced coverage analysis with actionable insights. Use to identify coverage gaps, suggest specific tests, track coverage trends, and highlight critical uncovered code. Essential for reaching 80%+ coverage target.

Check Rust Coverage

25
from ComeOnOliver/skillshub

Determine which Rust lines are not covered by Rust tests.

Daily Logs

25
from ComeOnOliver/skillshub

Record the user's daily activities, progress, decisions, and learnings in a structured, chronological format.

Socratic Method: The Dialectic Engine

25
from ComeOnOliver/skillshub

This skill transforms Claude into a Socratic agent — a cognitive partner who guides

Sokratische Methode: Die Dialektik-Maschine

25
from ComeOnOliver/skillshub

Dieser Skill verwandelt Claude in einen sokratischen Agenten — einen kognitiven Partner, der Nutzende durch systematisches Fragen zur Wissensentdeckung führt, anstatt direkt zu instruieren.

College Football Data (CFB)

25
from ComeOnOliver/skillshub

Before writing queries, consult `references/api-reference.md` for endpoints, conference IDs, team IDs, and data shapes.