Message ID | 20190614171200.21078-38-alex.bennee@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | tcg plugin support | expand |
On 6/14/19 10:11 AM, Alex Bennée wrote: > @@ -95,6 +103,10 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, > ops->translate_insn(db, cpu); > } > > + if (plugin_enabled) { > + plugin_gen_insn_end(); > + } > + > /* Stop translation if translate_insn so indicated. */ > if (db->is_jmp != DISAS_NEXT) { This will of course not be reachable if db->is_jmp == DISAS_NORETURN. Do we want to not bother calling the plugin for this case? r~
Richard Henderson <richard.henderson@linaro.org> writes: > On 6/14/19 10:11 AM, Alex Bennée wrote: >> @@ -95,6 +103,10 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, >> ops->translate_insn(db, cpu); >> } >> >> + if (plugin_enabled) { >> + plugin_gen_insn_end(); >> + } >> + >> /* Stop translation if translate_insn so indicated. */ >> if (db->is_jmp != DISAS_NEXT) { > > This will of course not be reachable if db->is_jmp == DISAS_NORETURN. > Do we want to not bother calling the plugin for this case? Hmm good point. Are you just suggesting: if (plugin_enabled && db->is_jmp != DISAS_NORETURN) to be explicit? > > > r~ -- Alex Bennée
Richard Henderson <richard.henderson@linaro.org> writes: > On 6/14/19 10:11 AM, Alex Bennée wrote: >> @@ -95,6 +103,10 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, >> ops->translate_insn(db, cpu); >> } >> >> + if (plugin_enabled) { >> + plugin_gen_insn_end(); >> + } >> + >> /* Stop translation if translate_insn so indicated. */ >> if (db->is_jmp != DISAS_NEXT) { > > This will of course not be reachable if db->is_jmp == DISAS_NORETURN. > Do we want to not bother calling the plugin for this case? Swap the order and add a comment? -- Alex Bennée
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 9226a348a3..161b494a54 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))) { @@ -95,6 +103,10 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, ops->translate_insn(db, cpu); } + if (plugin_enabled) { + plugin_gen_insn_end(); + } + /* Stop translation if translate_insn so indicated. */ if (db->is_jmp != DISAS_NEXT) { break; @@ -112,6 +124,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;