add runtime printing for call/return
this makes it easier to follow execution and figure out what's currently running
This commit is contained in:
parent
de26285433
commit
90ff09bc10
3 changed files with 14 additions and 0 deletions
|
|
@ -29,3 +29,7 @@ void helper_dump_regs(CPUCR16CState* env) {
|
|||
qemu_printf("State dump requested:\n");
|
||||
cr16c_debug_dump_state(env_cpu(env));
|
||||
}
|
||||
|
||||
void helper_print_addr(const void * insn, uint32_t addr) {
|
||||
qemu_printf("%s to: 0x%x\n", (const char *) insn, addr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ DEF_HELPER_1(raise_illegal_instruction, void, env);
|
|||
DEF_HELPER_1(raise_unimplemented_instruction, void, env);
|
||||
DEF_HELPER_1(exit, void, env);
|
||||
DEF_HELPER_1(dump_regs, void, env);
|
||||
DEF_HELPER_2(print_addr, void, cptr, i32);
|
||||
|
|
|
|||
|
|
@ -1367,6 +1367,10 @@ static bool trans_JCOND(DisasContext* ctx, arg_JCOND *a) {
|
|||
|
||||
gen_set_label(l);
|
||||
|
||||
if (a->cond == CR16C_COND_ALWAYS && a->ra == CR16C_REGNO_RA) {
|
||||
gen_helper_print_addr(tcg_constant_ptr("JUMP ra"), r[a->ra]);
|
||||
}
|
||||
|
||||
tcg_gen_mov_i32(pc, r[a->ra]);
|
||||
tcg_gen_lookup_and_goto_ptr();
|
||||
|
||||
|
|
@ -1395,6 +1399,8 @@ static bool trans_JAL(DisasContext* ctx, arg_JAL *a) {
|
|||
tcg_gen_extract2_i32(pc, r[a->destrp], r[a->destrp+1], 0);
|
||||
tcg_gen_andi_i32(pc, pc, 0xffffff);
|
||||
tcg_gen_shli_i32(pc, pc, 1);
|
||||
|
||||
gen_helper_print_addr(tcg_constant_ptr("JAL"), pc);
|
||||
tcg_gen_lookup_and_goto_ptr();
|
||||
|
||||
// TODO CFG.SR handling
|
||||
|
|
@ -1723,6 +1729,8 @@ static bool trans_BAL_ra(DisasContext *ctx, arg_BAL_ra *a) {
|
|||
// 2) sign extend from 23 -> "25" bits
|
||||
int32_t dest_sextend = sextract32(dest_offset, 0, 23);
|
||||
|
||||
gen_helper_print_addr(tcg_constant_ptr("BAL"), tcg_constant_i32(pc_this + dest_sextend));
|
||||
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
gen_goto(&ctx->base, pc_this + dest_sextend, 0);
|
||||
|
||||
|
|
@ -1759,6 +1767,7 @@ static bool trans_pop(DisasContext *ctx, arg_pop *a) {
|
|||
|
||||
if (a->rt) {
|
||||
// basically, JUMP RA
|
||||
gen_helper_print_addr(tcg_constant_ptr("POPRET"), r[CR16C_REGNO_RA]);
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
|
||||
tcg_gen_mov_i32(pc, r[CR16C_REGNO_RA]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue