From patchwork Fri Sep 8 16:20:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javi Merino X-Patchwork-Id: 13377659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00DB3EE801A for ; Fri, 8 Sep 2023 16:21:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.598077.932579 (Exim 4.92) (envelope-from ) id 1qeeE2-0006Eu-Af; Fri, 08 Sep 2023 16:20:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 598077.932579; Fri, 08 Sep 2023 16:20:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qeeE2-0006El-7Q; Fri, 08 Sep 2023 16:20:54 +0000 Received: by outflank-mailman (input) for mailman id 598077; Fri, 08 Sep 2023 16:20:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qeeE0-0006Dr-N1 for xen-devel@lists.xenproject.org; Fri, 08 Sep 2023 16:20:52 +0000 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [2a00:1450:4864:20::330]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ad82f35e-4e63-11ee-8783-cb3800f73035; Fri, 08 Sep 2023 18:20:51 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-401da71b85eso24135955e9.1 for ; Fri, 08 Sep 2023 09:20:51 -0700 (PDT) Received: from EMEAENG6DZjqCfH.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id m24-20020a7bce18000000b003feee8d8011sm5574352wmc.41.2023.09.08.09.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 09:20:50 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ad82f35e-4e63-11ee-8783-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1694190051; x=1694794851; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MOfLOXf8yDOC8XjMaviIU41n1ePC1cU7Y3evBR4kK7U=; b=K8mdn5Q94CNNnx2T8A6ViyRSfG/oVqGYMbGdZPc+CEFx3gQo/2gf54EKOkvy14ol32 pmp6dQwMDTCcIzb5L6Y7zglAiS9axfKTc5TXczo7Olwpha9q3bMAvzOwJrIVpO5KZupy d6BQRHEOQo7KjKlALJBVSV8hYo1LUHXagmoPw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694190051; x=1694794851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MOfLOXf8yDOC8XjMaviIU41n1ePC1cU7Y3evBR4kK7U=; b=IShzHfP3NLw9AVva6/TWmD0VqkccWpU6Li7MP1DG2zjat2czu4c/iQPhn+p/7wcNZU Tcsge+REsYiIKJLE2TSkXHLyTMprbKWh+mYK+MmDGeSG4J5p9eo72ZdhVPG+q3Ac7AmF /fzkqMEGPe9+aCWV35EH3YElATB+TA2he3Hehl3ZaZSNU+MLSkqb+lHjQQvHleUU/7l4 u+yItmyf7CdNZA5S5+XPXNDX7C1Gj3aILSLCXPJC+VdR0po/SgQMqVq9KgzjNijWpqp2 ziyCByva0uviHb14fU7zJGoZRgH00uOlKEq/TjBPh4W5FA8h26ZDoaB5oqEDgEDMs5u3 70tw== X-Gm-Message-State: AOJu0Yz/I3CwvDEopT3WXLPejNb6NBBzi24WQQcZWGsGgoCktmqjvF19 zNJMsUoPTb7PBwR7JjO8/KTmclFaPvaBbFQ5seYp4g== X-Google-Smtp-Source: AGHT+IFLGgaR3GaQNT/hO3YT4Jx265RaO4F39ZDC5SpvsBK3M3KAx7cJhbueYwfpjTdAt+JecgOvpA== X-Received: by 2002:a05:600c:2249:b0:3fe:111a:d1d9 with SMTP id a9-20020a05600c224900b003fe111ad1d9mr2578357wmm.25.1694190050831; Fri, 08 Sep 2023 09:20:50 -0700 (PDT) From: Javi Merino To: xen-devel@lists.xenproject.org Cc: Javi Merino , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version Date: Fri, 8 Sep 2023 17:20:31 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 The current structure of choosing the correct file based on the compiler version makes us make 33 line files just to define a constant. The changes after gcc 4.7 are minimal, just the number of counters. Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to remove a lot of the boilerplate and keep the logic of choosing the GCOV_COUNTER in gcc_4_7.c. Signed-off-by: Javi Merino Reviewed-by: Jan Beulich --- xen/common/coverage/Makefile | 6 +----- xen/common/coverage/gcc_4_7.c | 17 +++++++++-------- xen/common/coverage/gcc_4_9.c | 33 --------------------------------- xen/common/coverage/gcc_5.c | 33 --------------------------------- xen/common/coverage/gcc_7.c | 30 ------------------------------ 5 files changed, 10 insertions(+), 109 deletions(-) delete mode 100644 xen/common/coverage/gcc_4_9.c delete mode 100644 xen/common/coverage/gcc_5.c delete mode 100644 xen/common/coverage/gcc_7.c diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile index 63f98c71d6..d729afc9c7 100644 --- a/xen/common/coverage/Makefile +++ b/xen/common/coverage/Makefile @@ -1,11 +1,7 @@ obj-y += coverage.o ifneq ($(CONFIG_CC_IS_CLANG),y) obj-y += gcov_base.o gcov.o -obj-y += $(call cc-ifversion,-lt,0407, \ - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \ - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \ - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \ - gcc_5.o, gcc_7.o)))) +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o) else obj-y += llvm.o endif diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c index 25b4a8bcdc..ddbc9f4bb0 100644 --- a/xen/common/coverage/gcc_4_7.c +++ b/xen/common/coverage/gcc_4_7.c @@ -18,15 +18,16 @@ #include "gcov.h" -/* - * GCOV_COUNTERS will be defined if this file is included by other - * source files. - */ -#ifndef GCOV_COUNTERS -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900) -# error "Wrong version of GCC used to compile gcov" -# endif +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900) #define GCOV_COUNTERS 8 +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000) +#define GCOV_COUNTERS 9 +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000 +#define GCOV_COUNTERS 10 +#elif GCC_VERSION >= 70000 +#define GCOV_COUNTERS 9 +#else +#error "Wrong version of GCC used to compile gcov" #endif #define GCOV_TAG_FUNCTION_LENGTH 3 diff --git a/xen/common/coverage/gcc_4_9.c b/xen/common/coverage/gcc_4_9.c deleted file mode 100644 index dcea961936..0000000000 --- a/xen/common/coverage/gcc_4_9.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This code provides functions to handle gcc's profiling data format - * introduced with gcc 4.7. - * - * For a better understanding, refer to gcc source: - * gcc/gcov-io.h - * libgcc/libgcov.c - * - * Uses gcc-internal data definitions. - * - * Imported from Linux and modified for Xen by - * Wei Liu - */ - -#include "gcov.h" - -#if !(GCC_VERSION >= 40900 && GCC_VERSION < 50000) -#error "Wrong version of GCC used to compile gcov" -#endif - -#define GCOV_COUNTERS 9 - -#include "gcc_4_7.c" - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/common/coverage/gcc_5.c b/xen/common/coverage/gcc_5.c deleted file mode 100644 index 6e0d276f3b..0000000000 --- a/xen/common/coverage/gcc_5.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This code provides functions to handle gcc's profiling data format - * introduced with gcc 5. - * - * For a better understanding, refer to gcc source: - * gcc/gcov-io.h - * libgcc/libgcov.c - * - * Uses gcc-internal data definitions. - * - * Imported from Linux and modified for Xen by - * Wei Liu - */ - -#include "gcov.h" - -#if GCC_VERSION < 50000 || GCC_VERSION >= 70000 -#error "Wrong version of GCC used to compile gcov" -#endif - -#define GCOV_COUNTERS 10 - -#include "gcc_4_7.c" - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/common/coverage/gcc_7.c b/xen/common/coverage/gcc_7.c deleted file mode 100644 index 3962eb4c76..0000000000 --- a/xen/common/coverage/gcc_7.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This code provides functions to handle gcc's profiling data format - * introduced with gcc 7. - * - * For a better understanding, refer to gcc source: - * gcc/gcov-io.h - * libgcc/libgcov.c - * - * Uses gcc-internal data definitions. - */ - -#include "gcov.h" - -#if GCC_VERSION < 70000 -#error "Wrong version of GCC used to compile gcov" -#endif - -#define GCOV_COUNTERS 9 - -#include "gcc_4_7.c" - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ From patchwork Fri Sep 8 16:20:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javi Merino X-Patchwork-Id: 13377660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB613EE801B for ; Fri, 8 Sep 2023 16:21:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.598078.932589 (Exim 4.92) (envelope-from ) id 1qeeE5-0006W7-JE; Fri, 08 Sep 2023 16:20:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 598078.932589; Fri, 08 Sep 2023 16:20:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qeeE5-0006Vt-Ft; Fri, 08 Sep 2023 16:20:57 +0000 Received: by outflank-mailman (input) for mailman id 598078; Fri, 08 Sep 2023 16:20:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qeeE4-0005vx-Az for xen-devel@lists.xenproject.org; Fri, 08 Sep 2023 16:20:56 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id af5fac43-4e63-11ee-9b0d-b553b5be7939; Fri, 08 Sep 2023 18:20:54 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fef56f7248so23746055e9.3 for ; Fri, 08 Sep 2023 09:20:54 -0700 (PDT) Received: from EMEAENG6DZjqCfH.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id m24-20020a7bce18000000b003feee8d8011sm5574352wmc.41.2023.09.08.09.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 09:20:53 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: af5fac43-4e63-11ee-9b0d-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1694190054; x=1694794854; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i6wE+Q6YPhjgRGDUDttaAAhWjDOLXM9ZsbpkHij4TSA=; b=jwk3vVjwzUxByXybHEWPNX/3lDDjDWBjQHyfjz2Ko591E4NpvYTNcskng4EJ3f8EML 7dXEfCJ/iKtioFl7sICe8tK6JpBTqREwY/H+ztYOjrUuNPFCF1AUInv9mvPth2E+jUJ3 IUATI6QltvbnlzQ/GZYdYdPhoZ7ZY23JM0OrU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694190054; x=1694794854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i6wE+Q6YPhjgRGDUDttaAAhWjDOLXM9ZsbpkHij4TSA=; b=ZLkbGo0zOp8aUf6AStWPxdmmCf3a0nW63ei2XJ/uxKyDgYQJTFAfUlhZ5RCr/ZQ4cr RozgQ1rxUwx93E0wpBmOP1tl7BobCv1LIBUyjsrbIQLDuDz8P3JwJjp+cj4vZpBhqudL euuNCe088I6/ger6m1T/iMYMFcIDT7JE4eYd8xRJp43juayk8gEJMF5InJgQuwt8gkN0 1+Pi7YKV/Bi/juiX28UgqLhdIJKKbPkg7I/s79VavjKgL+jHQU18ueAOj+RIz6RCmZrP 3YVebaDzQohtYL8w5tGU+a6hnImflI/Gazf+eZQ+MYCWb0Y8R+JnEJsIVza/juN1gE8p Z7jQ== X-Gm-Message-State: AOJu0YymcUhgsVMPFTo4xukL0ZSH6guCFfbeL/72MdP2ASRYS3j2gchG GZWxhVkFBS4FlXt6diVGlyTdX8lKO/NFkGqgGfihkA== X-Google-Smtp-Source: AGHT+IHpKLXmgdlDykh/Lnsr/L+EHgmoX4EoZJ5vI1LnOskXlwZ4GNncyfTrAy2rVtqS5OLbNIXq3g== X-Received: by 2002:a7b:c8c4:0:b0:402:8c7e:3fc4 with SMTP id f4-20020a7bc8c4000000b004028c7e3fc4mr2417637wml.30.1694190054134; Fri, 08 Sep 2023 09:20:54 -0700 (PDT) From: Javi Merino To: xen-devel@lists.xenproject.org Cc: Javi Merino , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc Date: Fri, 8 Sep 2023 17:20:32 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Shamelessly copy changes to gcov_info structures from linux so that we can capture coverage for xen built with newer compilers. Signed-off-by: Javi Merino Acked-by: Jan Beulich --- xen/common/coverage/gcc_4_7.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c index ddbc9f4bb0..8f6e287474 100644 --- a/xen/common/coverage/gcc_4_7.c +++ b/xen/common/coverage/gcc_4_7.c @@ -24,14 +24,23 @@ #define GCOV_COUNTERS 9 #elif GCC_VERSION >= 50000 && GCC_VERSION < 70000 #define GCOV_COUNTERS 10 -#elif GCC_VERSION >= 70000 +#elif GCC_VERSION >= 70000 && GCC_VERSION < 100000 #define GCOV_COUNTERS 9 +#elif GCC_VERSION >= 100000 +#define GCOV_COUNTERS 8 #else #error "Wrong version of GCC used to compile gcov" #endif #define GCOV_TAG_FUNCTION_LENGTH 3 +#if GCC_VERSION >= 120000 +/* Since GCC 12.1, sizes are in BYTES and not in WORDS (4B). */ +#define GCOV_UNIT_SIZE 4 +#else +#define GCOV_UNIT_SIZE 1 +#endif + static struct gcov_info *gcov_info_head; /** @@ -89,6 +98,10 @@ struct gcov_info { unsigned int version; struct gcov_info *next; unsigned int stamp; +#if (GCC_VERSION >= 120000) + /* GCC 12.1 introduced a checksum field */ + unsigned int checksum; +#endif const char *filename; void (*merge[GCOV_COUNTERS])(gcov_type *, unsigned int); unsigned int n_functions; @@ -161,13 +174,18 @@ size_t gcov_info_to_gcda(char *buffer, const struct gcov_info *info) pos += gcov_store_uint32(buffer, pos, info->version); pos += gcov_store_uint32(buffer, pos, info->stamp); +#if (GCC_VERSION >= 120000) + /* Use zero as checksum of the compilation unit. */ + pos += gcov_store_uint32(buffer, pos, 0); +#endif + for ( fi_idx = 0; fi_idx < info->n_functions; fi_idx++ ) { fi_ptr = info->functions[fi_idx]; /* Function record. */ pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION); - pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH); + pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE); pos += gcov_store_uint32(buffer, pos, fi_ptr->ident); pos += gcov_store_uint32(buffer, pos, fi_ptr->lineno_checksum); pos += gcov_store_uint32(buffer, pos, fi_ptr->cfg_checksum); @@ -182,7 +200,7 @@ size_t gcov_info_to_gcda(char *buffer, const struct gcov_info *info) /* Counter record. */ pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FOR_COUNTER(ct_idx)); - pos += gcov_store_uint32(buffer, pos, ci_ptr->num * 2); + pos += gcov_store_uint32(buffer, pos, ci_ptr->num * 2 * GCOV_UNIT_SIZE); for ( cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++ ) pos += gcov_store_uint64(buffer, pos, ci_ptr->values[cv_idx]);