From 31df5e8db21e60cedbed7442f95b77bbff633c56 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 25 Apr 2012 05:24:53 -0700 Subject: [PATCH] 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. --- scp.c | 58 ++++++++++++++++++++++++++++++++++++------------------ sim_defs.h | 2 ++ 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/scp.c b/scp.c index cb919b73..b4598ab8 100644 --- a/scp.c +++ b/scp.c @@ -412,7 +412,7 @@ t_stat set_quiet (int32 flag, char *cptr); t_stat set_asynch (int32 flag, char *cptr); t_stat do_cmd_label (int32 flag, char *cptr, char *label); void int_handler (int signal); - +void run_cmd_message (const char *unechod_cmdline, t_stat r); /* Global data */ @@ -578,15 +578,15 @@ static CTAB cmd_table[] = { { "EVALUATE", &eval_cmd, 0, "ev{aluate} evaluate symbolic expression\n" }, { "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 {new PC} start simulation\n" }, + "go {new PC} start simulation\n", &run_cmd_message }, { "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, - "c{ont} continue simulation\n" }, + "c{ont} continue simulation\n", &run_cmd_message }, { "BOOT", &run_cmd, RU_BOOT, - "b{oot} bootstrap unit\n" }, + "b{oot} bootstrap unit\n", &run_cmd_message }, { "BREAK", &brk_cmd, SSH_ST, "br{eak} set breakpoints\n" }, { "NOBREAK", &brk_cmd, SSH_CL, @@ -874,9 +874,13 @@ while (stat != SCPE_EXIT) { /* in case exit */ stat = SCPE_BARE_STATUS(stat); /* remove possible flag */ sim_last_cmd_stat = stat; /* save command error status */ if ((stat >= SCPE_BASE) && (!stat_nomessage)) { /* error? */ - printf ("%s\n", sim_error_text (stat)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (stat)); + if (cmdp->message) /* special message handler? */ + cmdp->message (NULL, 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) (*sim_vm_post) (TRUE); @@ -1184,7 +1188,8 @@ do { if ((stat >= SCPE_BASE) && (stat != SCPE_EXIT) && /* error from cmd? */ (stat != SCPE_STEP)) { 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); if (sim_log) fprintf (sim_log, "%s> %s\n", do_position(), ocptr); @@ -1192,9 +1197,14 @@ do { } if ((flag <= 0) && /* report error if in cmdline/init file */ (stat >= SCPE_BASE) && !stat_nomessage) { - printf ("%s\n", sim_error_text (stat)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (stat)); + if (cmdp->message) { /* special message handler */ + cmdp->message ((!echo && !sim_quiet) ? ocptr : NULL, stat); + } + else { + printf ("%s\n", sim_error_text (stat)); + if (sim_log) + fprintf (sim_log, "%s\n", sim_error_text (stat)); + } } if (staying && (sim_on_check[sim_do_depth]) && @@ -3580,15 +3590,25 @@ if (sim_clock_queue != NULL) { /* update sim time */ else { 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) printf ("\n"); #endif -if (!(r & SCPE_NOMESSAGE)) { - fprint_stopped (stdout, r); /* print msg */ - if (sim_log) /* log if enabled */ - fprint_stopped (sim_log, r); - } -return r | SCPE_NOMESSAGE; +if (unechoed_cmdline) { + printf("%s> %s\n", do_position(), unechoed_cmdline); + if (sim_log) + fprintf (sim_log, "%s> %s\n", do_position(), unechoed_cmdline); + } +fprint_stopped (stdout, r); /* print msg */ +if (sim_log) /* log if enabled */ + fprint_stopped (sim_log, r); } /* Common setup for RUN or BOOT */ diff --git a/sim_defs.h b/sim_defs.h index 399e4159..4c4d1f5c 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -432,6 +432,8 @@ struct sim_ctab { /* action routine */ int32 arg; /* argument */ char *help; /* help string */ + void (*message)(const char *unechoed_cmdline, t_stat stat); + /* message printing routine */ }; struct sim_c1tab {