From nobody Sun Nov 16 19:36:38 2025 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1738346327; cv=none; d=zohomail.com; s=zohoarc; b=NI9pjLrYL4yK4VWG39j8gTjKccD3QtJcvrCI2Y4BTMOoNK4UdwYk90tiHUuRFafNq7Bcs6nO84j3wvix2InAaFhZPuspJx1c/IGk2ceGF98TfuXHKM4Eh4HQ5h3TTnIO+n0w1sjYixaIksqC2MUmp3BtdGgYZcMKy4LCB8TBr5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738346327; 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=e6uGwaniCL5bYZNfnfF6MzaJzg1nlQBZKTNndfBAHl8=; b=nKbpJ2h1nVzwq+esmbuiRvuH/wmc2V/hCW9XVSPDvfc0lEhaOXJFYrtOe9Wxs7X25hgHuO7d0AC9XDIWD2DtwtH206EKJa+5rTxPKF5eVqhboGXbvJwIY9DtffPKK1irr8eeNDeCzhj0N5FgpnABVgrDs7DaxcDR0Cf3CZF91BQ= 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 1738346327989438.1948169562505; Fri, 31 Jan 2025 09:58:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdvGg-0000NK-B5; Fri, 31 Jan 2025 12:57:26 -0500 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 1tdvGe-0000Mc-I0 for qemu-devel@nongnu.org; Fri, 31 Jan 2025 12:57:24 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tdvGd-0004T8-1S for qemu-devel@nongnu.org; Fri, 31 Jan 2025 12:57:24 -0500 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5d982de9547so4280324a12.2 for ; Fri, 31 Jan 2025 09:57:22 -0800 (PST) Received: from luke-igloo.. ([18.4.85.124]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dc723efc45sm3110074a12.32.2025.01.31.09.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 09:57:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738346241; x=1738951041; 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=e6uGwaniCL5bYZNfnfF6MzaJzg1nlQBZKTNndfBAHl8=; b=AjXqOtUoEUwOa2qUYa4uNs5kkoKbvXbdTLasQkvZMQYsyzYxG0pXvLKvDYC8bVznVn 2JoQ+ppDG0vfyWIt4U975+hs9NDEzJ9UlP6m9dURXHt8TDy+y1okiBlrp3XHhVSy+GKr //MKaGhraHFJU0pQEt4YXDwWZE8pgQcb3+32oZcNg0FxUnX5yBevX53Q+qVpaKjvHIGc 01KkGDs7yJclI41GupKGz8Y0+nNx03JOMEmE7c+bs7wCZGX+vJB1bm5RgUUTvN7zMaxV xDmIIS1iUIvTtl7Dsjp92R3Cnjo+ITVBAulDUrZSc4quKofzqrINCbeth6VG/iV8xlVd 0MZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738346241; x=1738951041; 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=e6uGwaniCL5bYZNfnfF6MzaJzg1nlQBZKTNndfBAHl8=; b=X9unB6jo1VE+OA8pqtNIIZpa0WF+Kj8VyO1vWpPnNQsgOSoJ/YgMKHtd0uFkOtPoQm g49+MFdJxbGtOCfp75kJFfc8vT5gN6Jt4+iLWykDcYOZ2wMVmEc0GTtuwOxLneYz7lUp VsGFu/DCL0ojpvVMTu2N8lPGX8qRze+3peLRyWX2o0HB2ejojvL4bGMHC+CeSDugOlt3 gJOnlAfK5ms/Iy6Hw28SklC0zbYWBE0SdyyjC9RYZMuY5NGHrOum9hVO7yRNSEFLan5x hrdOWgaT+4aSKyr8azM/Q00r+gSfsQFu0LiarvzmlSUrq4b+j4IaWS9hF4GuAICE1na0 JxiA== X-Gm-Message-State: AOJu0YwneN6EqJnkijsdjJJYCRAU2ELNk+OJ6e6iO5PVn1df7mqwL+TV 52mMMqGGH/hEausd2JpPsQ5sHNevT74+CPlgqAHvSloQOFcIixBnz5bRoA== X-Gm-Gg: ASbGncuTt2vNqgkJI3deX2RJmSvd3B1iSzk+5DBi3Jg3QUq1/jXtQ//NQdK0InFzj9q qNEX0oP0eB68p7BaOWi6T4epfFO8a3vDlkhh5Vik36I25Y2BDGE3AmMrp2Q7OVKWjVfc2KGQ+zx 3zEzMFIWpNEtpjQidzw4G0QTqa+8xT8+Fu5s6UyVxIs6H4PfYOSO6SSuVP51xwNz/WXe19opZAp Mi3mvRFLdLm81g3cgGfPBPniaS+eq3pdbNhbPpU9AXQYTB2u93TWMDeSz4HHlo1ZJeE34tmsj1a ba0tRONjWU0= X-Google-Smtp-Source: AGHT+IHO/8dm5p3YxVE448p2NyRGp5QWIyuIEy4/zVsFXahTfu/cQnwxiwMd8Gl4oJwd6JC71aumww== X-Received: by 2002:a05:6402:518f:b0:5dc:32eb:f289 with SMTP id 4fb4d7f45d1cf-5dc5f01e810mr11304728a12.22.1738346240858; Fri, 31 Jan 2025 09:57:20 -0800 (PST) From: Luke Craig To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Alexandre Iooss , Mahmoud Mandour , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Luke Craig Subject: [PATCH v2 1/3] plugin: extend API with qemu_plugin_tb_get_insn_by_vaddr Date: Fri, 31 Jan 2025 12:57:14 -0500 Message-Id: <20250131175716.3218600-2-lacraig3@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250131175716.3218600-1-lacraig3@gmail.com> References: <20250131175716.3218600-1-lacraig3@gmail.com> 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=2a00:1450:4864:20::52b; envelope-from=lacraig3@gmail.com; helo=mail-ed1-x52b.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.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 @gmail.com) X-ZM-MESSAGEID: 1738346331607019000 Content-Type: text/plain; charset="utf-8" --- include/qemu/qemu-plugin.h | 11 +++++++++++ plugins/api.c | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 3a850aa216..a1c478c54f 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -500,6 +500,17 @@ QEMU_PLUGIN_API struct qemu_plugin_insn * qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx); =20 +/** + * qemu_plugin_tb_get_insn_by_vaddr() - lookup handle for instruction by v= addr + * @tb: opaque handle to TB passed to callback + * @vaddr: virtual address of instruction + * + * Returns: opaque handle to instruction + */ +QEMU_PLUGIN_API +struct qemu_plugin_insn * +qemu_plugin_tb_get_insn_by_vaddr(const struct qemu_plugin_tb *tb, uint64_t= vaddr); + /** * qemu_plugin_insn_data() - copy instruction data * @insn: opaque instruction handle from qemu_plugin_tb_get_insn() diff --git a/plugins/api.c b/plugins/api.c index 4110cfaa23..a6bd912c56 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -258,6 +258,19 @@ qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *t= b, size_t idx) return insn; } =20 +struct qemu_plugin_insn * +qemu_plugin_tb_get_insn_by_vaddr(const struct qemu_plugin_tb *tb, uint64_t= vaddr) +{ + struct qemu_plugin_insn *insn; + for (size_t i =3D 0; i < tb->n; i++){ + insn =3D g_ptr_array_index(tb->insns, i); + if (insn !=3D NULL && insn->vaddr =3D=3D vaddr){ + return insn; + } + } + return NULL; +} + /* * Instruction information * --=20 2.34.1