From 8517f62b166073b871c896fdd642798fae4a08bd Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Fri, 18 Apr 1997 12:24:52 +0000 Subject: Ref gdb/11763 - can't stop a running simulator: o Provide poll_quit callback to simulators so that they can poll for SIGINT on clueless OS's. o Add sim_stop to simulators so that clients can request a halt (eg gdbtk's STOP button) Works for PPC! o Re-arange remote-sim.c so that the hard work is moved from gdbsim_resume() to gdbsim_wait() (where it should be). --- sim/ppc/ChangeLog | 23 +++++++++++++++++++++++ sim/ppc/main.c | 21 ++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'sim/ppc') diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog index 9c35194..49b0aa2 100644 --- a/sim/ppc/ChangeLog +++ b/sim/ppc/ChangeLog @@ -1,3 +1,26 @@ +Fri Apr 18 17:03:09 1997 Andrew Cagney + + * sim_calls.c (sim_stop_reason): Simplify. Was running implies + stopped/SIGINT. Exit implies a status code. + + * psim.c (cntrl_c_simulation): From main.c. Event function that + halts the simulator. + (psim_stop): New. Asynchronously schedule a stop simulator event. + (psim_run_until_stop): Delete. Made redundant by psim_stop. + + * main.c (cntrl_c): Update. + (cntrl_c_simulation): Moved to psim.c. + + * sim_calls.c (sim_stop): New function. Use psim_stop which + schedules a stop event. + (sim_resume): Drop SIGINT handler, now in gdb/main.c. + (sim_resume): Use psim_run as stop variable no longer needed. + +Fri Apr 18 17:03:08 1997 Andrew Cagney + + * psim.c (psim_options): Handle -E option correctly. + (psim_usage): Document. + Thu Apr 17 03:28:03 1997 Doug Evans * psim.c (psim_options): Ignore -E option (sets endianness). diff --git a/sim/ppc/main.c b/sim/ppc/main.c index 454efed..091486b 100644 --- a/sim/ppc/main.c +++ b/sim/ppc/main.c @@ -23,9 +23,12 @@ #include #include +#include + #include "psim.h" #include "options.h" #include "device.h" /* FIXME: psim should provide the interface */ +#include "events.h" /* FIXME: psim should provide the interface */ #ifdef HAVE_STDLIB_H #include @@ -149,6 +152,7 @@ sim_io_read_stdin(char *buf, return sim_io_eof; break; case DONT_USE_STDIO: +#if defined(O_NDELAY) && defined(F_GETFL) && defined(F_SETFL) { /* check for input */ int flags; @@ -189,6 +193,7 @@ sim_io_read_stdin(char *buf, return result; } break; +#endif default: error("sim_io_read_stdin: invalid switch\n"); break; @@ -228,6 +233,15 @@ zfree(void *chunk) free(chunk); } +/* When a CNTRL-C occures, queue an event to shut down the simulation */ + +static RETSIGTYPE +cntrl_c(int sig) +{ + psim_stop (simulation); +} + + int main(int argc, char **argv) { @@ -264,7 +278,12 @@ main(int argc, char **argv) psim_init(simulation); psim_stack(simulation, argv, environ); - psim_run(simulation); + { + RETSIGTYPE (*prev) (); + prev = signal(SIGINT, cntrl_c); + psim_run(simulation); + signal(SIGINT, prev); + } /* any final clean up */ if (ppc_trace[trace_print_info]) -- cgit v1.1