X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=sim%2Fcommon%2Fnrun.c;h=8dfa94658b0a9ca5ee541d9fc052e0a3fc47eb6d;hb=fc0a224429224e8ce0c1adb631e10124a597cc6d;hp=2f13b1f91bbf2f164bf996984677355855575525;hpb=5b64ad42d36e6d487e1f7287d37fbc243a178e72;p=binutils-gdb.git diff --git a/sim/common/nrun.c b/sim/common/nrun.c index 2f13b1f91bb..8dfa94658b0 100644 --- a/sim/common/nrun.c +++ b/sim/common/nrun.c @@ -47,7 +47,7 @@ main (int argc, char **argv) { char *name; char **prog_argv = NULL; - struct _bfd *prog_bfd; + struct bfd *prog_bfd; enum sim_stop reason; int sigrc = 0; int single_step = 0; @@ -137,46 +137,45 @@ main (int argc, char **argv) ((reason == sim_stopped) && (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT))); } - else do + else { + do + { #if defined (HAVE_SIGACTION) && defined (SA_RESTART) - struct sigaction sa, osa; - sa.sa_handler = cntrl_c; - sigemptyset (&sa.sa_mask); - sa.sa_flags = 0; - sigaction (SIGINT, &sa, &osa); - prev_sigint = osa.sa_handler; + struct sigaction sa, osa; + sa.sa_handler = cntrl_c; + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; + sigaction (SIGINT, &sa, &osa); + prev_sigint = osa.sa_handler; #else - prev_sigint = signal (SIGINT, cntrl_c); + prev_sigint = signal (SIGINT, cntrl_c); #endif - sim_resume (sd, 0, sigrc); - signal (SIGINT, prev_sigint); - sim_stop_reason (sd, &reason, &sigrc); - - if ((reason == sim_stopped) && - (sigrc == sim_signal_to_host (sd, SIM_SIGINT))) - break; /* exit on control-C */ - - /* remain on signals in oe mode */ - } while ((reason == sim_stopped) && - (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)); - + sim_resume (sd, 0, sigrc); + signal (SIGINT, prev_sigint); + sim_stop_reason (sd, &reason, &sigrc); + + if ((reason == sim_stopped) && + (sigrc == sim_signal_to_host (sd, SIM_SIGINT))) + break; /* exit on control-C */ + + /* remain on signals in oe mode */ + } while ((reason == sim_stopped) && + (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)); + + } /* Print any stats the simulator collected. */ - sim_info (sd, 0); - + if (STATE_VERBOSE_P (sd)) + sim_info (sd, 0); + /* Shutdown the simulator. */ sim_close (sd, 0); - + /* If reason is sim_exited, then sigrc holds the exit code which we want to return. If reason is sim_stopped or sim_signalled, then sigrc holds the signal that the simulator received; we want to return that to indicate failure. */ - -#ifdef SIM_H8300 /* FIXME: Ugh. grep for SLEEP in compile.c */ - if (sigrc == SIGILL) - abort (); - sigrc = 0; -#else + /* Why did we stop? */ switch (reason) { @@ -194,7 +193,6 @@ main (int argc, char **argv) break; } -#endif return sigrc; }