Add a new hook type UC_HOOK_TCG_OPCODE
This commit is contained in:
@ -42,6 +42,24 @@ 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)
|
||||
{
|
||||
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);
|
||||
// #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));
|
||||
// #else
|
||||
// TCGv_i64 targ1 = arg1;
|
||||
// TCGv_i64 targ2 = arg2;
|
||||
// #endif
|
||||
gen_helper_uc_traceopcode(tcg_ctx, thook, arg1, arg2, tuc, tpc);
|
||||
tcg_temp_free_i64(tcg_ctx, tpc);
|
||||
tcg_temp_free_ptr(tcg_ctx, tuc);
|
||||
tcg_temp_free_ptr(tcg_ctx, thook);
|
||||
}
|
||||
|
||||
/* Basic output routines. Not for general consumption. */
|
||||
|
||||
void tcg_gen_op1(TCGContext *tcg_ctx, TCGOpcode, TCGArg);
|
||||
@ -422,6 +440,20 @@ static inline void tcg_gen_add_i32(TCGContext *tcg_ctx, TCGv_i32 ret, TCGv_i32 a
|
||||
|
||||
static inline void tcg_gen_sub_i32(TCGContext *tcg_ctx, TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
|
||||
{
|
||||
uc_engine *uc = tcg_ctx->uc;
|
||||
|
||||
if (HOOK_EXISTS_BOUNDED(uc, UC_HOOK_TCG_OPCODE, tcg_ctx->pc_start)) {
|
||||
struct hook *hook;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_TCG_OPCODE) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tcg_gen_op3_i32(tcg_ctx, INDEX_op_sub_i32, ret, arg1, arg2);
|
||||
}
|
||||
|
||||
@ -641,6 +673,20 @@ static inline void tcg_gen_add_i64(TCGContext *tcg_ctx, TCGv_i64 ret, TCGv_i64 a
|
||||
|
||||
static inline void tcg_gen_sub_i64(TCGContext *tcg_ctx, TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
|
||||
{
|
||||
uc_engine *uc = tcg_ctx->uc;
|
||||
|
||||
if (HOOK_EXISTS_BOUNDED(uc, UC_HOOK_TCG_OPCODE, tcg_ctx->pc_start)) {
|
||||
struct hook *hook;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_TCG_OPCODE) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tcg_gen_op3_i64(tcg_ctx, INDEX_op_sub_i64, ret, arg1, arg2);
|
||||
}
|
||||
|
||||
|
@ -791,6 +791,9 @@ struct TCGContext {
|
||||
TCGv NULL_QREG;
|
||||
/* Used to distinguish stores from bad addressing modes. */
|
||||
TCGv store_dummy;
|
||||
|
||||
// Used to store the start of current instrution.
|
||||
uint64_t pc_start;
|
||||
};
|
||||
|
||||
static inline size_t temp_idx(TCGContext *tcg_ctx, TCGTemp *ts)
|
||||
|
Reference in New Issue
Block a user