Skip to content

gcov: Add MC/DC condition coverage support

Sasha Levin linux-doc linux-kbuild lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4gcov: fix gcov_info_add() merge semantics for IOR counterskernel/gcov/gcc_4_7.c+22 -30 replies
2/4kconfig: add CC_HAS_CONDITION_COVERAGE for MC/DC support detectioninit/Kconfig+3 -00 replies
3/4gcov: add MC/DC condition coverage supportMakefile arch/x86/um/vdso/Makefile kernel/gcov/Kconfig+20 -20 replies
4/4Documentation: gcov: document MC/DC condition coverage supportDocumentation/dev-tools/gcov.rst+25 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] gcov: Add MC/DC condition coverage support

This series adds support for GCC's MC/DC (Modified Condition/Decision Coverage) instrumentation to the kernel's gcov subsystem.

MC/DC verifies that each condition in a boolean decision independently affects the decision's outcome. It is required by safety standards such as DO-178C (avionics) and ISO 26262 (automotive). GCC 14 added MC/DC instrumentation via -fcondition-coverage.

Patch 1 fixes a pre-existing bug in gcov_info_add() where IOR-based counters (bitsets) were incorrectly merged with += instead of |=. Patches 2-3 add the CONFIG_GCOV_CONDITION_COVERAGE Kconfig option and wire up the compiler flag. Patch 4 documents the feature.

With CONFIG_GCOV_CONDITION_COVERAGE=y, gcov --conditions shows per-line condition coverage:

  4577658:  257:	if (node->num_loaded > 0)
  condition outcomes covered 2/2
  4577658:  355:	if (info && (strcmp(gcov_info_filename(info), name) == 0))
  condition outcomes covered 2/4
  condition  0 not covered (true)
  condition  1 not covered (true)
     2896:  420:	if (!copy)
  condition outcomes covered 1/2
  condition  0 not covered (true)

Tested with GCC 15.2, verified boot + gcov data extraction + gcov --conditions output. Also verified clean build with LLVM=1 (condition coverage correctly disabled for Clang).

Sasha Levin (4):
gcov: fix gcov_info_add() merge semantics for IOR counters
kconfig: add CC_HAS_CONDITION_COVERAGE for MC/DC support detection
gcov: add MC/DC condition coverage support
Documentation: gcov: document MC/DC condition coverage support

 Documentation/dev-tools/gcov.rst | 25 +++++++++++++++++++++++++
 Makefile                         |  3 +++
 arch/x86/um/vdso/Makefile        |  4 ++--
 init/Kconfig                     |  3 +++
 kernel/gcov/Kconfig              | 15 +++++++++++++++
 kernel/gcov/gcc_4_7.c            | 25 ++++++++++++++++++++++---
 6 files changed, 70 insertions(+), 5 deletions(-)
Signature · 1 line
2.51.0