From nobody Sat May 18 04:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1597234750; cv=none; d=zohomail.com; s=zohoarc; b=fdx+3cvrJ7WFyyrG4+qTdeHvILuEPsQaBmP4qxxfoiB0p7H6JHhSrtX++XP9rZYPYwt6B+4CkR+/JPkf5cQNaJuYXguBfS6GqsoP1PhdRsPipPr4jSfzZQwMMO6h4VXBhRqXloYGN/yCpfUpJSFgCBe4w5c/fFBRhVGqBbAuSXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597234750; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=WPyfanBQHSgbh057unYYbmBTQkSDAC4xa2IcyfXfxeI=; b=IhK4SypVFZab2iWEah015J+pxyPNWckbYkF8fGBptqtC/D/v5g4ppKGnSmlj7WvcLs8uTNNBKnJ4bQl9KNkJz9tGoj/02bkQCrfaJOGoByJNowY6AaNzuqZ8nzJJbGAut8mqb2syqhi9o1ojyCEA8CfiTKyYIL3c/PxQ61uYC8c= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597234750361300.27160742549427; Wed, 12 Aug 2020 05:19:10 -0700 (PDT) Received: from localhost ([::1]:42284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5pin-0006al-0X for importer@patchew.org; Wed, 12 Aug 2020 08:19:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5ph9-0005Qx-Ua for qemu-devel@nongnu.org; Wed, 12 Aug 2020 08:17:27 -0400 Received: from weckbecker.name ([87.118.122.104]:64220) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5ph5-0002ON-Ut for qemu-devel@nongnu.org; Wed, 12 Aug 2020 08:17:27 -0400 Received: by weckbecker.name (Postfix, from userid 1000) id 654441A83AC; Wed, 12 Aug 2020 13:59:14 +0200 (CEST) From: Matthias Weckbecker To: qemu-devel@nongnu.org Subject: [PATCH] plugins: new syscalls plugin Date: Wed, 12 Aug 2020 13:58:17 +0200 Message-Id: <20200812115816.4454-1-matthias@weckbecker.name> 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=87.118.122.104; envelope-from=matthias@weckbecker.name; helo=weckbecker.name X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 08:17:14 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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: Matthias Weckbecker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This commit adds a new syscalls plugin that displays the syscalls as they are executed and returned. This plugin outputs the number of the syscall as well as the syscall return value. Works in *-user only. Essentially, this commit restores: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg00846.html by using the new QEMU plugin API. Signed-off-by: Matthias Weckbecker --- tests/plugin/Makefile | 1 + tests/plugin/syscall.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/plugin/syscall.c diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile index e9348fde4a..fc176909e9 100644 --- a/tests/plugin/Makefile +++ b/tests/plugin/Makefile @@ -21,6 +21,7 @@ NAMES +=3D hotblocks NAMES +=3D howvec NAMES +=3D hotpages NAMES +=3D lockstep +NAMES +=3D syscall =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 diff --git a/tests/plugin/syscall.c b/tests/plugin/syscall.c new file mode 100644 index 0000000000..53ee2ab6c4 --- /dev/null +++ b/tests/plugin/syscall.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020, Matthias Weckbecker + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +static void vcpu_syscall(qemu_plugin_id_t id, unsigned int vcpu_index, + int64_t num, uint64_t a1, uint64_t a2, + uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8) +{ + g_autofree gchar *out =3D g_strdup_printf("syscall #%" PRIi64 "\n", nu= m); + qemu_plugin_outs(out); +} + +static void vcpu_syscall_ret(qemu_plugin_id_t id, unsigned int vcpu_idx, + int64_t num, int64_t ret) +{ + g_autofree gchar *out; + out =3D g_strdup_printf("syscall #%" PRIi64 " returned -> %" PRIi64 "\= n", + num, ret); + qemu_plugin_outs(out); +} + +/* ***********************************************************************= ** */ + +static void plugin_exit(qemu_plugin_id_t id, void *p) {} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) +{ + qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall); + qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} --=20 2.23.0