aboutsummaryrefslogtreecommitdiff
path: root/sim/common/run.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-04-18 12:24:52 +0000
committerAndrew Cagney <cagney@redhat.com>1997-04-18 12:24:52 +0000
commit8517f62b166073b871c896fdd642798fae4a08bd (patch)
tree805af7156e712458e58d2ebe21fc7b0b73dee681 /sim/common/run.c
parent2d3588808f00aaa6784f004aa940b862a11be3a2 (diff)
downloadfsf-binutils-gdb-8517f62b166073b871c896fdd642798fae4a08bd.zip
fsf-binutils-gdb-8517f62b166073b871c896fdd642798fae4a08bd.tar.gz
fsf-binutils-gdb-8517f62b166073b871c896fdd642798fae4a08bd.tar.bz2
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).
Diffstat (limited to 'sim/common/run.c')
-rw-r--r--sim/common/run.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sim/common/run.c b/sim/common/run.c
index 24dfe20..acdbab2 100644
--- a/sim/common/run.c
+++ b/sim/common/run.c
@@ -63,12 +63,24 @@ extern int sim_trace PARAMS ((SIM_DESC sd));
extern int getopt ();
+static SIM_DESC sd;
+
+static RETSIGTYPE
+cntrl_c (int sig)
+{
+ if (! sim_stop (sd))
+ {
+ fprintf (stderr, "Quit!\n");
+ exit (1);
+ }
+}
int
main (ac, av)
int ac;
char **av;
{
+ RETSIGTYPE (*prev_sigint) ();
bfd *abfd;
asection *s;
int i;
@@ -80,7 +92,6 @@ main (ac, av)
char **prog_args;
enum sim_stop reason;
int sigrc;
- SIM_DESC sd;
myname = av[0] + strlen (av[0]);
while (myname > av[0] && myname[-1] != '/')
@@ -207,6 +218,7 @@ main (ac, av)
if (sim_create_inferior (sd, prog_args, NULL) == SIM_RC_FAIL)
exit (1);
+ prev_sigint = signal (SIGINT, cntrl_c);
if (trace)
{
int done = 0;
@@ -219,6 +231,7 @@ main (ac, av)
{
sim_resume (sd, 0, 0);
}
+ signal (SIGINT, prev_sigint);
if (verbose)
sim_info (sd, 0);