[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 42/54] translator: inject instrumentation from pl
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v4 42/54] translator: inject instrumentation from plugins |
Date: |
Wed, 31 Jul 2019 17:07:07 +0100 |
From: "Emilio G. Cota" <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
---
v4
- note we can't inject instrumentation if ! DISAS_NEXT
---
accel/tcg/translator.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 9226a348a39..4e30772f8cb 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -16,6 +16,7 @@
#include "exec/gen-icount.h"
#include "exec/log.h"
#include "exec/translator.h"
+#include "exec/plugin-gen.h"
/* Pairs with tcg_clear_temp_count.
To be called by #TranslatorOps.{translate_insn,tb_stop} if
@@ -34,6 +35,7 @@ void translator_loop(const TranslatorOps *ops,
DisasContextBase *db,
CPUState *cpu, TranslationBlock *tb, int max_insns)
{
int bp_insn = 0;
+ bool plugin_enabled;
/* Initialize DisasContext */
db->tb = tb;
@@ -55,11 +57,17 @@ void translator_loop(const TranslatorOps *ops,
DisasContextBase *db,
ops->tb_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
+ plugin_enabled = plugin_gen_tb_start(cpu, tb);
+
while (true) {
db->num_insns++;
ops->insn_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
+ if (plugin_enabled) {
+ plugin_gen_insn_start(cpu, db);
+ }
+
/* Pass breakpoint hits to target for further processing */
if (!db->singlestep_enabled
&& unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) {
@@ -100,6 +108,14 @@ void translator_loop(const TranslatorOps *ops,
DisasContextBase *db,
break;
}
+ /*
+ * We can't instrument after instructions that change control
+ * flow although this only really affects post-load operations.
+ */
+ if (plugin_enabled) {
+ plugin_gen_insn_end();
+ }
+
/* Stop translation if the output buffer is full,
or we have executed all of the allowed instructions. */
if (tcg_op_buf_full() || db->num_insns >= db->max_insns) {
@@ -112,6 +128,10 @@ void translator_loop(const TranslatorOps *ops,
DisasContextBase *db,
ops->tb_stop(db, cpu);
gen_tb_end(db->tb, db->num_insns - bp_insn);
+ if (plugin_enabled) {
+ plugin_gen_tb_end(cpu);
+ }
+
/* The disas_log hook may use these values rather than recompute. */
db->tb->size = db->pc_next - db->pc_first;
db->tb->icount = db->num_insns;
--
2.20.1
- [Qemu-devel] [PATCH v4 12/54] configure: add --enable-plugins (MOVE TO END), (continued)
- [Qemu-devel] [PATCH v4 12/54] configure: add --enable-plugins (MOVE TO END), Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 13/54] plugin: add user-facing API, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 09/54] cpu: introduce cpu_in_exclusive_context(), Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 11/54] docs/devel: add plugins.rst design document, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 29/54] plugin-gen: add plugin_insn_append, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 14/54] plugin: add core code, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 07/54] trace: add mmu_index to mem_info, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 45/54] linux-user: support -plugin option, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 53/54] include/exec: wrap cpu_ldst.h in CONFIG_TCG, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 33/54] target/sh4: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 42/54] translator: inject instrumentation from plugins,
Alex Bennée <=
- [Qemu-devel] [PATCH v4 19/54] tcg: add tcg_gen_st_ptr, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 54/54] include/exec/cpu-defs.h: fix typo, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 40/54] target/xtensa: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 31/54] target/arm: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 30/54] translator: add translator_ld{ub, sw, uw, l, q}, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 39/54] target/sparc: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 18/54] cputlb: introduce get_page_addr_code_hostp, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 41/54] target/openrisc: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 27/54] *-user: plugin syscalls, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 51/54] tests/plugin: add hotpages plugin to breakdown memory access patterns, Alex Bennée, 2019/07/31