+ /* Run/Step the program. */
+ if (single_step)
+ {
+ do
+ {
+ prev_sigint = signal (SIGINT, cntrl_c);
+ sim_resume (sd, 1/*step*/, 0);
+ 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 breakpoint or signals in oe mode*/
+ while (((reason == sim_signalled) &&
+ (sigrc == sim_signal_to_host (sd, SIM_SIGTRAP))) ||
+ ((reason == sim_stopped) &&
+ (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)));
+ }
+ 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;
+#else
+ 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));