summary refs log tree commit diff stats
path: root/accel
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-04-03 09:20:06 -1000
committerRichard Henderson <richard.henderson@linaro.org>2024-05-15 08:55:18 +0200
commit36bc99bc789fd564facea93feb2a22e4942b84d0 (patch)
tree06c80475b1c2a88198d9e546ccb37b000e32ac7c /accel
parent3a247368e6fc12304e73451c63254313e2ebd60e (diff)
downloadfocaccia-qemu-36bc99bc789fd564facea93feb2a22e4942b84d0.tar.gz
focaccia-qemu-36bc99bc789fd564facea93feb2a22e4942b84d0.zip
plugins: Use translator_st for qemu_plugin_insn_data
Use the bytes that we record for the entire TB, rather than
a per-insn GByteArray.  Record the length of the insn in
plugin_gen_insn_end rather than infering from the length
of the array.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'accel')
-rw-r--r--accel/tcg/plugin-gen.c7
-rw-r--r--accel/tcg/translator.c26
2 files changed, 5 insertions, 28 deletions
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index 842da97204..716c8ec753 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -346,11 +346,9 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db)
     ptb->n = n;
     if (n <= ptb->insns->len) {
         insn = g_ptr_array_index(ptb->insns, n - 1);
-        g_byte_array_set_size(insn->data, 0);
     } else {
         assert(n - 1 == ptb->insns->len);
         insn = g_new0(struct qemu_plugin_insn, 1);
-        insn->data = g_byte_array_sized_new(4);
         g_ptr_array_add(ptb->insns, insn);
     }
 
@@ -389,6 +387,11 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db)
 
 void plugin_gen_insn_end(void)
 {
+    const DisasContextBase *db = tcg_ctx->plugin_db;
+    struct qemu_plugin_insn *pinsn = tcg_ctx->plugin_insn;
+
+    pinsn->len = db->fake_insn ? db->record_len : db->pc_next - pinsn->vaddr;
+
     tcg_gen_plugin_cb(PLUGIN_GEN_AFTER_INSN);
 }
 
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 01e1f0977b..986045154c 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -409,27 +409,6 @@ bool translator_st(const DisasContextBase *db, void *dest,
     return false;
 }
 
-static void plugin_insn_append(vaddr pc, const void *from, size_t size)
-{
-#ifdef CONFIG_PLUGIN
-    struct qemu_plugin_insn *insn = tcg_ctx->plugin_insn;
-    size_t off;
-
-    if (insn == NULL) {
-        return;
-    }
-    off = pc - insn->vaddr;
-    if (off < insn->data->len) {
-        g_byte_array_set_size(insn->data, off);
-    } else if (off > insn->data->len) {
-        /* we have an unexpected gap */
-        g_assert_not_reached();
-    }
-
-    insn->data = g_byte_array_append(insn->data, from, size);
-#endif
-}
-
 uint8_t translator_ldub(CPUArchState *env, DisasContextBase *db, vaddr pc)
 {
     uint8_t raw;
@@ -438,7 +417,6 @@ uint8_t translator_ldub(CPUArchState *env, DisasContextBase *db, vaddr pc)
         raw = cpu_ldub_code(env, pc);
         record_save(db, pc, &raw, sizeof(raw));
     }
-    plugin_insn_append(pc, &raw, sizeof(raw));
     return raw;
 }
 
@@ -453,7 +431,6 @@ uint16_t translator_lduw(CPUArchState *env, DisasContextBase *db, vaddr pc)
         raw = tswap16(tgt);
         record_save(db, pc, &raw, sizeof(raw));
     }
-    plugin_insn_append(pc, &raw, sizeof(raw));
     return tgt;
 }
 
@@ -468,7 +445,6 @@ uint32_t translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
         raw = tswap32(tgt);
         record_save(db, pc, &raw, sizeof(raw));
     }
-    plugin_insn_append(pc, &raw, sizeof(raw));
     return tgt;
 }
 
@@ -483,7 +459,6 @@ uint64_t translator_ldq(CPUArchState *env, DisasContextBase *db, vaddr pc)
         raw = tswap64(tgt);
         record_save(db, pc, &raw, sizeof(raw));
     }
-    plugin_insn_append(pc, &raw, sizeof(raw));
     return tgt;
 }
 
@@ -492,5 +467,4 @@ void translator_fake_ldb(DisasContextBase *db, vaddr pc, uint8_t insn8)
     assert(pc >= db->pc_first);
     db->fake_insn = true;
     record_save(db, pc, &insn8, sizeof(insn8));
-    plugin_insn_append(pc, &insn8, sizeof(insn8));
 }