refactor to allow multiple hooks for one type

This commit is contained in:
Ryan Hileman
2016-01-16 00:44:02 -08:00
parent 6f0a01293d
commit 93052f6566
20 changed files with 542 additions and 751 deletions

View File

@@ -10970,6 +10970,7 @@ static void disas_data_proc_simd_fp(DisasContext *s, uint32_t insn)
static void disas_a64_insn(CPUARMState *env, DisasContext *s)
{
uint32_t insn;
struct hook *hook;
TCGContext *tcg_ctx = env->uc->tcg_ctx;
// Unicorn: end address tells us to stop emulation
@@ -10984,10 +10985,10 @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s)
s->pc += 4;
// Unicorn: trace this instruction on request
if (env->uc->hook_insn) {
struct hook_struct *trace = hook_find(s->uc, UC_HOOK_CODE, s->pc - 4);
if (trace)
gen_uc_tracecode(tcg_ctx, 4, trace->callback, env->uc, s->pc - 4, trace->user_data);
HOOK_FOREACH(env->uc, hook, UC_HOOK_CODE) {
if (! HOOK_BOUND_CHECK(hook, s->pc - 4))
continue;
gen_uc_tracecode(tcg_ctx, 4, hook->callback, env->uc, s->pc - 4, hook->user_data);
// the callback might want to stop emulation immediately
check_exit_request(tcg_ctx);
}
@@ -11043,6 +11044,7 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu,
int max_insns;
TCGContext *tcg_ctx = env->uc->tcg_ctx;
bool block_full = false;
struct hook *hook;
pc_start = tb->pc;
@@ -11114,12 +11116,13 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu,
// Unicorn: trace this block on request
// Only hook this block if it is not broken from previous translation due to
// full translation cache
if (env->uc->hook_block && !env->uc->block_full) {
struct hook_struct *trace = hook_find(env->uc, UC_HOOK_BLOCK, pc_start);
if (trace) {
if (! env->uc->block_full) {
HOOK_FOREACH(env->uc, hook, UC_HOOK_BLOCK) {
if (! HOOK_BOUND_CHECK(hook, pc_start))
continue;
// save block address to see if we need to patch block size later
env->uc->block_addr = pc_start;
gen_uc_tracecode(tcg_ctx, 0xf8f8f8f8, trace->callback, env->uc, pc_start, trace->user_data);
gen_uc_tracecode(tcg_ctx, 0xf8f8f8f8, hook->callback, env->uc, pc_start, hook->user_data);
}
}