Fix UC_HOOK_EDGE_GENERATED implementation

This commit is contained in:
lazymio 2021-11-11 22:15:15 +01:00
parent fafec703e1
commit 7e244f87b4
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873

View File

@ -257,6 +257,22 @@ static inline TranslationBlock *tb_find(CPUState *cpu,
mmap_unlock();
/* We add the TB in the virtual pc hash table for the fast lookup */
cpu->tb_jmp_cache[tb_jmp_cache_hash_func(cpu->uc, pc)] = tb;
UC_TB_COPY(&cur_tb, tb);
if (last_tb) {
UC_TB_COPY(&prev_tb, last_tb);
for (cur = uc->hook[UC_HOOK_EDGE_GENERATED_IDX].head;
cur != NULL && (hook = (struct hook *)cur->data); cur = cur->next) {
if (hook->to_delete) {
continue;
}
if (HOOK_BOUND_CHECK(hook, (uint64_t)tb->pc)) {
((uc_hook_edge_gen_t)hook->callback)(uc, &cur_tb, &prev_tb, hook->user_data);
}
}
}
}
/* We don't take care of direct jumps when address mapping changes in
* system emulation. So it's not safe to make a direct jump to a TB
@ -270,22 +286,6 @@ static inline TranslationBlock *tb_find(CPUState *cpu,
tb_add_jump(last_tb, tb_exit, tb);
}
UC_TB_COPY(&cur_tb, tb);
if (last_tb) {
UC_TB_COPY(&prev_tb, last_tb);
for (cur = uc->hook[UC_HOOK_EDGE_GENERATED_IDX].head;
cur != NULL && (hook = (struct hook *)cur->data); cur = cur->next) {
if (hook->to_delete) {
continue;
}
if (HOOK_BOUND_CHECK(hook, (uint64_t)tb->pc)) {
((uc_hook_edge_gen_t)hook->callback)(uc, &cur_tb, &prev_tb, hook->user_data);
}
}
}
return tb;
}