From 39d38568717220e629e404b6f5f3b856d87e04a7 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 25 Aug 2015 16:10:05 +0800 Subject: [PATCH] when block size is unknown because the translation cache is full, assign it value 0 --- include/unicorn/unicorn.h | 2 +- qemu/translate-all.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 161e7613..a3293920 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -121,7 +121,7 @@ typedef enum uc_err { // Callback function for tracing code (UC_HOOK_CODE & UC_HOOK_BLOCK) // @address: address where the code is being executed -// @size: size of machine instruction being executed +// @size: size of machine instruction(s) being executed, or 0 when size is unknown // @user_data: user data passed to tracing APIs. typedef void (*uc_cb_hookcode_t)(uch handle, uint64_t address, uint32_t size, void *user_data); diff --git a/qemu/translate-all.c b/qemu/translate-all.c index 9723f23f..aaebee42 100644 --- a/qemu/translate-all.c +++ b/qemu/translate-all.c @@ -179,8 +179,10 @@ static int cpu_gen_code(CPUArchState *env, TranslationBlock *tb, int *gen_code_s gen_intermediate_code(env, tb); // Unicorn: when tracing block, patch 1st operand for block size - if (env->uc->hook_block) { - if (env->uc->block_addr == tb->pc) + if (env->uc->hook_block && env->uc->block_addr == tb->pc) { + if (env->uc->block_full) // block size is unknown + *(s->gen_opparam_buf + 1) = 0; + else *(s->gen_opparam_buf + 1) = tb->size; }