[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 7/8] plugins/api: expose symbol lookup to plugins
From: |
Alex Bennée |
Subject: |
[PATCH v1 7/8] plugins/api: expose symbol lookup to plugins |
Date: |
Wed, 23 Jun 2021 11:27:48 +0100 |
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>
Message-Id: <20210608040532.56449-2-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.20.1
- [PATCH v1 0/8] misc fixes pre-PR (docs, plugins, tests), Alex Bennée, 2021/06/23
- [PATCH v1 1/8] tests/acceptance: tweak the tcg/kvm tests for virt, Alex Bennée, 2021/06/23
- [PATCH v1 2/8] docs/devel: Add a single top-level header to MTTCG's doc, Alex Bennée, 2021/06/23
- [PATCH v1 6/8] tests/tcg: skip the signals test for hppa/s390x for now, Alex Bennée, 2021/06/23
- [PATCH v1 3/8] scripts/checkpatch: roll diff tweaking into checkpatch itself, Alex Bennée, 2021/06/23
- [PATCH v1 5/8] GitLab: Add "Feature Request" issue template., Alex Bennée, 2021/06/23
- [PATCH v1 4/8] GitLab: Add "Bug" issue reporting template, Alex Bennée, 2021/06/23
- [PATCH v1 8/8] Update documentation to refer to new location for issues, Alex Bennée, 2021/06/23
- [PATCH v1 7/8] plugins/api: expose symbol lookup to plugins,
Alex Bennée <=