From nobody Mon Nov 25 01:34:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719443650; cv=none; d=zohomail.com; s=zohoarc; b=WYsPcbqWCLj4CNh+DpBgsi4PHfokvRXbaP2D5FCEMWgAxmFFVHXsDWcgtQqCG5uecQfHVTE5xDODkTwLkLEDaFyyFtLw9CIVeVYpWkKPc0q2Zza98zw8x2eAd9iE9osdHiXMPAR5FmPg39VNN3CwaMW7O9l7xPoVImz0oxUO1Xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719443650; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; b=Nvr3tDM6tLPGhD5u/fMMEa38sIYYorbhmhmDGxAsPkfClDDWBieY2jDNwgBe5lPiY0/Y2Io3Uh5zGXR3cvQD0PrShxUKMtoeTHTwNQ5g5NPdkP3gbfEesGAnd0ugmICg8UKp4d3rt7TaW2K1f9FEGEMjXiFDX5IfLmOGYi+vEzs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171944365019492.53014209887726; Wed, 26 Jun 2024 16:14:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbpF-0003Bn-Fy; Wed, 26 Jun 2024 19:13:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMbp9-00039S-DF for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:12 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMbp6-0000PB-KQ for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:10 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1f9fb3ca81bso34335585ad.3 for ; Wed, 26 Jun 2024 16:13:08 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443587; x=1720048387; darn=nongnu.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=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; b=btot52pcmJkIttEQiOHpjsvXZgZeLdvJvW/PGfbaalpnfVuvtuTZA1OdQim7tqqkUw d4b3hIRenCs5HhHoBA+GpGqiMP9hcjiMaGJJKGiJPHn0qmfjHgZxCukceOUXw1DulIvJ dDJr983aIQ/71n81+rhsnvK36o0zJK/fuWvMcDiF56dqYw7EesVHYu8bqJdKaM/fKLWR Osqke8HzkzjV7W8eCEOyHR3ZQ+Fqwz8EHX1rYXg6phxwhmZWzpsS+1CUvdNx+/f9pBrb YicZXq8chXivr7Sro4c62+7cErznxjMjaxvibqEC01A4DFllo8uuBzBVfITNigaquIu6 QtOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443587; x=1720048387; 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=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; b=vQOZoynIBmeh8xf1+wJHQpAafPBUClMf0XiQTK5K5HISs6SynYaQw4OLcQk7BI5qPd 78r38LmG9y4xlOH6D/gNPeVk5RprSuAlbuCo4N1avM9fWHKdfWlm79qY/F0jl98+H4pA 2JX0qH7e9aWY7O75WQYNCBS9q+ZeSvoPcC65Lmk5qpddulAu/wgetm15GuHvFXgNhfCL kz0kvSWAF55v9K3vAgwe8bpCzPDXrcGYsKNiTaku6vkUfwDGcd+RuCEFdTn/aW2PdGW/ cLM0rOgCNki817Bw993EknuMcSS5vd24F4Jq/G1+gdnTrfUWfP7hYJUIv3nO6xqGNzL+ RIZg== X-Gm-Message-State: AOJu0Yx+FwUxwCVKu6tmhvPM02369/pWqo18Oe9yurVEwRP/ZNVOEr0W R0RDpG67pUkNZci0RdKIiiueI4hydXiK4BckSZcCQ2AZbPryaSgDsfubJBsKd3tHbwD653YPXcN AU8I= X-Google-Smtp-Source: AGHT+IFCLvtHvjMgdin6zv+Hb78vkOnv5sHZA9BT9Gy89rsFpNABdH6N2zbRh3MiP6b9Zpl1SWFZFQ== X-Received: by 2002:a17:902:f54c:b0:1f6:225e:67a1 with SMTP id d9443c01a7336-1fa2413cddemr139393005ad.56.1719443586759; Wed, 26 Jun 2024 16:13:06 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 6/7] tests/plugin/mem: add option to print memory accesses Date: Wed, 26 Jun 2024 16:12:54 -0700 Message-Id: <20240626231255.339353-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::632; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719443651282100001 Content-Type: text/plain; charset="utf-8" By using "print-accesses=3Dtrue" option, mem plugin will now print every value accessed, with associated size, type (store vs load) and symbol where this happens. Signed-off-by: Pierrick Bouvier --- tests/plugin/mem.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index b650dddcce1..d897034a044 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -24,7 +24,7 @@ typedef struct { static struct qemu_plugin_scoreboard *counts; static qemu_plugin_u64 mem_count; static qemu_plugin_u64 io_count; -static bool do_inline, do_callback; +static bool do_inline, do_callback, do_print_accesses; static bool do_haddr; static enum qemu_plugin_mem_rw rw =3D QEMU_PLUGIN_MEM_RW; =20 @@ -60,6 +60,20 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin= _meminfo_t meminfo, } } =20 +static void print_access(unsigned int cpu_index, qemu_plugin_meminfo_t mem= info, + uint64_t vaddr, void *udata) +{ + unsigned size =3D 8 << qemu_plugin_mem_size_shift(meminfo); + const char *type =3D qemu_plugin_mem_is_store(meminfo) ? "store" : "lo= ad"; + uint64_t upper =3D qemu_plugin_mem_get_value_upper_bits(meminfo); + uint64_t lower =3D qemu_plugin_mem_get_value_lower_bits(meminfo); + const char *sym =3D udata ? udata : ""; + g_autoptr(GString) out =3D g_string_new(""); + g_string_printf(out, "access: 0x%.0"PRIx64"%"PRIx64",%d,%s,%s\n", + upper, lower, size, type, sym); + qemu_plugin_outs(out->str); +} + static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { size_t n =3D qemu_plugin_tb_n_insns(tb); @@ -79,6 +93,12 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qe= mu_plugin_tb *tb) QEMU_PLUGIN_CB_NO_REGS, rw, NULL); } + if (do_print_accesses) { + const char *sym =3D qemu_plugin_insn_symbol(insn); + qemu_plugin_register_vcpu_mem_cb(insn, print_access, + QEMU_PLUGIN_CB_NO_REGS, + rw, (void *) sym); + } } } =20 @@ -117,6 +137,12 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); return -1; } + } else if (g_strcmp0(tokens[0], "print-accesses") =3D=3D 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &do_print_accesses)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); + return -1; + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; --=20 2.39.2