From: Sasha Levin <sashal@kernel.org>
To: oberpar@linux.ibm.com
Cc: corbet@lwn.net, skhan@linuxfoundation.org, nathan@kernel.org,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 0/4] gcov: Add MC/DC condition coverage support
Date: Sat, 14 Mar 2026 10:17:45 -0400 [thread overview]
Message-ID: <20260314141749.3382679-1-sashal@kernel.org> (raw)
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(-)
--
2.51.0
next reply other threads:[~2026-03-14 14:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 14:17 Sasha Levin [this message]
2026-03-14 14:17 ` [PATCH 1/4] gcov: fix gcov_info_add() merge semantics for IOR counters Sasha Levin
2026-03-14 14:17 ` [PATCH 2/4] kconfig: add CC_HAS_CONDITION_COVERAGE for MC/DC support detection Sasha Levin
2026-03-14 14:17 ` [PATCH 3/4] gcov: add MC/DC condition coverage support Sasha Levin
2026-03-14 14:17 ` [PATCH 4/4] Documentation: gcov: document " Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260314141749.3382679-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=oberpar@linux.ibm.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox