signal(SIGINT, sig_int);
signal(SIGTERM, sig_int);
- for (;;)
- avr_run(avr);
+ for (;;) {
+ int state = avr_run(avr);
+ if ( state == cpu_Done || state == cpu_Crashed)
+ break;
+ }
avr_terminate(avr);
}
avr_gdb_init(avr);
}
if (!avr->gdb)
- exit(1); // no gdb ?
+ avr->state = cpu_Crashed;
}
static void _avr_io_command_write(struct avr_t * avr, avr_io_addr_t addr, uint8_t v, void * param)
if (avr->state == cpu_Sleeping) {
if (!avr->sreg[S_I]) {
- printf("simavr: sleeping with interrupts off, quitting gracefully\n");
+ if ( avr->log_level) printf("simavr: sleeping with interrupts off, quitting gracefully\n");
avr_terminate(avr);
- exit(0);
+ avr->state = cpu_Done;
+ return;
}
/*
* try to sleep for as long as we can (?)
if (avr->state == cpu_Sleeping) {
if (!avr->sreg[S_I]) {
- printf("simavr: sleeping with interrupts off, quitting gracefully\n");
+ if ( avr->log_level) printf("simavr: sleeping with interrupts off, quitting gracefully\n");
avr_terminate(avr);
- exit(0);
+ avr->state = cpu_Done;
+ return;
}
/*
* try to sleep for as long as we can (?)
cpu_Step, // run ONE instruction, then...
cpu_StepDone, // tell gdb it's all OK, and give it registers
+ cpu_Done, // avr software stopped gracefully
+ cpu_Crashed, // avr software crashed (watchdog fired)
};
// this is only ever used if CONFIG_SIMAVR_TRACE is defined