From: "Alex Bennée" <alex.bennee@linaro.org>
To: Luke Craig <lacraig3@gmail.com>
Cc: qemu-devel@nongnu.org, Alexandre Iooss <erdnaxe@crans.org>,
Mahmoud Mandour <ma.mandourr@gmail.com>,
Pierrick Bouvier <pierrick.bouvier@linaro.org>
Subject: Re: [PATCH 1/2] plugin: extend API with qemu_plugin_tb_get_insn_by_vaddr
Date: Tue, 28 Jan 2025 09:07:04 +0000 [thread overview]
Message-ID: <87jzaf2ton.fsf@draig.linaro.org> (raw)
In-Reply-To: <20250127201734.1769540-2-lacraig3@gmail.com> (Luke Craig's message of "Mon, 27 Jan 2025 15:17:33 -0500")
Luke Craig <lacraig3@gmail.com> writes:
> ---
> 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);
>
> +/**
> + * qemu_plugin_tb_get_insn_by_vaddr() - lookup handle for instruction by vaddr
> + * @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..7ff5e1c1bd 100644
> --- a/plugins/api.c
> +++ b/plugins/api.c
> @@ -258,6 +258,19 @@ qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx)
> return insn;
> }
>
> +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 = 0; i < tb->n; i++){
> + insn = g_ptr_array_index(tb->insns, idx);
> + if (insn != NULL && insn->vaddr == vaddr){
> + return insn;
> + }
> + }
> + return NULL;
> +}
> +
I don't have any fundamental objection to this. I would prefer it if the
new helper was used by either one of the test or contrib plugins to
ensure we don't bitrot it.
> /*
> * Instruction information
> *
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2025-01-28 9:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 20:17 [PATCH 0/2] plugins: add tb convenience functions Luke Craig
2025-01-27 20:17 ` [PATCH 1/2] plugin: extend API with qemu_plugin_tb_get_insn_by_vaddr Luke Craig
2025-01-28 9:07 ` Alex Bennée [this message]
2025-01-27 20:17 ` [PATCH 2/2] plugin: extend API with qemu_plugin_tb_size Luke Craig
2025-01-28 9:17 ` Alex Bennée
2025-01-28 18:32 ` Pierrick Bouvier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jzaf2ton.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=lacraig3@gmail.com \
--cc=ma.mandourr@gmail.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.