REMOTE_CONSOLE: Make STEP behavior consistent in master mode

As discussed in #866
This commit is contained in:
Mark Pizzolato 2020-06-06 08:40:49 -07:00
parent 706b376f9a
commit 65778c7664
3 changed files with 28 additions and 11 deletions

22
scp.c
View file

@ -8510,12 +8510,8 @@ if (signal (SIGTERM, int_handler) == SIG_ERR) { /* set WRU */
sim_ttcmd (); sim_ttcmd ();
return r; return r;
} }
if (sim_step) { /* set step timer */ if (sim_step) /* set step timer */
if (sim_switches & SWMASK ('T')) /* stepping for elapsed time? */ sim_sched_step ();
sim_activate_after (&sim_step_unit, (uint32)sim_step);/* wall clock based step */
else
sim_activate (&sim_step_unit, sim_step); /* instruction based step */
}
sim_activate_after (&sim_flush_unit, FLUSH_INTERVAL); /* Enable periodic buffer flushing */ sim_activate_after (&sim_flush_unit, FLUSH_INTERVAL); /* Enable periodic buffer flushing */
stop_cpu = FALSE; stop_cpu = FALSE;
sim_is_running = TRUE; /* flag running */ sim_is_running = TRUE; /* flag running */
@ -8565,7 +8561,7 @@ do {
else else
sim_step = 1; sim_step = 1;
if (sim_step) /* set step timer */ if (sim_step) /* set step timer */
sim_activate (&sim_step_unit, sim_step); sim_sched_step ();
} while (1); } while (1);
if ((SCPE_BARE_STATUS(r) == SCPE_STOP) && if ((SCPE_BARE_STATUS(r) == SCPE_STOP) &&
@ -8593,7 +8589,7 @@ signal (SIGHUP, SIG_DFL); /* cancel WRU */
signal (SIGTERM, SIG_DFL); /* cancel WRU */ signal (SIGTERM, SIG_DFL); /* cancel WRU */
sim_flush_buffered_files(); sim_flush_buffered_files();
sim_cancel (&sim_flush_unit); /* cancel flush timer */ sim_cancel (&sim_flush_unit); /* cancel flush timer */
sim_cancel (&sim_step_unit); /* cancel step timer */ sim_cancel_step (); /* cancel step timer */
sim_throt_cancel (); /* cancel throttle */ sim_throt_cancel (); /* cancel throttle */
AIO_UPDATE_QUEUE; AIO_UPDATE_QUEUE;
UPDATE_SIM_TIME; /* update sim time */ UPDATE_SIM_TIME; /* update sim time */
@ -8732,6 +8728,16 @@ t_stat sim_cancel_step (void)
return sim_cancel (&sim_step_unit); return sim_cancel (&sim_step_unit);
} }
/* schedule step service */
t_stat sim_sched_step (void)
{
if (sim_switches & SWMASK ('T')) /* stepping for elapsed time? */
return sim_activate_after_abs (&sim_step_unit, (uint32)sim_step);/* wall clock based step */
else
return sim_activate_abs (&sim_step_unit, sim_step); /* instruction based step */
}
/* Signal handler for ^C signal - set stop simulation flag */ /* Signal handler for ^C signal - set stop simulation flag */
void int_handler (int sig) void int_handler (int sig)

1
scp.h
View file

@ -318,6 +318,7 @@ t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST cha
t_stat sim_add_debug_flags (DEVICE *dptr, DEBTAB *debflags); t_stat sim_add_debug_flags (DEVICE *dptr, DEBTAB *debflags);
const char *sim_error_text (t_stat stat); const char *sim_error_text (t_stat stat);
t_stat sim_string_to_stat (const char *cptr, t_stat *cond); t_stat sim_string_to_stat (const char *cptr, t_stat *cond);
t_stat sim_sched_step (void);
t_stat sim_cancel_step (void); t_stat sim_cancel_step (void);
void sim_printf (const char *fmt, ...) GCC_FMT_ATTR(1, 2); void sim_printf (const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void sim_perror (const char *msg); void sim_perror (const char *msg);

View file

@ -1405,7 +1405,8 @@ for (i=(was_active_command ? sim_rem_cmd_active_line : 0);
sim_rem_cmd_active_line = -1; /* Done with active command */ sim_rem_cmd_active_line = -1; /* Done with active command */
if (!sim_rem_active_command) { /* STEP command? */ if (!sim_rem_active_command) { /* STEP command? */
stat = SCPE_STEP; stat = SCPE_STEP;
_sim_rem_message ("STEP", stat); /* produce a STEP complete message */ if (sim_con_stable_registers || !sim_rem_master_mode)
_sim_rem_message ("STEP", stat);/* produce a STEP complete message */
} }
_sim_rem_log_out (lp); _sim_rem_log_out (lp);
sim_rem_active_command = NULL; /* Restart loop to process available input */ sim_rem_active_command = NULL; /* Restart loop to process available input */
@ -1840,8 +1841,14 @@ if (sim_rem_master_was_connected && /* Master mode ever
!sim_rem_con_tmxr.ldsc[0].sock) /* Master Connection lost? */ !sim_rem_con_tmxr.ldsc[0].sock) /* Master Connection lost? */
return sim_messagef (SCPE_EXIT, "Master Session Disconnect");/* simulator has been 'unplugged' */ return sim_messagef (SCPE_EXIT, "Master Session Disconnect");/* simulator has been 'unplugged' */
if (sim_rem_cmd_active_line != -1) { if (sim_rem_cmd_active_line != -1) {
if (steps) if (steps) {
if (!sim_con_stable_registers && sim_rem_master_mode) {
sim_step = steps;
sim_sched_step ();
}
else
sim_activate(uptr, steps); /* check again after 'steps' instructions */ sim_activate(uptr, steps); /* check again after 'steps' instructions */
}
else else
return SCPE_REMOTE; /* force sim_instr() to exit to process command */ return SCPE_REMOTE; /* force sim_instr() to exit to process command */
} }
@ -2065,8 +2072,11 @@ if (sim_rem_master_mode) {
} }
sim_rem_cmd_active_line = 0; /* Make it look like */ sim_rem_cmd_active_line = 0; /* Make it look like */
sim_rem_consoles[0].single_mode = FALSE; sim_rem_consoles[0].single_mode = FALSE;
sim_cancel_step ();
if (stat != SCPE_STEP) if (stat != SCPE_STEP)
sim_rem_active_command = &allowed_single_remote_cmds[0];/* Dummy */ sim_rem_active_command = &allowed_single_remote_cmds[0];/* Dummy */
else
sim_activate_abs (rem_con_data_unit, 0); /* force step completion processing */
sim_last_cmd_stat = SCPE_BARE_STATUS(stat); /* make exit status available to remote console */ sim_last_cmd_stat = SCPE_BARE_STATUS(stat); /* make exit status available to remote console */
} }
sim_rem_master_was_enabled = FALSE; sim_rem_master_was_enabled = FALSE;