Leave out size parameter in callback

This commit is contained in:
lazymio 2021-11-09 00:21:34 +01:00
parent 56fcc07a7c
commit 640251e1aa
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873
13 changed files with 22 additions and 19 deletions

View File

@ -259,7 +259,7 @@ typedef void (*uc_hook_edge_gen_t)(uc_engine *uc, uc_tb *cur_tb, uc_tb *prev_tb,
@arg2: The second argument.
*/
typedef void (*uc_hook_tcg_op_2)(uc_engine *uc, uint64_t address, uint64_t arg1,
uint64_t arg2, void *user_data);
uint64_t arg2, uint32_t size, void *user_data);
typedef uc_hook_tcg_op_2 uc_hook_tcg_sub_t;

View File

@ -42,11 +42,12 @@ static inline void gen_uc_tracecode(TCGContext *tcg_ctx, int32_t size, int32_t t
tcg_temp_free_i32(tcg_ctx, tsize);
}
static inline void gen_uc_traceopcode(TCGContext *tcg_ctx, void* hook, TCGv_i64 arg1, TCGv_i64 arg2, void *uc, uint64_t pc)
static inline void gen_uc_traceopcode(TCGContext *tcg_ctx, void* hook, TCGv_i64 arg1, TCGv_i64 arg2, uint32_t size, void *uc, uint64_t pc)
{
TCGv_ptr thook = tcg_const_ptr(tcg_ctx, hook);
TCGv_ptr tuc = tcg_const_ptr(tcg_ctx, uc);
TCGv_i64 tpc = tcg_const_i64(tcg_ctx, pc);
TCGv_i32 tsz = tcg_const_i32(tcg_ctx, size);
// #if TARGET_LONG_BITS == 32
// TCGv_i64 targ1 = temp_tcgv_i64(tcg_ctx, tcgv_i32_temp(tcg_ctx, arg1));
// TCGv_i64 targ2 = temp_tcgv_i64(tcg_ctx, tcgv_i32_temp(tcg_ctx, arg2));
@ -54,7 +55,8 @@ static inline void gen_uc_traceopcode(TCGContext *tcg_ctx, void* hook, TCGv_i64
// TCGv_i64 targ1 = arg1;
// TCGv_i64 targ2 = arg2;
// #endif
gen_helper_uc_traceopcode(tcg_ctx, thook, arg1, arg2, tuc, tpc);
gen_helper_uc_traceopcode(tcg_ctx, thook, arg1, arg2, tsz, tuc, tpc);
tcg_temp_free_i32(tcg_ctx, tsz);
tcg_temp_free_i64(tcg_ctx, tpc);
tcg_temp_free_ptr(tcg_ctx, tuc);
tcg_temp_free_ptr(tcg_ctx, thook);
@ -449,7 +451,7 @@ static inline void tcg_gen_sub_i32(TCGContext *tcg_ctx, TCGv_i32 ret, TCGv_i32 a
if (hook->to_delete)
continue;
if (hook->op == UC_TCG_OP_SUB && hook->op_flags == 0) {
gen_uc_traceopcode(tcg_ctx, hook, (TCGv_i64)arg1, (TCGv_i64)arg2, uc, tcg_ctx->pc_start);
gen_uc_traceopcode(tcg_ctx, hook, (TCGv_i64)arg1, (TCGv_i64)arg2, 32, uc, tcg_ctx->pc_start);
}
}
}
@ -682,7 +684,7 @@ static inline void tcg_gen_sub_i64(TCGContext *tcg_ctx, TCGv_i64 ret, TCGv_i64 a
if (hook->to_delete)
continue;
if (hook->op == UC_TCG_OP_SUB && hook->op_flags == 0) {
gen_uc_traceopcode(tcg_ctx, hook, arg1, arg2, uc, tcg_ctx->pc_start);
gen_uc_traceopcode(tcg_ctx, hook, arg1, arg2, 64, uc, tcg_ctx->pc_start);
}
}
}

View File

@ -1,5 +1,5 @@
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
DEF_HELPER_5(uc_traceopcode, void, ptr, i64, i64, ptr, i64)
DEF_HELPER_6(uc_traceopcode, void, ptr, i64, i64, i32, ptr, i64)
DEF_HELPER_FLAGS_1(sxtb16, TCG_CALL_NO_RWG_SE, i32, i32)
DEF_HELPER_FLAGS_1(uxtb16, TCG_CALL_NO_RWG_SE, i32, i32)

View File

@ -1,5 +1,5 @@
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
DEF_HELPER_5(uc_traceopcode, void, ptr, i64, i64, ptr, i64)
DEF_HELPER_6(uc_traceopcode, void, ptr, i64, i64, i32, ptr, i64)
DEF_HELPER_FLAGS_4(cc_compute_all, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl, int)
DEF_HELPER_FLAGS_4(cc_compute_c, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl, int)

View File

