On 3 March 2013 21:07, Anthony Green <gr...@moxielogic.com> wrote: > +/* generate intermediate code for basic block 'tb'. */ > +static void > +gen_intermediate_code_internal(MoxieCPU *cpu, TranslationBlock *tb, > + bool search_pc) > +{ > + DisasContext ctx; > + target_ulong pc_start; > + uint16_t *gen_opc_end; > + CPUBreakpoint *bp; > + int j, lj = -1; > + CPUMoxieState *env = &cpu->env; > + > + pc_start = tb->pc; > + gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; > + ctx.pc = pc_start; > + ctx.saved_pc = -1; > + ctx.tb = tb; > + ctx.memidx = 0; > + ctx.singlestep_enabled = 0; > + ctx.bstate = BS_NONE; > + > + do { > + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { > + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { > + if (ctx.pc == bp->pc) { > + tcg_gen_movi_i32(cpu_pc, ctx.pc); > + gen_helper_debug(cpu_env); > + ctx.bstate = BS_EXCP; > + goto done_generating; > + } > + } > + } > + > + if (search_pc) { > + j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; > + if (lj < j) { > + lj++; > + while (lj < j) { > + tcg_ctx.gen_opc_instr_start[lj++] = 0; > + } > + } > + tcg_ctx.gen_opc_pc[lj] = ctx.pc; > + tcg_ctx.gen_opc_instr_start[lj] = 1; > + } > + ctx.opcode = cpu_lduw_code(env, ctx.pc); > + ctx.pc += decode_opc(cpu, &ctx); > + > + if (env->singlestep_enabled) { > + break; > + } > + > + if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) { > + break; > + } > + } while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end); > + > + if (env->singlestep_enabled) { > + tcg_gen_movi_tl(cpu_pc, ctx.pc); > + gen_helper_debug(cpu_env); > + } else { > + switch (ctx.bstate) { > + case BS_STOP: > + case BS_NONE: > + gen_goto_tb(env, &ctx, 0, ctx.pc); > + break; > + case BS_EXCP: > + tcg_gen_exit_tb(0); > + break; > + case BS_BRANCH: > + default: > + break; > + } > + } > + done_generating: > + *tcg_ctx.gen_opc_ptr = INDEX_op_end; > + if (search_pc) { > + j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; > + lj++; > + while (lj <= j) { > + tcg_ctx.gen_opc_instr_start[lj++] = 0; > + } > + } else { > + tb->size = ctx.pc - pc_start; > + } > +}
Now that my 'get rid of cpu_tb_unlink()' patch series has been applied, you must call 'gen_tb_start()' and 'gen_tb_end()' in the right places in this function, or interrupts will not be able to stop QEMU executing translated code. thanks -- PMM