correct ebreak implementation, gdbstub watcher

everything in gdb should work now :)
This commit is contained in:
2023-10-08 19:04:25 +02:00
parent 89da4e56bb
commit 980070b204
2 changed files with 37 additions and 11 deletions

View File

@@ -512,7 +512,10 @@ static void cpu_execute(rv32_cpu_t* cpu, instruction_t* instruction)
fprintf(stderr, "ECALL: a7(sbi ext id) = %d, a6(sbi funct id) = %d\n", cpu->regs.a7, cpu->regs.a6);
break;
case IMM_EBREAK:
fprintf(stderr, "EBREAK\n");
// EBREAK : on debug, give back hand to debugger ; without debug, end simulation
// In any way, we set back simulation ticks to 0
cpu->sim_ticks_left = 1;
cpu->pc -= 4;
break;
default:
fprintf(stderr, "FATAL: Unknown IMM for ECALL/EBREAK instruction while executing (IMM=0x%x)\n", instruction->immediate);
@@ -650,6 +653,11 @@ void cpu_loop(rv32_cpu_t* cpu)
{
// Aquire CPU and memory mutex
pthread_mutex_lock(&cpu0_mutex);
// No simulation ticks left : wakeup people waiting on sim end
if(!cpu->sim_ticks_left)
pthread_cond_signal(&cpu0->sim_condition);
// Then, wait for simulation state to change until we get more ticks to simulate
while(!cpu->sim_ticks_left)
pthread_cond_wait(&cpu0->sim_condition, &cpu0_mutex);