[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 51/73] translator: inject instrumentation from plugins
From: |
Alex Bennée |
Subject: |
[PULL v2 51/73] translator: inject instrumentation from plugins |
Date: |
Fri, 25 Oct 2019 07:36:51 +0100 |
From: "Emilio G. Cota" <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 70c66c538cf..f977682be79 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))) {
@@ -99,6 +107,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) {
@@ -111,6 +127,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
- [PULL v2 70/73] .travis.yml: add --enable-plugins tests, (continued)
- [PULL v2 70/73] .travis.yml: add --enable-plugins tests, Alex Bennée, 2019/10/25
- [PULL v2 63/73] tests/tcg: drop test-i386-fprem from TESTS when not SLOW, Alex Bennée, 2019/10/25
- [PULL v2 31/73] tcg: let plugins instrument virtual memory accesses, Alex Bennée, 2019/10/25
- [PULL v2 43/73] target/i386: fetch code with translator_ld, Alex Bennée, 2019/10/25
- [PULL v2 42/73] target/sh4: fetch code with translator_ld, Alex Bennée, 2019/10/25
- [PULL v2 44/73] target/hppa: fetch code with translator_ld, Alex Bennée, 2019/10/25
- [PULL v2 64/73] tests/tcg: enable plugin testing, Alex Bennée, 2019/10/25
- [PULL v2 14/73] travis.yml: --enable-debug-tcg to check-tcg, Alex Bennée, 2019/10/25
- [PULL v2 33/73] translate-all: notify plugin code of tb_flush, Alex Bennée, 2019/10/25
- [PULL v2 66/73] tests/plugin: add instruction execution breakdown, Alex Bennée, 2019/10/25
- [PULL v2 51/73] translator: inject instrumentation from plugins,
Alex Bennée <=
- [PULL v2 61/73] tests/tcg: set QEMU_OPTS for all cris runs, Alex Bennée, 2019/10/25
- [PULL v2 39/73] translator: add translator_ld{ub,sw,uw,l,q}, Alex Bennée, 2019/10/25
- [PULL v2 68/73] accel/stubs: reduce headers from tcg-stub, Alex Bennée, 2019/10/25
- [PULL v2 47/73] target/riscv: fetch code with translator_ld, Alex Bennée, 2019/10/25
- [PULL v2 16/73] tests/docker: update Travis image to a more current version, Alex Bennée, 2019/10/25
- [PULL v2 26/73] cputlb: document get_page_addr_code, Alex Bennée, 2019/10/25
- [PULL v2 23/73] plugin: add core code, Alex Bennée, 2019/10/25
- [PULL v2 73/73] travis.yml: enable linux-gcc-debug-tcg cache, Alex Bennée, 2019/10/25
- [PULL v2 29/73] plugin-gen: add module for TCG-related code, Alex Bennée, 2019/10/25
- Re: [PULL v2 00/73] tcg plugins and testing updates, Markus Armbruster, 2019/10/25