mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-02 05:01:06 +00:00
exec: [tcg] Track which vCPU is performing translation and execution
Information is tracked inside the TCGContext structure, and later used by tracing events with the 'tcg' and 'vcpu' properties. The 'cpu' field is used to check tracing of translation-time events ("*_trans"). The 'tcg_env' field is used to pass it to execution-time events ("*_exec"). Backports commit 7c2550432abe62f53e6df878ceba6ceaf71f0e7e from qemu
This commit is contained in:
parent
0f6513ef62
commit
2297527755
|
@ -73,6 +73,7 @@ void arm_translate_init(struct uc_struct *uc)
|
|||
TCGContext *tcg_ctx = uc->tcg_ctx;
|
||||
|
||||
tcg_ctx->cpu_env = tcg_global_reg_new_ptr(uc->tcg_ctx, TCG_AREG0, "env");
|
||||
tcg_ctx->tcg_env = tcg_ctx->cpu_env;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
tcg_ctx->cpu_R[i] = tcg_global_mem_new_i32(uc->tcg_ctx, tcg_ctx->cpu_env,
|
||||
|
|
|
@ -8909,6 +8909,8 @@ void tcg_x86_init(struct uc_struct *uc)
|
|||
TCGContext *tcg_ctx = uc->tcg_ctx;
|
||||
|
||||
tcg_ctx->cpu_env = tcg_global_reg_new_ptr(uc->tcg_ctx, TCG_AREG0, "env");
|
||||
tcg_ctx->tcg_env = tcg_ctx->cpu_env;
|
||||
|
||||
tcg_ctx->cpu_cc_op = tcg_global_mem_new_i32(uc->tcg_ctx, tcg_ctx->cpu_env,
|
||||
offsetof(CPUX86State, cc_op), "cc_op");
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ void m68k_tcg_init(struct uc_struct *uc)
|
|||
int i;
|
||||
|
||||
tcg_ctx->cpu_env = tcg_global_reg_new_ptr(tcg_ctx, TCG_AREG0, "env");
|
||||
tcg_ctx->tcg_env = tcg_ctx->cpu_env;
|
||||
|
||||
#define DEFO32(name, offset) tcg_ctx->QREG_##name = tcg_global_mem_new_i32(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUM68KState, offset), #name);
|
||||
#define DEFO64(name, offset) tcg_ctx->QREG_##name = tcg_global_mem_new_i64(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUM68KState, offset), #name);
|
||||
|
|
|
@ -20144,6 +20144,7 @@ void mips_tcg_init(struct uc_struct *uc)
|
|||
int i;
|
||||
|
||||
tcg_ctx->cpu_env = tcg_global_reg_new_ptr(uc->tcg_ctx, TCG_AREG0, "env");
|
||||
tcg_ctx->tcg_env = tcg_ctx->cpu_env;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
tcg_ctx->cpu_gpr[i] = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env,
|
||||
|
|
|
@ -5537,6 +5537,8 @@ void gen_intermediate_code_init(CPUSPARCState *env)
|
|||
return;
|
||||
}
|
||||
tcg_ctx->cpu_env = tcg_global_reg_new_ptr(tcg_ctx, TCG_AREG0, "env");
|
||||
tcg_ctx->tcg_env = tcg_ctx->cpu_env;
|
||||
|
||||
tcg_ctx->cpu_regwptr = tcg_global_mem_new_ptr(tcg_ctx, tcg_ctx->cpu_env,
|
||||
offsetof(CPUSPARCState, regwptr),
|
||||
"regwptr");
|
||||
|
|
|
@ -727,6 +727,10 @@ struct TCGContext {
|
|||
|
||||
TBContext tb_ctx;
|
||||
|
||||
/* Track which vCPU triggers events */
|
||||
CPUState *cpu; /* *_trans */
|
||||
TCGv_env tcg_env; /* *_exec */
|
||||
|
||||
/* The TCGBackendData structure is private to tcg-target.inc.c. */
|
||||
struct TCGBackendData *be;
|
||||
|
||||
|
|
|
@ -1292,7 +1292,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
|
||||
tcg_func_start(tcg_ctx);
|
||||
|
||||
tcg_ctx->cpu = ENV_GET_CPU(env);
|
||||
gen_intermediate_code(env, tb);
|
||||
tcg_ctx->cpu = NULL;
|
||||
|
||||
// Unicorn: when tracing block, patch block size operand for callback
|
||||
if (env->uc->size_arg != -1 && HOOK_EXISTS_BOUNDED(env->uc, UC_HOOK_BLOCK, tb->pc)) {
|
||||
|
|
Loading…
Reference in a new issue