@ -1552,7 +1552,7 @@ static void gen_op(DisasContext *s1, int op, MemOp ot, int d)
continue;
if (hook->op == UC_TCG_OP_SUB && (hook->op_flags & UC_TCG_OP_FLAG_DIRECT) ) {
// TCGv is just an offset to tcg_ctx so it's safe to do so.
gen_uc_traceopcode(tcg_ctx, hook, (TCGv_i64)s1->T0, (TCGv_i64)s1->T1, uc, s1->pc_start);
gen_uc_traceopcode(tcg_ctx, hook, (TCGv_i64)s1->T0, (TCGv_i64)s1->T1, 1 << ((ot & MO_SIZE) + 3), uc, s1->pc_start);
}
}
}
@ -1607,7 +1607,7 @@ static void gen_op(DisasContext *s1, int op, MemOp ot, int d)
continue;
if (hook->op == UC_TCG_OP_SUB && (hook->op_flags & UC_TCG_OP_FLAG_CMP) ) {
// TCGv is just an offset to tcg_ctx so it's safe to do so.
gen_uc_traceopcode(tcg_ctx, hook, (TCGv_i64)s1->T0, (TCGv_i64)s1->T1, uc, s1->pc_start);
gen_uc_traceopcode(tcg_ctx, hook, (TCGv_i64)s1->T0, (TCGv_i64)s1->T1, 1 << ((ot & MO_SIZE) + 3), uc, s1->pc_start);
}
}
}

View File

@ -1,5 +1,5 @@
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
DEF_HELPER_5(uc_traceopcode, void, ptr, i64, i64, ptr, i64)
DEF_HELPER_6(uc_traceopcode, void, ptr, i64, i64, i32, ptr, i64)
DEF_HELPER_1(bitrev, i32, i32)
DEF_HELPER_1(ff1, i32, i32)

View File

@ -1,5 +1,5 @@
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
DEF_HELPER_5(uc_traceopcode, void, ptr, i64, i64, ptr, i64)
DEF_HELPER_6(uc_traceopcode, void, ptr, i64, i64, i32, ptr, i64)
DEF_HELPER_3(raise_exception_err, noreturn, env, i32, int)
DEF_HELPER_2(raise_exception, noreturn, env, i32)

View File

@ -1,5 +1,5 @@
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
DEF_HELPER_5(uc_traceopcode, void, ptr, i64, i64, ptr, i64)
DEF_HELPER_6(uc_traceopcode, void, ptr, i64, i64, i32, ptr, i64)
DEF_HELPER_FLAGS_3(raise_exception_err, TCG_CALL_NO_WG, void, env, i32, i32)
DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, void, env, i32)

View File

@ -1,5 +1,5 @@
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
DEF_HELPER_5(uc_traceopcode, void, ptr, i64, i64, ptr, i64)
DEF_HELPER_6(uc_traceopcode, void, ptr, i64, i64, i32, ptr, i64)
DEF_HELPER_1(uc_riscv_exit, void, env)
/* Exceptions */

View File

@ -1,5 +1,5 @@
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
DEF_HELPER_5(uc_traceopcode, void, ptr, i64, i64, ptr, i64)
DEF_HELPER_6(uc_traceopcode, void, ptr, i64, i64, i32, ptr, i64)
#ifndef TARGET_SPARC64
DEF_HELPER_1(rett, void, env)

View File

@ -909,7 +909,7 @@ void tcg_gen_sub2_i32(TCGContext *tcg_ctx, TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 al
TCGv_i64 t1 = tcg_temp_new_i64(tcg_ctx);
tcg_gen_concat_i32_i64(tcg_ctx, t0, al, ah);
tcg_gen_concat_i32_i64(tcg_ctx, t1, bl, bh);
gen_uc_traceopcode(tcg_ctx, hook, t0, t1, uc, tcg_ctx->pc_start);
gen_uc_traceopcode(tcg_ctx, hook, t0, t1, 32, uc, tcg_ctx->pc_start);
tcg_temp_free_i64(tcg_ctx, t0);
tcg_temp_free_i64(tcg_ctx, t1);
}

View File

@ -708,7 +708,8 @@ typedef struct _HOOK_TCG_OP_RESULTS {
} HOOK_TCG_OP_RESULTS;
static void test_x86_hook_tcg_op_cb(uc_engine *uc, uint64_t address,
uint64_t arg1, uint64_t arg2, void *data)
uint64_t arg1, uint64_t arg2, uint32_t size,
void *data)
{
HOOK_TCG_OP_RESULTS *results = (HOOK_TCG_OP_RESULTS *)data;
HOOK_TCG_OP_RESULT *result = &results->results[results->len++];

6
uc.c
View File

@ -1518,9 +1518,9 @@ uc_err uc_hook_del(uc_engine *uc, uc_hook hh)
// have memory hooks already. We may exceed the maximum arguments of a tcg
// helper but that's easy to extend.
void helper_uc_traceopcode(struct hook *hook, uint64_t arg1, uint64_t arg2,
void *handle, uint64_t address);
uint32_t size, void *handle, uint64_t address);
void helper_uc_traceopcode(struct hook *hook, uint64_t arg1, uint64_t arg2,
void *handle, uint64_t address)
uint32_t size, void *handle, uint64_t address)
{
struct uc_struct *uc = handle;
@ -1539,7 +1539,7 @@ void helper_uc_traceopcode(struct hook *hook, uint64_t arg1, uint64_t arg2,
// hold in most cases for uc_tracecode.
//
// TODO: Shall we have a flag to allow users to control whether updating PC?
((uc_hook_tcg_op_2)hook->callback)(uc, address, arg1, arg2,
((uc_hook_tcg_op_2)hook->callback)(uc, address, arg1, arg2, size,
hook->user_data);
if (unlikely(uc->stop_request)) {