[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5] xen: debug: gcov: add condition coverage support


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Wed, 9 Apr 2025 10:11:23 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LqWWxpDoYDsBPgqho41u5hwxdBWPF+k3b6j7HgGhvwM=; b=ySXbc+Uamzr2Q3ZmpeP8IZInTkNX/g9EDMGgrsh22X24ZIBSyIxNmqO2XQzsTPaXvYJHtq7YBToo9j9FEJiPWJAASV7W/9sNQC/WdM8ahp3dHPwk5gLa+RmoxenO89bJ+uI9yw0xBF5CHl2v+LrcbJbEG0AVgYAqkGwoNCXpcOlsCUZKlhZD+h/CbRa8E/WLUOeO/eEO++8zRX20Q+Nv6tBaw0N7vRRm4spV5B/AgHkmBcO7MjLX0sQwKtADK/o4j1Qc6ZDaCTu6stMQ7Kr99WjHF2z7MZgdyBL7tqdktX3qpTorWB8Kp0i3uREfXBbEg8St5YrAU69U3blEktkFuA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dugBDF4+4VNS0EQa/+M4xaIzUUe6W6giLg3brpmj1AYszEoI7dlFZEt0QAS4kBuWAv4j+MvsXHpIJT8xPV0aOH3HQM4gtdAvCMSZBPW7FdI+SErqMyACbDWwfEiINlfFzmBpoNnfBd0StKK9p4JlYR/lb8wT3QD4Yjj2HUbnqsMxM0S/VmlJWINUYeNjreq0yLt7WTXNZP/8pUJ/HzHfX9EDSie3F3/2NF+RWX3V5LFs9KK9v1vvgV2w8fJx1eYlsyv6oDIq1bX0sCmtUkFMlS6fvB/6FV1c9Nzu+8fgUzXQVaAfIP5AKbdXGNL84SXXi41sRk+mKAtGwOWhwo8xxw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 09 Apr 2025 10:11:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbqTe/Csu/ncsNI0mulEQya+sOaA==
  • Thread-topic: [PATCH v5] xen: debug: gcov: add condition coverage support

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 because Xen can't emit version
10 of LLVM profile data, where MC/DC support was added.

Also, use the opportunity to convert COV_FLAGS to cov-cflags-y, which
reduces amount of ifeqs in Rules.mk. Otherwise this patch had to add
another nesting level with "ifeq ($(CONFIG_CONDITION_COVERAGE),y)".

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>

---
Changes in v5:
 - cov-flags-y -> cov-cflags-y
 - Clarified why Clang is not supported right now

Changes in v4:
 - Slight formatting fixes
 - COV_FLAGS  -> cov-flags-y

Changes in v3:
 - Introduced CC_HAS_MCDC that checks if compiler supports
   required feature

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       |  4 ++++
 xen/Kconfig.debug |  9 +++++++++
 xen/Rules.mk      | 14 +++++++-------
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/xen/Kconfig b/xen/Kconfig
index 2128f0ccfc..3a723db8ea 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -41,6 +41,10 @@ config CC_SPLIT_SECTIONS
 config CC_HAS_UBSAN
        def_bool $(cc-option,-fsanitize=undefined)
 
+# Compiler supports -fcondition-coverage aka MC/DC
+config CC_HAS_MCDC
+       def_bool $(cc-option,-fcondition-coverage)
+
 # Set code alignment.
 #
 # Allow setting on a boolean basis, and then convert such selection to an
diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug
index f7cc5ffaab..f89cbd823b 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_HAS_MCDC
+       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..da21850926 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -29,6 +29,7 @@ targets :=
 subdir-y :=
 CFLAGS-y :=
 AFLAGS-y :=
+cov-cflags-y :=
 nocov-y :=
 noubsan-y :=
 
@@ -133,19 +134,18 @@ $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): 
CFLAGS-y += -DINIT_SECTIONS
 
 non-init-objects = $(filter-out %.init.o, $(obj-y) $(obj-bin-y) $(extra-y))
 
-ifeq ($(CONFIG_COVERAGE),y)
 ifeq ($(CONFIG_CC_IS_CLANG),y)
-    COV_FLAGS := -fprofile-instr-generate -fcoverage-mapping
+    cov-cflags-$(CONFIG_COVERAGE) := -fprofile-instr-generate 
-fcoverage-mapping
 else
-    COV_FLAGS := -fprofile-arcs -ftest-coverage
+    cov-cflags-$(CONFIG_COVERAGE) := -fprofile-arcs -ftest-coverage
+    cov-cflags-$(CONFIG_CONDITION_COVERAGE) += -fcondition-coverage
 endif
 
-# Reset COV_FLAGS in cases where an objects has another one as prerequisite
+# Reset cov-cflags-y in cases where an objects has another one as prerequisite
 $(nocov-y) $(filter %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)): \
-    COV_FLAGS :=
+    cov-cflags-y :=
 
-$(non-init-objects): _c_flags += $(COV_FLAGS)
-endif
+$(non-init-objects): _c_flags += $(cov-cflags-y)
 
 ifeq ($(CONFIG_UBSAN),y)
 # Any -fno-sanitize= options need to come after any -fsanitize= options
-- 
2.48.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.