Skip to content

Commit

Permalink
Dump illegal instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Jan 24, 2024
1 parent f65c274 commit 41428e7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions riscv_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,13 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
}
#endif

//// Begin Test: Quit if Illegal Instruction, otherwise it will loop forever
if (cause == 2) {
printf("tinyemu: Illegal instruction, quitting: pc=%p, instruction=%p\n", s->pc, tval);
exit(1);
}
//// End Test

//// Begin Test: Emulate OpenSBI for System Timer
if (cause == CAUSE_SUPERVISOR_ECALL) {
_info("TODO: Emulate OpenSBI for System Timer\n");
Expand Down Expand Up @@ -1216,9 +1223,6 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
set_priv(s, PRV_M);
s->pc = s->mtvec;
}
//// Begin Test: Quit if cause=2, otherwise it will loop forever
if (cause == 2) { puts("tinyemu: Unknown mcause 2, quitting"); exit(1); }
//// End Test
}

static void raise_exception(RISCVCPUState *s, uint32_t cause)
Expand Down

0 comments on commit 41428e7

Please sign in to comment.