From nobody Mon Apr 29 00:49:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634919069832633.7628111366316; Fri, 22 Oct 2021 09:11:09 -0700 (PDT) Received: from localhost ([::1]:58810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdx8O-0005w6-JY for importer@patchew.org; Fri, 22 Oct 2021 12:11:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdx4f-00031m-J9 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 12:07:18 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]:33319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdx4Z-0004lk-6D for qemu-devel@nongnu.org; Fri, 22 Oct 2021 12:07:14 -0400 Received: by mail-lf1-x129.google.com with SMTP id j21so10262334lfe.0 for ; Fri, 22 Oct 2021 09:07:10 -0700 (PDT) Received: from pc-System-Product-Name.intra.ispras.ru ([85.142.117.226]) by smtp.gmail.com with ESMTPSA id d19sm769200lfa.271.2021.10.22.09.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 09:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Ul02qr83p0UCQN00dY8EGmXSFR8bKuehRSmvwndXbGs=; b=LZ9CJLSOIETbB2nYmaRM4k/Ob5fGdkokpNr64TZr6vU546gxoladtfqhyWFTLjjg9Y MW03Sb1AeKliU/4fZ0PcJXyDzLArG8WlS3YgxRdxp5jsbx5lAveN60s5ynasM7ZiM8J1 UZHYOFBTFj7Nhrr9+tTr7HpIGrJEb/TK3l+dehTOfI/CFaBFK66pcJmmjeogOOkjRzay lKEOgGARjTX/r550HtkpV8BmqddgPiy/970np5G7W+qb3W1Y2Q4I1BBYU2tUKPTA8cPm Ik2E2zmZn8+UGhKxf3yKR3H7psSP59+VeAOmNttLkTRiJ1RWmFGmOwkYNYIriy2636bF GlwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Ul02qr83p0UCQN00dY8EGmXSFR8bKuehRSmvwndXbGs=; b=Cr17ED2eDBirqyvnQVEFkZG0hooDFoO9sJBUrCM7nnu3hpALFTYAgSsydk9CvJ9NGH yNLyIu03p5uHV8nPw0BQRv/Ia23MxEBrtMtsGFCaVoFzAtpxt9jMH7vhNWlPcPx3mAWs lKariuXK53ZjQEq+OgIcIEvCtYXVWk79fKAW56xa1aYqW9zEDm4UDLTiOtjba4tmZDXp 3WDjTmGzEujfIfk1ER6B3UN2VLT76cdK4YuNuo2B66cTbJvnfM0LlilDPjSBqCghxsDz PfIdCvKJ8gZKr17/eInUIJY/NudM8FtHaqVYWVNvszjtILPdeZ7N8Io2hECe4NxUsJUA j+ug== X-Gm-Message-State: AOAM533gU0EtR/adSd4XxtwesJ7L34Ksni02aICvPGS1uVQzPLuEORaE GU/MmURCkGI97BA8Jl1gA/TIT3V30+TQlg== X-Google-Smtp-Source: ABdhPJxPEgge5mMpkvIwpKHl4B6k6uhp6Nz9dHBcOP4WOBrnV74cpSuGzBqoTfCC860oLIaP0QYrNA== X-Received: by 2002:a05:6512:3a92:: with SMTP id q18mr563916lfu.198.1634918829491; Fri, 22 Oct 2021 09:07:09 -0700 (PDT) From: NDNF To: qemu-devel@nongnu.org Subject: [PATCH v3 1/3] src/plugins: sorted list Date: Fri, 22 Oct 2021 19:07:03 +0300 Message-Id: <163491882316.304355.6955215012706902188.stgit@pc-System-Product-Name> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163491872706.304355.11795681036780988723.stgit@pc-System-Product-Name> References: <163491872706.304355.11795681036780988723.stgit@pc-System-Product-Name> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=arkaisp2021@gmail.com; helo=mail-lf1-x129.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: arkadiy.ivanov@ispras.ru, alex.bennee@linaro.org, pavel.dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634919072012100001 The list is sorted to make it easier to find missing characters Signed-off-by: Ivanov Arkady --- plugins/qemu-plugins.symbols | 52 +++++++++++++++++++++-----------------= ---- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 4bdb381f48..688db92773 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -1,40 +1,40 @@ { - qemu_plugin_uninstall; - qemu_plugin_reset; - qemu_plugin_register_vcpu_init_cb; + qemu_plugin_get_hwaddr; + qemu_plugin_hwaddr_is_io; + qemu_plugin_hwaddr_to_raddr; + qemu_plugin_insn_data; + qemu_plugin_insn_disas; + qemu_plugin_insn_haddr; + qemu_plugin_insn_size; + qemu_plugin_insn_vaddr; + qemu_plugin_mem_is_big_endian; + qemu_plugin_mem_is_sign_extended; + qemu_plugin_mem_is_store; + qemu_plugin_mem_size_shift; + qemu_plugin_n_max_vcpus; + qemu_plugin_n_vcpus; + qemu_plugin_outs; + qemu_plugin_ram_addr_from_host; + qemu_plugin_register_atexit_cb; + qemu_plugin_register_flush_cb; qemu_plugin_register_vcpu_exit_cb; qemu_plugin_register_vcpu_idle_cb; - qemu_plugin_register_vcpu_resume_cb; + qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; qemu_plugin_register_vcpu_insn_exec_inline; qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_haddr_cb; qemu_plugin_register_vcpu_mem_inline; - qemu_plugin_ram_addr_from_host; - qemu_plugin_register_vcpu_tb_trans_cb; - qemu_plugin_register_vcpu_tb_exec_cb; - qemu_plugin_register_vcpu_tb_exec_inline; - qemu_plugin_register_flush_cb; + qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; - qemu_plugin_register_atexit_cb; - qemu_plugin_tb_n_insns; + qemu_plugin_register_vcpu_tb_exec_cb; + qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_vcpu_tb_trans_cb; + qemu_plugin_reset; qemu_plugin_tb_get_insn; + qemu_plugin_tb_n_insns; qemu_plugin_tb_vaddr; - qemu_plugin_insn_data; - qemu_plugin_insn_size; - qemu_plugin_insn_vaddr; - qemu_plugin_insn_haddr; - qemu_plugin_insn_disas; - qemu_plugin_mem_size_shift; - qemu_plugin_mem_is_sign_extended; - qemu_plugin_mem_is_big_endian; - qemu_plugin_mem_is_store; - qemu_plugin_get_hwaddr; - qemu_plugin_hwaddr_is_io; - qemu_plugin_hwaddr_to_raddr; + qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; - qemu_plugin_n_vcpus; - qemu_plugin_n_max_vcpus; - qemu_plugin_outs; }; From nobody Mon Apr 29 00:49:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16349191544051023.3352375933312; Fri, 22 Oct 2021 09:12:34 -0700 (PDT) Received: from localhost ([::1]:35418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdx9l-0000s1-Bz for importer@patchew.org; Fri, 22 Oct 2021 12:12:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdx4n-00036o-6J for qemu-devel@nongnu.org; Fri, 22 Oct 2021 12:07:26 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]:34338) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdx4l-0004q6-2u for qemu-devel@nongnu.org; Fri, 22 Oct 2021 12:07:24 -0400 Received: by mail-lj1-x230.google.com with SMTP id 145so1655031ljj.1 for ; Fri, 22 Oct 2021 09:07:21 -0700 (PDT) Received: from pc-System-Product-Name.intra.ispras.ru ([85.142.117.226]) by smtp.gmail.com with ESMTPSA id v13sm1006551ljk.72.2021.10.22.09.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 09:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Za/D2UN9Z9+XEWh61kGs3HCg0PZ2jhxOM6dupbpj9N8=; b=JSbVHyFd6lw79tIxn2xe6gqhf6LrpBG4rlCEnu3JNyRYZ/jJrRUuQ2GbTYhbt/vg+1 Wxm6VpbI405+dB2l+uakmVNbGD0ojcITIK3bhdSqdgsNmmdY74ukcw0qZ/Asw/LQ1Had TxwKK8uwPDDqrp3isp0lsIDWQPiEUiSK9gLBir94DvQMXjs3jz//0FVtuISNvXPIZTcv C7czeUnbrczBSvE2FIJIoBrgkRHBqXTFZEapaFxqWKBmZgMVaRRnaddjVrOUhwJG2+PM 5T9uja+loA7C8lNVTx/ybC+8XaM9mVM2axTWIZ1PyNPNhZxZrnRQzMUnaYU7oqysptPl Or3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Za/D2UN9Z9+XEWh61kGs3HCg0PZ2jhxOM6dupbpj9N8=; b=BBCbJqfs7bBplXukFjDdKFao0HtMtkk2sBznuu5Iuk1D6hljlNQZ8ecrgiVLddUkRg eFj6Am41zG7j+5XVw2bua5ccIipF2G+ix58/3jRAG2HqzQcgTu0SJ5tY94QyzVaBqtxI 4Lf4J0U6tZ4av7oRRV9SlO2GKQSwgal9O1+8UNbC84sDB+PLjawsBxCJ4FS3yzWAGFxh fclTKJVhfAs7EJY4lao8b2LKu8+9H7FkPNJrdJarygKXNfPGKnxRa03nysma3u3FOPOq OWNW6O2NmRKgeyW8DFq6JWJ7fWl8ubN8vfscPOV9IE7OmpDZ41r2Yh6AW/5hjec+xWgQ fh8A== X-Gm-Message-State: AOAM532HOcBWn552UnC3NitbwVgSAc8BffBZHUJ8a55TB9iy5n+cvXLp BmAR3NMCFOktHKkCvcGBNFDyigPsbyQfTQ== X-Google-Smtp-Source: ABdhPJw21VgPQXlFT8c1RZcjjG3MRnX+bSAQlmkZrk4ZWJPO5Fan6c0kA0jHmxoRA6IM1iQUDIFr4g== X-Received: by 2002:a2e:b5db:: with SMTP id g27mr767705ljn.531.1634918840405; Fri, 22 Oct 2021 09:07:20 -0700 (PDT) From: NDNF To: qemu-devel@nongnu.org Subject: [PATCH v3 2/3] This patch adds helper functions to the drcov plugin. Date: Fri, 22 Oct 2021 19:07:14 +0300 Message-Id: <163491883461.304355.8210754161847179432.stgit@pc-System-Product-Name> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163491872706.304355.11795681036780988723.stgit@pc-System-Product-Name> References: <163491872706.304355.11795681036780988723.stgit@pc-System-Product-Name> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=arkaisp2021@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: arkadiy.ivanov@ispras.ru, alex.bennee@linaro.org, pavel.dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634919157345100001 Which provide information about: - start_code. - end_code. - entry. - path to the executable binary. Signed-off-by: Ivanov Arkady --- include/qemu/qemu-plugin.h | 17 ++++++++++++++++ plugins/api.c | 44 ++++++++++++++++++++++++++++++++++++++= ++++ plugins/qemu-plugins.symbols | 4 ++++ 3 files changed, 65 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 5775e82c4e..68af67acf2 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -405,4 +405,21 @@ int qemu_plugin_n_max_vcpus(void); */ void qemu_plugin_outs(const char *string); =20 +/** + * qemu_plugin_path_to_binary() - returns path to binary file being execut= ed + */ +QEMU_PLUGIN_EXPORT const char *qemu_plugin_path_to_binary(void); +/** + * qemu_plugin_start_code() - returns start of text segment + */ +QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_start_code(void); +/** + * qemu_plugin_end_code() - returns end of text segment + */ +QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_end_code(void); +/** + * qemu_plugin_entry_code() - returns start address for module + */ +QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_entry_code(void); + #endif /* QEMU_PLUGIN_API_H */ diff --git a/plugins/api.c b/plugins/api.c index bbdc5a4eb4..064eebacd1 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -48,6 +48,10 @@ #endif #include "trace/mem.h" =20 +#ifdef CONFIG_USER_ONLY +#include "qemu.h" +#endif + /* Uninstall and Reset handlers */ =20 void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) @@ -340,3 +344,43 @@ void qemu_plugin_outs(const char *string) { qemu_log_mask(CPU_LOG_PLUGIN, "%s", string); } + +const char *qemu_plugin_path_to_binary(void) +{ +#ifdef CONFIG_USER_ONLY + TaskState *ts =3D (TaskState *) current_cpu->opaque; + return ts->bprm->filename; +#else + return "path"; +#endif +} + +uint64_t qemu_plugin_start_code(void) +{ +#ifdef CONFIG_USER_ONLY + TaskState *ts =3D (TaskState *) current_cpu->opaque; + return ts->info->start_code; +#else + return 0; +#endif +} + +uint64_t qemu_plugin_end_code(void) +{ +#ifdef CONFIG_USER_ONLY + TaskState *ts =3D (TaskState *) current_cpu->opaque; + return ts->info->end_code; +#else + return 0xFFFFFFFF; +#endif +} + +uint64_t qemu_plugin_entry_code(void) +{ +#ifdef CONFIG_USER_ONLY + TaskState *ts =3D (TaskState *) current_cpu->opaque; + return ts->info->entry; +#else + return 0; +#endif +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 688db92773..d956888f67 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -1,4 +1,6 @@ { + qemu_plugin_end_code; + qemu_plugin_entry_code; qemu_plugin_get_hwaddr; qemu_plugin_hwaddr_is_io; qemu_plugin_hwaddr_to_raddr; @@ -14,6 +16,7 @@ qemu_plugin_n_max_vcpus; qemu_plugin_n_vcpus; qemu_plugin_outs; + qemu_plugin_path_to_binary; qemu_plugin_ram_addr_from_host; qemu_plugin_register_atexit_cb; qemu_plugin_register_flush_cb; @@ -32,6 +35,7 @@ qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; + qemu_plugin_start_code; qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; qemu_plugin_tb_vaddr; From nobody Mon Apr 29 00:49:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163491917569094.40212449720343; Fri, 22 Oct 2021 09:12:55 -0700 (PDT) Received: from localhost ([::1]:37042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdxA6-0001yG-MG for importer@patchew.org; Fri, 22 Oct 2021 12:12:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdx4x-0003Qe-0B for qemu-devel@nongnu.org; Fri, 22 Oct 2021 12:07:35 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]:43549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdx4u-00056u-Av for qemu-devel@nongnu.org; Fri, 22 Oct 2021 12:07:34 -0400 Received: by mail-lf1-x129.google.com with SMTP id bq11so3741356lfb.10 for ; Fri, 22 Oct 2021 09:07:31 -0700 (PDT) Received: from pc-System-Product-Name.intra.ispras.ru ([85.142.117.226]) by smtp.gmail.com with ESMTPSA id c15sm766522lff.238.2021.10.22.09.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 09:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=+InlGJvPCaCvmTuBKMOkWCL9YA+wZbOiycFkKePOVzs=; b=MkZC2n7FWMfABKY2MKy5/8ajnuAJ2+ks2aBww6XcutjE/bg1ZlzIdbiSW1hmdiX8X5 gEI+JUB52Dfp9lmtG5MPQebbN+SQasvKA7YSCWHp/NcjF2iSKzrl9lzGAiGPzPJvwDYD DGma7CzpCLTfbEsyU/bD7dj7k65mj1MlsBWZ1xsM7RUsXQOkBsa//5ObsuYiWcMYIXUc Ki5bsnu880zVXn6BFy65Oao3rxetVSxWJZz4FgJuUjzb+sSNH0mTe8T0kWjT1R0VIlz6 iuNNqwdcUmNgpqDf2WTu4poEvFJVxkLUKIYgoDwIrchoQgQlZLg7w4F62BsJHeS0EQzT SIew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=+InlGJvPCaCvmTuBKMOkWCL9YA+wZbOiycFkKePOVzs=; b=Ji61Ce5HKc3YXMJUGgp3M4oovJN+dEwg4aWneKSeZlng6oR9NMjs3vVC8bNJ6850+U xCqnM+B4syXo/ywiOuZnlaHZkL43kPBeEi6sE4S+h70Vkkl7HShwloUkKqdTdvYcbvHy 3qJ0ekJpqdvZeEyYyAClytg5HDbZykyDjsPK80l9b/A1jxyBFNhsrPkbD6MHQvV3DGLd q653zveDZMgD6hldG96jn+EmPjBhkn2jC3xjJUVoDxwQTjSwvMEg20CVEtBi28OzbBCP R7flYRXQAs88ab7YnjtvFS1c6tJmBSl+UVg9q1oTl2Aric1t26LynieAhaUArFY8YL9L ia8Q== X-Gm-Message-State: AOAM5304UlsEcJr/ge0V4aXxJX9wzvEplhhO+Z/68UQdE5JSbOwzJ7f7 s6EkZjmqgPvF4PLHFf9Hf3sCM7gCA6tsmg== X-Google-Smtp-Source: ABdhPJyrWI+d0aCIimvz0QDtbxWBTLHL5vrrirAGKrNXKjMHyaYEtaImvDS8qpULgP13YrczftAcNw== X-Received: by 2002:a05:6512:36ce:: with SMTP id e14mr546137lfs.328.1634918850751; Fri, 22 Oct 2021 09:07:30 -0700 (PDT) From: NDNF To: qemu-devel@nongnu.org Subject: [PATCH v3 3/3] contrib/plugins: add a drcov plugin Date: Fri, 22 Oct 2021 19:07:25 +0300 Message-Id: <163491884553.304355.13246023070235438959.stgit@pc-System-Product-Name> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163491872706.304355.11795681036780988723.stgit@pc-System-Product-Name> References: <163491872706.304355.11795681036780988723.stgit@pc-System-Product-Name> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=arkaisp2021@gmail.com; helo=mail-lf1-x129.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: arkadiy.ivanov@ispras.ru, alex.bennee@linaro.org, pavel.dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634919176242100001 This patch adds the ability to generate files in drcov format. Primary goal this script is to have coverage logfiles thatwork in Lighthouse. Signed-off-by: Ivanov Arkady --- contrib/plugins/Makefile | 1=20 contrib/plugins/drcov.c | 152 ++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 153 insertions(+) create mode 100644 contrib/plugins/drcov.c diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index 7801b08b0d..0a681efeec 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -17,6 +17,7 @@ NAMES +=3D hotblocks NAMES +=3D hotpages NAMES +=3D howvec NAMES +=3D lockstep +NAMES +=3D drcov =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 diff --git a/contrib/plugins/drcov.c b/contrib/plugins/drcov.c new file mode 100644 index 0000000000..a655f1337c --- /dev/null +++ b/contrib/plugins/drcov.c @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2021, Ivanov Arkady + * + * Drcov - a DynamoRIO-based tool that collects coverage information + * from a binary. Primary goal this script is to have coverage log + * files that work in Lighthouse. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +static char header[] =3D "DRCOV VERSION: 2\n" + "DRCOV FLAVOR: drcov-64\n" + "Module Table: version 2, count 1\n" + "Columns: id, base, end, entry, path\n"; + +static FILE *fp; +static char *file_name =3D "file.drcov.trace"; +static GMutex lock; + +typedef struct { + uint32_t start; + uint16_t size; + uint16_t mod_id; + bool exec; +} bb_entry_t; + +static GSList *bbs; + +static void printf_header(void) +{ + fprintf(fp, "%s", header); + const char *path =3D qemu_plugin_path_to_binary(); + uint64_t start_code =3D qemu_plugin_start_code(); + uint64_t end_code =3D qemu_plugin_end_code(); + uint64_t entry =3D qemu_plugin_entry_code(); + fprintf(fp, "0, 0x%lx, 0x%lx, 0x%lx, %s\n", + start_code, end_code, entry, path); + fprintf(fp, "BB Table: %d bbs\n", g_slist_length(bbs)); +} + +static void printf_char_array32(uint32_t data) +{ + const uint8_t *bytes =3D (const uint8_t *)(&data); + fwrite(bytes, sizeof(char), sizeof(data), fp); +} + +static void printf_char_array16(uint16_t data) +{ + const uint8_t *bytes =3D (const uint8_t *)(&data); + fwrite(bytes, sizeof(char), sizeof(data), fp); +} + + +static void printf_el(gpointer data, gpointer user_data) +{ + g_mutex_lock(&lock); + + bb_entry_t *bb =3D (bb_entry_t *)data; + if (bb->exec) { + printf_char_array32(bb->start); + printf_char_array16(bb->size); + printf_char_array16(bb->mod_id); + } + + g_mutex_unlock(&lock); +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + /* Print function */ + printf_header(); + bbs =3D g_slist_reverse(bbs); + g_slist_foreach(bbs, printf_el, NULL); + + /* Clear */ + g_slist_free_full(bbs, &g_free); + fclose(fp); +} + +static void plugin_init(void) +{ + fp =3D fopen(file_name, "wb"); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + g_mutex_lock(&lock); + + bb_entry_t *bb =3D (bb_entry_t *)udata; + bb->exec =3D true; + + g_mutex_unlock(&lock); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + uint64_t pc =3D qemu_plugin_tb_vaddr(tb); + + size_t n =3D qemu_plugin_tb_n_insns(tb); + + g_mutex_lock(&lock); + + bb_entry_t *bb =3D g_new0(bb_entry_t, 1); + for (int i =3D 0; i < n; i++) { + bb->size +=3D qemu_plugin_insn_size(qemu_plugin_tb_get_insn(tb, i)= ); + } + + bb->start =3D pc; + bb->mod_id =3D 0; + bb->exec =3D false; + + bbs =3D g_slist_prepend(bbs, bb); + g_mutex_unlock(&lock); + + qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, + QEMU_PLUGIN_CB_NO_REGS, + (void *)bb); + +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + for (int i =3D 0; i < argc; i++) { + g_autofree char **tokens =3D g_strsplit(argv[i], "=3D", 2); + if (g_strcmp0(tokens[0], "filename") =3D=3D 0) { + file_name =3D g_strdup(tokens[1]); + } + } + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +}