From patchwork Thu Nov 9 11:13:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 10050811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BFCE60381 for ; Thu, 9 Nov 2017 11:16:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CCC82A59D for ; Thu, 9 Nov 2017 11:16:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 216F32AB49; Thu, 9 Nov 2017 11:16:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A65DB2A59D for ; Thu, 9 Nov 2017 11:16:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCkmu-0004fX-8D; Thu, 09 Nov 2017 11:14:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCkms-0004eg-VO for xen-devel@lists.xenproject.org; Thu, 09 Nov 2017 11:14:23 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id FE/20-01779-E88340A5; Thu, 09 Nov 2017 11:14:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRWlGSWpSXmKPExsXitHSDvW6vBUu UwbJt2hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a8LSIF21QrjrVcZWpg/CLfxcjJISHgL/Hl zk5WEJtNQEfi4tydbF2MHBwiAioSt/cadDFycTALPGeSeD+hgRmkRljAUeLNksmMIDYLUM3Tc 6vBenkFLCWOfL7FBDFTT6L500l2EJtTwEpi/8VGFhBbCKjm6O0+qHpBiZMzn4DFmQU0JVq3/2 aHsOUlmrfOZoaoV5Ton/eAbQIj3ywkLbOQtMxC0rKAkXkVo0ZxalFZapGukbFeUlFmekZJbmJ mjq6hgalebmpxcWJ6ak5iUrFecn7uJkZgqNUzMDDuYNzR7neIUZKDSUmU98ErpighvqT8lMqM xOKM+KLSnNTiQ4wyHBxKErxF5ixRQoJFqempFWmZOcCgh0lLcPAoifBeNQNK8xYXJOYWZ6ZDp E4xGnM8m/m6gZlj2tXWJmYhlrz8vFQpcd7vIKUCIKUZpXlwg2DReIlRVkqYl5GBgUGIpyC1KD ezBFX+FaM4B6OSMG8uyD08mXklcPteAZ3CBHRKNDvYKSWJCCmpBkaps0uvJ62Onq/XqtW7mdH Q7DiDoXHhvcMbz14qrNCKPNatbuEu8Er99WwOJuNFmVnz5A5yT/ugGj/p1FbLG5NveBbPPpbe NSfrulC9pfdZdYXZri3tbQk7Zs86W7z76/ecj/uPSevtu/LEfspW0Z6Zix1FzOeK615zWPOCj YeDMf5U8yPHKdeUWIozEg21mIuKEwG1iIU/wQIAAA== X-Env-Sender: prvs=4793881c9=roger.pau@citrix.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1510226050!90964552!4 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28297 invoked from network); 9 Nov 2017 11:14:21 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 9 Nov 2017 11:14:21 -0000 X-IronPort-AV: E=Sophos;i="5.44,369,1505779200"; d="scan'208";a="458674555" From: Roger Pau Monne To: Date: Thu, 9 Nov 2017 11:13:46 +0000 Message-ID: <20171109111349.95800-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.13.6 (Apple Git-96) In-Reply-To: <20171109111349.95800-1-roger.pau@citrix.com> References: <20171109111349.95800-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH v2 for-next 6/9] kconfig/gcov: rename to coverage X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP So it can be used by both gcc and clang. Just add the Kconfig option and modify the makefiles so the llvm coverage specific code can be added in a follow up patch. Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- Changes since v1: - Use a choice in kconfig to select code coverage technology. - Compile coverage.c regardless of selected code coverage technology. - Introduce an unimplemented sysctl_cov_op function if CONFIG_COVERAGE is not set. --- docs/misc/coverage.markdown | 2 +- xen/Kconfig.debug | 7 +++---- xen/Rules.mk | 6 +++++- xen/common/Makefile | 2 +- xen/common/coverage/Makefile | 5 ++++- xen/common/sysctl.c | 2 -- xen/include/xen/coverage.h | 7 ++++++- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/docs/misc/coverage.markdown b/docs/misc/coverage.markdown index b47aba2648..430cd27b2f 100644 --- a/docs/misc/coverage.markdown +++ b/docs/misc/coverage.markdown @@ -10,7 +10,7 @@ down your hypervisor. ## Enable coverage -Test coverage support can be turned on compiling Xen with the `CONFIG_GCOV` +Test coverage support can be turned on compiling Xen with the `CONFIG_COVERAGE` option set to `y`. Change your `.config` or run `make -C xen menuconfig`. diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index 7bb0465b5d..153d68fed3 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -28,12 +28,11 @@ config FRAME_POINTER maybe slower, but it gives very useful debugging information in case of any Xen bugs. -config GCOV - bool "Gcov Support" +config COVERAGE + bool "Code coverage support" depends on !LIVEPATCH - select SUPPRESS_DUPLICATE_SYMBOL_WARNINGS ---help--- - Enable gcov (a test coverage program in GCC) support. + Enable code coverage support. If unsure, say N here. diff --git a/xen/Rules.mk b/xen/Rules.mk index 2659f8a4d1..d1b72e24ab 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -115,9 +115,13 @@ subdir-all := $(subdir-y) $(subdir-n) $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -DINIT_SECTIONS_ONLY -ifeq ($(CONFIG_GCOV),y) +ifeq ($(CONFIG_COVERAGE),y) +ifeq ($(clang),y) +$(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-instr-generate -fcoverage-mapping +else $(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-arcs -ftest-coverage endif +endif ifeq ($(CONFIG_UBSAN),y) $(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fsanitize=undefined diff --git a/xen/common/Makefile b/xen/common/Makefile index ad181636f6..3a349f478b 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -74,7 +74,7 @@ tmem-y := tmem.o tmem_xen.o tmem_control.o tmem-$(CONFIG_COMPAT) += compat/tmem_xen.o obj-$(CONFIG_TMEM) += $(tmem-y) -subdir-$(CONFIG_GCOV) += coverage +subdir-$(CONFIG_COVERAGE) += coverage subdir-$(CONFIG_UBSAN) += ubsan subdir-y += libelf diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile index 5387bc6429..1039a160c4 100644 --- a/xen/common/coverage/Makefile +++ b/xen/common/coverage/Makefile @@ -1,6 +1,9 @@ -obj-y += coverage.o gcov_base.o gcov.o +obj-y += coverage.o +ifneq ($(clang),y) +obj-y += gcov_base.o gcov.o obj-y += $(call cc-ifversion,lt,0x040700, \ gcc_3_4.o, $(call cc-ifversion,lt,0x040900, \ gcc_4_7.o, $(call cc-ifversion,lt,0x050000, \ gcc_4_9.o, $(call cc-ifversion,lt,0x070000, \ gcc_5.o, gcc_7.o)))) +endif diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index f2ae6295ff..8e83c33a16 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -396,12 +396,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) } break; -#ifdef CONFIG_GCOV case XEN_SYSCTL_coverage_op: ret = sysctl_cov_op(&op->u.coverage_op); copyback = 1; break; -#endif #ifdef CONFIG_HAS_PCI case XEN_SYSCTL_pcitopoinfo: diff --git a/xen/include/xen/coverage.h b/xen/include/xen/coverage.h index daddef37d3..098f116760 100644 --- a/xen/include/xen/coverage.h +++ b/xen/include/xen/coverage.h @@ -1,9 +1,14 @@ #ifndef _XEN_COV_H #define _XEN_COV_H -#ifdef CONFIG_GCOV +#ifdef CONFIG_COVERAGE #include int sysctl_cov_op(struct xen_sysctl_coverage_op *op); +#else +static inline int sysctl_cov_op(void *unused) +{ + return -ENOSYS; +} #endif #endif /* _XEN_GCOV_H */