Message ID | 20250328121902.2134020-4-volodymyr_babchuk@epam.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Enable MC/DC support for GCOV | expand |
On 28.03.2025 13:19, Volodymyr Babchuk wrote: > Condition coverage, also known as MC/DC (modified condition/decision > coverage) is a coverage metric that tracks separate outcomes in > boolean expressions. > > This patch adds CONFIG_CONDITION_COVERAGE option to enable MC/DC for > GCC. Clang is not supported right now. > > Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com> > > --- > > Changes in v2: > - Move gcc version check from .c file to Rules.mk (I can't find > an easy way to check GCC version at Kconfig level) Yet all of this could be avoided if, as indicated before, you checked for acceptance of the command line option rather than a particular gcc version. Jan
On Fri, Mar 28, 2025 at 12:19:18PM +0000, Volodymyr Babchuk wrote: > Condition coverage, also known as MC/DC (modified condition/decision > coverage) is a coverage metric that tracks separate outcomes in > boolean expressions. > > This patch adds CONFIG_CONDITION_COVERAGE option to enable MC/DC for > GCC. Clang is not supported right now. > > Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com> > > --- > > Changes in v2: > - Move gcc version check from .c file to Rules.mk (I can't find > an easy way to check GCC version at Kconfig level) It's very easy to do so, our Kconfig already look for GCC's version ;-) The result isn't used yet in Kconfig, but it is in some C files and Makefile. You can simply do: depends on GCC_VERSION > 140000 (instead of checking for CC_IS_CLANG, because GCC_VERSION would be 0 when clang is used) But, do you really need to check for gcc's version? Is -fcondition-coverage mean something different in previous version? Cann't you actually just check if a feature is present in the CC been used? It is rare to check for a particular version of a compiler and instead check if it knows about a flags. Cheers,
diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index f7cc5ffaab..7f758d221b 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -44,6 +44,15 @@ config COVERAGE If unsure, say N here. +config CONDITION_COVERAGE + bool "Condition coverage support" + depends on COVERAGE && !CC_IS_CLANG + help + Enable condition coverage support. Used for collecting MC/DC + (Modified Condition/Decision Coverage) metrics. + + If unsure, say N here. + config DEBUG_LOCK_PROFILE bool "Lock Profiling" select DEBUG_LOCKS diff --git a/xen/Rules.mk b/xen/Rules.mk index d759cccee3..b6f83caad0 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -138,6 +138,13 @@ ifeq ($(CONFIG_CC_IS_CLANG),y) COV_FLAGS := -fprofile-instr-generate -fcoverage-mapping else COV_FLAGS := -fprofile-arcs -ftest-coverage +ifeq ($(CONFIG_CONDITION_COVERAGE),y) + ifeq ($(call cc-ifversion,-ge,1400,y),y) + COV_FLAGS += -fcondition-coverage + else + $(error "GCC 14 or newer is required for CONFIG_CONDITION_COVERAGE") + endif +endif endif # Reset COV_FLAGS in cases where an objects has another one as prerequisite
Condition coverage, also known as MC/DC (modified condition/decision coverage) is a coverage metric that tracks separate outcomes in boolean expressions. This patch adds CONFIG_CONDITION_COVERAGE option to enable MC/DC for GCC. Clang is not supported right now. Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com> --- Changes in v2: - Move gcc version check from .c file to Rules.mk (I can't find an easy way to check GCC version at Kconfig level) - Check for gcc 14, not gcc 14.1 --- xen/Kconfig.debug | 9 +++++++++ xen/Rules.mk | 7 +++++++ 2 files changed, 16 insertions(+)