From: Mahmoud Mandour <ma.mandourr@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Mahmoud Mandour" <ma.mandourr@gmail.com>,
cota@braap.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [RFC PATCH v3 1/4] plugins/api: expose symbol lookup to plugins
Date: Tue, 8 Jun 2021 06:05:29 +0200 [thread overview]
Message-ID: <20210608040532.56449-2-ma.mandourr@gmail.com> (raw)
In-Reply-To: <20210608040532.56449-1-ma.mandourr@gmail.com>
From: Alex Bennée <alex.bennee@linaro.org>
This is a quality of life helper for plugins so they don't need to
re-implement symbol lookup when dumping an address. The strings are
constant so don't need to be duplicated. One minor tweak is to return
NULL instead of a zero length string to show lookup failed.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210601145824.3849-1-alex.bennee@linaro.org>
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
---
include/qemu/qemu-plugin.h | 9 +++++++++
plugins/api.c | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index 97cdfd7761..dc3496f36c 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -525,6 +525,15 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id,
char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn);
+/**
+ * qemu_plugin_insn_symbol() - best effort symbol lookup
+ * @insn: instruction reference
+ *
+ * Return a static string referring to the symbol. This is dependent
+ * on the binary QEMU is running having provided a symbol table.
+ */
+const char *qemu_plugin_insn_symbol(const struct qemu_plugin_insn *insn);
+
/**
* qemu_plugin_vcpu_for_each() - iterate over the existing vCPU
* @id: plugin ID
diff --git a/plugins/api.c b/plugins/api.c
index 817c9b6b69..332e2c60e2 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -233,6 +233,12 @@ char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn)
return plugin_disas(cpu, insn->vaddr, insn->data->len);
}
+const char *qemu_plugin_insn_symbol(const struct qemu_plugin_insn *insn)
+{
+ const char *sym = lookup_symbol(insn->vaddr);
+ return sym[0] != 0 ? sym : NULL;
+}
+
/*
* The memory queries allow the plugin to query information about a
* memory access.
--
2.25.1
next prev parent reply other threads:[~2021-06-08 4:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 4:05 [RFC PATCH v3 0/4] Cache TCG plugin & symbol-resolution API Mahmoud Mandour
2021-06-08 4:05 ` Mahmoud Mandour [this message]
2021-06-08 4:05 ` [RFC PATCH v3 2/4] plugins: Added a new cache modelling plugin Mahmoud Mandour
2021-06-08 4:05 ` [RFC PATCH v3 3/4] plugins/cache: Enabled cache parameterization Mahmoud Mandour
2021-06-22 14:37 ` Alex Bennée
2021-06-08 4:05 ` [RFC PATCH v3 4/4] plugins/cache: Added FIFO and LRU eviction policies Mahmoud Mandour
2021-06-22 14:57 ` Alex Bennée
2021-06-22 14:57 ` [RFC PATCH v3 0/4] Cache TCG plugin & symbol-resolution API Alex Bennée
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=20210608040532.56449-2-ma.mandourr@gmail.com \
--to=ma.mandourr@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=cota@braap.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).