From patchwork Thu Nov 9 11:13:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 10050807 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 D753960381 for ; Thu, 9 Nov 2017 11:16:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8A5B2A59D for ; Thu, 9 Nov 2017 11:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD3072AB49; Thu, 9 Nov 2017 11:16:40 +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 625CF2A59D for ; Thu, 9 Nov 2017 11:16:40 +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 1eCkmy-0004kV-41; Thu, 09 Nov 2017 11:14:28 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCkmx-0004i5-2L for xen-devel@lists.xenproject.org; Thu, 09 Nov 2017 11:14:27 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 3D/AC-05188-298340A5; Thu, 09 Nov 2017 11:14:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsXitHRDpO5EC5Y ogxvPLS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oz509YyF2wSqdj0MqqBcYJgFyMnh4SAv8TX 3xcZQWw2AR2Ji3N3snUxcnCICKhI3N5r0MXIxcEs8JxJ4v2EBmaQGmEBP4lvsy+D1bAA1aw+o g4S5hWwktg9bQUrxEg9ieZPJ9lBbE6g+P6LjSwgtpCApcTR232sEPWCEidnPgGLMwtoSrRu/8 0OYctLNG+dzQxRryjRP+8B2wRGvllIWmYhaZmFpGUBI/MqRo3i1KKy1CJdIyO9pKLM9IyS3MT MHF1DAzO93NTi4sT01JzEpGK95PzcTYzAQGMAgh2Ma+YHHmKU5GBSEuV98IopSogvKT+lMiOx OCO+qDQntfgQowwHh5IEL4c5S5SQYFFqempFWmYOMORh0hIcPEoivMdA0rzFBYm5xZnpEKlTj MYcz2a+bmDmmHa1tYlZiCUvPy9VSpy3AKRUAKQ0ozQPbhAsFi8xykoJ8zICnSbEU5BalJtZgi r/ilGcg1FJmNcUZApPZl4J3L5XQKcwAZ0SzQ52SkkiQkqqgXFu+3f/5zftXpgx7Tr8qHJqyW5 Fzsc677pyN2htV1vlz5Hc+HyTRdObo2/P1F6/oGO0ilv+RNLsVTO7pnRNfrP+w16GG0vmWDbE /1xyfl2m7y69cDGz8PvXrO/GP3pZpnoy5V+7mtQJy/jzi74UffHflGFRp3Yz4bPma63fH+7NZ q3J5Xqmm6ioxFKckWioxVxUnAgAc7qixsACAAA= X-Env-Sender: prvs=4793881c9=roger.pau@citrix.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1510226052!114273850!5 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60729 invoked from network); 9 Nov 2017 11:14:25 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-12.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 9 Nov 2017 11:14:25 -0000 X-IronPort-AV: E=Sophos;i="5.44,369,1505779200"; d="scan'208";a="450987297" From: Roger Pau Monne To: Date: Thu, 9 Nov 2017 11:13:49 +0000 Message-ID: <20171109111349.95800-10-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 9/9] coverage: add documentation for LLVM 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 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: - s/gmake/make/. - Fix gcov section to mention CONFIG_COVERAGE instead of CONFIG_GCOV. --- docs/misc/coverage.markdown | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/misc/coverage.markdown b/docs/misc/coverage.markdown index 430cd27b2f..3554659fe4 100644 --- a/docs/misc/coverage.markdown +++ b/docs/misc/coverage.markdown @@ -8,6 +8,8 @@ information. Every basic block in the code will be instrumented by the compiler to compute these statistics. It should not be used in production as it slows down your hypervisor. +# GCOV (GCC coverage) + ## Enable coverage Test coverage support can be turned on compiling Xen with the `CONFIG_COVERAGE` @@ -75,3 +77,48 @@ blob extracted from xencov!** * See output in a browser firefox cov/index.html + +# LLVM coverage + +## Enable coverage + +Coverage can be enabled using a Kconfig option, from the top-level directory +use the following command to display the Kconfig menu: + + make -C xen menuconfig clang=y + +The code coverage option can be found inside of the "Debugging Options" +section. After enabling it just compile Xen as you would normally do: + + make xen clang=y + +## Extract coverage data + +LLVM coverage can be extracted from the hypervisor using the `xencov` tool. +The following actions are available: + +* `xencov read` extract data +* `xencov reset` reset all coverage counters +* `xencov read-reset` extract data and reset counters at the same time. + +## Possible use + +**This section is just an example on how to use these tools!** + +This example assumes you compiled Xen and copied the xen-syms file from +xen/xen-syms into your current directory. + +* Extract the coverage data from Xen: + + xencov read xen.profraw + +* Convert the data into a profile. Note that you can merge more than one + profraw file into a single profdata file. + + llvm-profdata merge xen.profraw -o xen.profdata + +* Generate a HTML report of the code coverage: + + llvm-cov show -format=html -output-dir=cov/ xen-syms -instr-profile=xen.profdata + +* Open cov/index.html with your browser in order to display the profile.