aboutsummaryrefslogtreecommitdiff
path: root/include/qemu
diff options
context:
space:
mode:
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/plugin.h35
1 files changed, 11 insertions, 24 deletions
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index 0d00624..b679a22 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -67,15 +67,8 @@ union qemu_plugin_cb_sig {
};
enum plugin_dyn_cb_type {
- PLUGIN_CB_INSN,
- PLUGIN_CB_MEM,
- PLUGIN_N_CB_TYPES,
-};
-
-enum plugin_dyn_cb_subtype {
PLUGIN_CB_REGULAR,
PLUGIN_CB_INLINE,
- PLUGIN_N_CB_SUBTYPES,
};
/*
@@ -85,7 +78,7 @@ enum plugin_dyn_cb_subtype {
*/
struct qemu_plugin_dyn_cb {
void *userp;
- enum plugin_dyn_cb_subtype type;
+ enum plugin_dyn_cb_type type;
/* @rw applies to mem callbacks only (both regular and inline) */
enum qemu_plugin_mem_rw rw;
/* fields specific to each dyn_cb type go here */
@@ -107,7 +100,8 @@ struct qemu_plugin_insn {
GByteArray *data;
uint64_t vaddr;
void *haddr;
- GArray *cbs[PLUGIN_N_CB_TYPES][PLUGIN_N_CB_SUBTYPES];
+ GArray *insn_cbs;
+ GArray *mem_cbs;
bool calls_helpers;
/* if set, the instruction calls helpers that might access guest memory */
@@ -136,16 +130,9 @@ static inline void qemu_plugin_insn_cleanup_fn(gpointer data)
static inline struct qemu_plugin_insn *qemu_plugin_insn_alloc(void)
{
- int i, j;
struct qemu_plugin_insn *insn = g_new0(struct qemu_plugin_insn, 1);
- insn->data = g_byte_array_sized_new(4);
- for (i = 0; i < PLUGIN_N_CB_TYPES; i++) {
- for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) {
- insn->cbs[i][j] = g_array_new(false, false,
- sizeof(struct qemu_plugin_dyn_cb));
- }
- }
+ insn->data = g_byte_array_sized_new(4);
return insn;
}
@@ -162,7 +149,7 @@ struct qemu_plugin_tb {
/* if set, the TB calls helpers that might access guest memory */
bool mem_helper;
- GArray *cbs[PLUGIN_N_CB_SUBTYPES];
+ GArray *cbs;
};
/**
@@ -175,22 +162,22 @@ struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb,
uint64_t pc)
{
struct qemu_plugin_insn *insn;
- int i, j;
if (unlikely(tb->n == tb->insns->len)) {
struct qemu_plugin_insn *new_insn = qemu_plugin_insn_alloc();
g_ptr_array_add(tb->insns, new_insn);
}
+
insn = g_ptr_array_index(tb->insns, tb->n++);
g_byte_array_set_size(insn->data, 0);
insn->calls_helpers = false;
insn->mem_helper = false;
insn->vaddr = pc;
-
- for (i = 0; i < PLUGIN_N_CB_TYPES; i++) {
- for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) {
- g_array_set_size(insn->cbs[i][j], 0);
- }
+ if (insn->insn_cbs) {
+ g_array_set_size(insn->insn_cbs, 0);
+ }
+ if (insn->mem_cbs) {
+ g_array_set_size(insn->mem_cbs, 0);
}
return insn;