Added a mechanism for commands to optionally handle their message printing via a separate dispatch in the command table. This is currently used by run_cmd to handle unsuppressed status returns.
This commit is contained in:
parent
72be72c472
commit
31df5e8db2
2 changed files with 41 additions and 19 deletions
58
scp.c
58
scp.c
|
@ -412,7 +412,7 @@ t_stat set_quiet (int32 flag, char *cptr);
|
||||||
t_stat set_asynch (int32 flag, char *cptr);
|
t_stat set_asynch (int32 flag, char *cptr);
|
||||||
t_stat do_cmd_label (int32 flag, char *cptr, char *label);
|
t_stat do_cmd_label (int32 flag, char *cptr, char *label);
|
||||||
void int_handler (int signal);
|
void int_handler (int signal);
|
||||||
|
void run_cmd_message (const char *unechod_cmdline, t_stat r);
|
||||||
|
|
||||||
/* Global data */
|
/* Global data */
|
||||||
|
|
||||||
|
@ -578,15 +578,15 @@ static CTAB cmd_table[] = {
|
||||||
{ "EVALUATE", &eval_cmd, 0,
|
{ "EVALUATE", &eval_cmd, 0,
|
||||||
"ev{aluate} <expr> evaluate symbolic expression\n" },
|
"ev{aluate} <expr> evaluate symbolic expression\n" },
|
||||||
{ "RUN", &run_cmd, RU_RUN,
|
{ "RUN", &run_cmd, RU_RUN,
|
||||||
"ru{n} {new PC} reset and start simulation\n" },
|
"ru{n} {new PC} reset and start simulation\n", &run_cmd_message },
|
||||||
{ "GO", &run_cmd, RU_GO,
|
{ "GO", &run_cmd, RU_GO,
|
||||||
"go {new PC} start simulation\n" },
|
"go {new PC} start simulation\n", &run_cmd_message },
|
||||||
{ "STEP", &run_cmd, RU_STEP,
|
{ "STEP", &run_cmd, RU_STEP,
|
||||||
"s{tep} {n} simulate n instructions\n" },
|
"s{tep} {n} simulate n instructions\n", &run_cmd_message },
|
||||||
{ "CONT", &run_cmd, RU_CONT,
|
{ "CONT", &run_cmd, RU_CONT,
|
||||||
"c{ont} continue simulation\n" },
|
"c{ont} continue simulation\n", &run_cmd_message },
|
||||||
{ "BOOT", &run_cmd, RU_BOOT,
|
{ "BOOT", &run_cmd, RU_BOOT,
|
||||||
"b{oot} <unit> bootstrap unit\n" },
|
"b{oot} <unit> bootstrap unit\n", &run_cmd_message },
|
||||||
{ "BREAK", &brk_cmd, SSH_ST,
|
{ "BREAK", &brk_cmd, SSH_ST,
|
||||||
"br{eak} <list> set breakpoints\n" },
|
"br{eak} <list> set breakpoints\n" },
|
||||||
{ "NOBREAK", &brk_cmd, SSH_CL,
|
{ "NOBREAK", &brk_cmd, SSH_CL,
|
||||||
|
@ -874,9 +874,13 @@ while (stat != SCPE_EXIT) { /* in case exit */
|
||||||
stat = SCPE_BARE_STATUS(stat); /* remove possible flag */
|
stat = SCPE_BARE_STATUS(stat); /* remove possible flag */
|
||||||
sim_last_cmd_stat = stat; /* save command error status */
|
sim_last_cmd_stat = stat; /* save command error status */
|
||||||
if ((stat >= SCPE_BASE) && (!stat_nomessage)) { /* error? */
|
if ((stat >= SCPE_BASE) && (!stat_nomessage)) { /* error? */
|
||||||
printf ("%s\n", sim_error_text (stat));
|
if (cmdp->message) /* special message handler? */
|
||||||
if (sim_log)
|
cmdp->message (NULL, stat);
|
||||||
fprintf (sim_log, "%s\n", sim_error_text (stat));
|
else {
|
||||||
|
printf ("%s\n", sim_error_text (stat));
|
||||||
|
if (sim_log)
|
||||||
|
fprintf (sim_log, "%s\n", sim_error_text (stat));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sim_vm_post != NULL)
|
if (sim_vm_post != NULL)
|
||||||
(*sim_vm_post) (TRUE);
|
(*sim_vm_post) (TRUE);
|
||||||
|
@ -1184,7 +1188,8 @@ do {
|
||||||
if ((stat >= SCPE_BASE) && (stat != SCPE_EXIT) && /* error from cmd? */
|
if ((stat >= SCPE_BASE) && (stat != SCPE_EXIT) && /* error from cmd? */
|
||||||
(stat != SCPE_STEP)) {
|
(stat != SCPE_STEP)) {
|
||||||
if (!echo && !sim_quiet && /* report if not echoing */
|
if (!echo && !sim_quiet && /* report if not echoing */
|
||||||
!stat_nomessage) { /* and not suppressing messages */
|
!stat_nomessage && /* and not suppressing messages */
|
||||||
|
!cmdp->message) { /* and not handling them specially */
|
||||||
printf("%s> %s\n", do_position(), ocptr);
|
printf("%s> %s\n", do_position(), ocptr);
|
||||||
if (sim_log)
|
if (sim_log)
|
||||||
fprintf (sim_log, "%s> %s\n", do_position(), ocptr);
|
fprintf (sim_log, "%s> %s\n", do_position(), ocptr);
|
||||||
|
@ -1192,9 +1197,14 @@ do {
|
||||||
}
|
}
|
||||||
if ((flag <= 0) && /* report error if in cmdline/init file */
|
if ((flag <= 0) && /* report error if in cmdline/init file */
|
||||||
(stat >= SCPE_BASE) && !stat_nomessage) {
|
(stat >= SCPE_BASE) && !stat_nomessage) {
|
||||||
printf ("%s\n", sim_error_text (stat));
|
if (cmdp->message) { /* special message handler */
|
||||||
if (sim_log)
|
cmdp->message ((!echo && !sim_quiet) ? ocptr : NULL, stat);
|
||||||
fprintf (sim_log, "%s\n", sim_error_text (stat));
|
}
|
||||||
|
else {
|
||||||
|
printf ("%s\n", sim_error_text (stat));
|
||||||
|
if (sim_log)
|
||||||
|
fprintf (sim_log, "%s\n", sim_error_text (stat));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (staying &&
|
if (staying &&
|
||||||
(sim_on_check[sim_do_depth]) &&
|
(sim_on_check[sim_do_depth]) &&
|
||||||
|
@ -3580,15 +3590,25 @@ if (sim_clock_queue != NULL) { /* update sim time */
|
||||||
else {
|
else {
|
||||||
UPDATE_SIM_TIME (noqueue_time);
|
UPDATE_SIM_TIME (noqueue_time);
|
||||||
}
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* run command message handler */
|
||||||
|
|
||||||
|
void
|
||||||
|
run_cmd_message (const char *unechoed_cmdline, t_stat r)
|
||||||
|
{
|
||||||
#if defined (VMS)
|
#if defined (VMS)
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
#endif
|
#endif
|
||||||
if (!(r & SCPE_NOMESSAGE)) {
|
if (unechoed_cmdline) {
|
||||||
fprint_stopped (stdout, r); /* print msg */
|
printf("%s> %s\n", do_position(), unechoed_cmdline);
|
||||||
if (sim_log) /* log if enabled */
|
if (sim_log)
|
||||||
fprint_stopped (sim_log, r);
|
fprintf (sim_log, "%s> %s\n", do_position(), unechoed_cmdline);
|
||||||
}
|
}
|
||||||
return r | SCPE_NOMESSAGE;
|
fprint_stopped (stdout, r); /* print msg */
|
||||||
|
if (sim_log) /* log if enabled */
|
||||||
|
fprint_stopped (sim_log, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Common setup for RUN or BOOT */
|
/* Common setup for RUN or BOOT */
|
||||||
|
|
|
@ -432,6 +432,8 @@ struct sim_ctab {
|
||||||
/* action routine */
|
/* action routine */
|
||||||
int32 arg; /* argument */
|
int32 arg; /* argument */
|
||||||
char *help; /* help string */
|
char *help; /* help string */
|
||||||
|
void (*message)(const char *unechoed_cmdline, t_stat stat);
|
||||||
|
/* message printing routine */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sim_c1tab {
|
struct sim_c1tab {
|
||||||
|
|
Loading…
Add table
Reference in a new issue