[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 20/38] plugin-gen: add plugin_insn_append
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [RFC v2 20/38] plugin-gen: add plugin_insn_append |
Date: |
Sun, 9 Dec 2018 14:37:31 -0500 |
By adding it to plugin-gen's header file, we can export is as
an inline, since tcg.h is included in the header (we need tcg_ctx).
Signed-off-by: Emilio G. Cota <address@hidden>
---
include/exec/plugin-gen.h | 27 ++++++++++++++++++---------
accel/tcg/plugin-gen.c | 10 +++++++++-
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h
index 449ea16034..b09c16b720 100644
--- a/include/exec/plugin-gen.h
+++ b/include/exec/plugin-gen.h
@@ -15,15 +15,6 @@
#include "qemu/plugin.h"
#include "tcg/tcg.h"
-/* used by plugin_callback_start and plugin_callback_end TCG ops */
-enum plugin_gen_from {
- PLUGIN_GEN_FROM_TB,
- PLUGIN_GEN_FROM_INSN,
- PLUGIN_GEN_FROM_MEM,
- PLUGIN_GEN_AFTER_INSN,
- PLUGIN_GEN_N_FROMS,
-};
-
struct DisasContextBase;
#ifdef CONFIG_PLUGIN
@@ -36,6 +27,21 @@ void plugin_gen_insn_end(void);
void plugin_gen_disable_mem_helpers(void);
void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info);
+static inline void plugin_insn_append(const void *from, size_t size)
+{
+ struct qemu_plugin_insn *insn = tcg_ctx->plugin_insn;
+
+ if (insn == NULL) {
+ return;
+ }
+ if (unlikely(insn->size + size > insn->capacity)) {
+ insn->data = g_realloc(insn->data, insn->size + size);
+ insn->capacity = insn->size + size;
+ }
+ memcpy(insn->data + insn->size, from, size);
+ insn->size += size;
+}
+
#else /* !CONFIG_PLUGIN */
static inline
@@ -60,6 +66,9 @@ static inline void plugin_gen_disable_mem_helpers(void)
static inline void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info)
{ }
+static inline void plugin_insn_append(const void *from, size_t size)
+{ }
+
#endif /* CONFIG_PLUGIN */
#endif /* QEMU_PLUGIN_GEN_H */
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index 06ec23e9f5..e6dd79e4d8 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -60,9 +60,17 @@
/*
* plugin_cb_start TCG op args[]:
* 0: enum plugin_gen_from
- * 1: enum plugin_gen_cb (defined below)
+ * 1: enum plugin_gen_cb
* 2: set to 1 if it's a mem callback and it's a write, 0 otherwise.
*/
+enum plugin_gen_from {
+ PLUGIN_GEN_FROM_TB,
+ PLUGIN_GEN_FROM_INSN,
+ PLUGIN_GEN_FROM_MEM,
+ PLUGIN_GEN_AFTER_INSN,
+ PLUGIN_GEN_N_FROMS,
+};
+
enum plugin_gen_cb {
PLUGIN_GEN_CB_UDATA,
PLUGIN_GEN_CB_INLINE,
--
2.17.1
- [Qemu-devel] [RFC v2 21/38] translator: add translator_ld{ub, sw, uw, l, q}, (continued)
- [Qemu-devel] [RFC v2 21/38] translator: add translator_ld{ub, sw, uw, l, q}, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 10/38] plugin-gen: add module for TCG-related code, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 25/38] target/i386: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 38/38] tests/plugin: add sample plugins, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 37/38] linux-user: support -plugin option, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 27/38] target/m68k: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 29/38] target/riscv: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 22/38] target/arm: call qemu_plugin_insn_append, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 08/38] tcg: drop nargs from tcg_op_insert_{before, after}, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 19/38] cpu: hook plugin vcpu events, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 20/38] plugin-gen: add plugin_insn_append,
Emilio G. Cota <=
- [Qemu-devel] [RFC v2 35/38] configure: add --enable-plugins, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 28/38] target/alpha: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 26/38] target/hppa: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 36/38] vl: support -plugin option, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 34/38] plugin: add API symbols to qemu-plugins.symbols, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 30/38] target/sparc: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 31/38] target/xtensa: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 33/38] translator: inject instrumentation from plugins, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 32/38] target/openrisc: fetch code with translator_ld, Emilio G. Cota, 2018/12/09