SCP: Migrate more output written to sim_log to use sim_printf.

This commit is contained in:
Mark Pizzolato 2014-10-22 13:25:42 -07:00
parent 6c5a700191
commit bff7521c56
3 changed files with 34 additions and 90 deletions

View file

@ -223,6 +223,7 @@ The EXPECT command now exists to provide a means of reacting to simulator output
SHIFT Slide argument parameters %1 thru %9 left 1 SHIFT Slide argument parameters %1 thru %9 left 1
NOOP A no-op command NOOP A no-op command
ON Establish or cancel an ON condition dispatch ON Establish or cancel an ON condition dispatch
IF Test some simulator state and conditionally execute commands
CD Change working directory CD Change working directory
SET DEFAULT Change working directory SET DEFAULT Change working directory
PWD Show working directory PWD Show working directory

49
scp.c
View file

@ -1612,7 +1612,7 @@ ASSERT failure have several different actions:
"++GEQ - greater than or equal\n\n" "++GEQ - greater than or equal\n\n"
" Comparisons are generic. This means that if both string1 and string2 are\n" " Comparisons are generic. This means that if both string1 and string2 are\n"
" comprised of all numeric digits, then the strings are converted to numbers\n" " comprised of all numeric digits, then the strings are converted to numbers\n"
" and a numeric comparison is performed. For example: \"+1\" EQU "1" will be " and a numeric comparison is performed. For example: \"+1\" EQU \"1\" will be\n"
" true.\n" " true.\n"
/***************** 80 character line width template *************************/ /***************** 80 character line width template *************************/
#define HLP_EXIT "*Commands Exiting_The_Simulator" #define HLP_EXIT "*Commands Exiting_The_Simulator"
@ -2425,34 +2425,24 @@ if (*cptr) {
int i; int i;
for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { for (i = 0; (dptr = sim_devices[i]) != NULL; i++) {
if (dptr->help) { if (dptr->help)
fprintf (stdout, "h{elp} %-17s display help for device %s\n", dptr->name, dptr->name); sim_printf ("h{elp} %-17s display help for device %s\n", dptr->name, dptr->name);
if (sim_log)
fprintf (sim_log, "h{elp} %-17s display help for device %s\n", dptr->name, dptr->name);
}
if (dptr->attach_help || if (dptr->attach_help ||
(DEV_TYPE(dptr) == DEV_MUX) || (DEV_TYPE(dptr) == DEV_MUX) ||
(DEV_TYPE(dptr) == DEV_DISK) || (DEV_TYPE(dptr) == DEV_DISK) ||
(DEV_TYPE(dptr) == DEV_TAPE)) { (DEV_TYPE(dptr) == DEV_TAPE)) {
fprintf (stdout, "h{elp} %s ATTACH\t display help for device %s ATTACH command\n", dptr->name, dptr->name); sim_printf ("h{elp} %s ATTACH\t display help for device %s ATTACH command\n", dptr->name, dptr->name);
if (sim_log)
fprintf (sim_log, "h{elp} %s ATTACH\t display help for device %s ATTACH command\n", dptr->name, dptr->name);
} }
if (dptr->registers) { if (dptr->registers) {
if (dptr->registers->name != NULL) { if (dptr->registers->name != NULL)
fprintf (stdout, "h{elp} %s REGISTERS\t display help for device %s register variables\n", dptr->name, dptr->name); sim_printf ("h{elp} %s REGISTERS\t display help for device %s register variables\n", dptr->name, dptr->name);
if (sim_log)
fprintf (sim_log, "h{elp} %s REGISTERS\t display help for device %s register variables\n", dptr->name, dptr->name);
}
} }
if (dptr->modifiers) { if (dptr->modifiers) {
MTAB *mptr; MTAB *mptr;
for (mptr = dptr->modifiers; mptr->pstring != NULL; mptr++) { for (mptr = dptr->modifiers; mptr->pstring != NULL; mptr++) {
if (mptr->help) { if (mptr->help) {
fprintf (stdout, "h{elp} %s SET\t\t display help for device %s SET commands (modifiers)\n", dptr->name, dptr->name); sim_printf ("h{elp} %s SET\t\t display help for device %s SET commands (modifiers)\n", dptr->name, dptr->name);
if (sim_log)
fprintf (sim_log, "h{elp} %s SET\t\t display help for device %s SET commands (modifiers)\n", dptr->name, dptr->name);
break; break;
} }
} }
@ -2474,18 +2464,12 @@ if (*cptr) {
for (cmdpa=cmd_table; cmdpa->name != NULL; cmdpa++) for (cmdpa=cmd_table; cmdpa->name != NULL; cmdpa++)
if ((cmdpa->action == cmdp->action) && (cmdpa->help)) { if ((cmdpa->action == cmdp->action) && (cmdpa->help)) {
fprintf (stdout, "%s is an alias for the %s command:\n%s", sim_printf ("%s is an alias for the %s command:\n%s",
cmdp->name, cmdpa->name, cmdpa->help); cmdp->name, cmdpa->name, cmdpa->help);
if (sim_log)
fprintf (sim_log, "%s is an alias for the %s command.\n%s",
cmdp->name, cmdpa->name, cmdpa->help);
break; break;
} }
if (cmdpa->name == NULL) { /* not found? */ if (cmdpa->name == NULL) /* not found? */
fprintf (stdout, "No help available for the %s command\n", cmdp->name); sim_printf ("No help available for the %s command\n", cmdp->name);
if (sim_log)
fprintf (sim_log, "No help available for the %s command\n", cmdp->name);
}
} }
} }
else { else {
@ -2498,11 +2482,8 @@ if (*cptr) {
dptr = find_dev (gbuf); dptr = find_dev (gbuf);
if (dptr == NULL) if (dptr == NULL)
return SCPE_ARG; return SCPE_ARG;
if (dptr->flags & DEV_DISABLE) { if (dptr->flags & DEV_DISABLE)
fprintf (stdout, "Device %s is currently disabled\n", dptr->name); sim_printf ("Device %s is currently disabled\n", dptr->name);
if (sim_log)
fprintf (sim_log, "Device %s is currently disabled\n", dptr->name);
}
} }
r = help_dev_help (stdout, dptr, uptr, flag, cptr); r = help_dev_help (stdout, dptr, uptr, flag, cptr);
if (sim_log) if (sim_log)
@ -2548,11 +2529,7 @@ return status;
t_stat echo_cmd (int32 flag, char *cptr) t_stat echo_cmd (int32 flag, char *cptr)
{ {
puts (cptr); sim_printf ("%s\n", cptr);
if (sim_log)
fprintf (sim_log, "%s\n", cptr);
if (sim_deb)
fprintf (sim_deb, "\n%s\n", cptr);
return SCPE_OK; return SCPE_OK;
} }

View file

@ -516,15 +516,11 @@ CTAB *cmdp, *cmdph;
if (*cptr) if (*cptr)
return help_cmd (flag, cptr); return help_cmd (flag, cptr);
printf ("Remote Console Commands:\r\n"); sim_printf ("Remote Console Commands:\r\n");
if (sim_log)
fprintf (sim_log, "Remote Console Commands:\r\n");
for (cmdp=allowed_remote_cmds; cmdp->name != NULL; ++cmdp) { for (cmdp=allowed_remote_cmds; cmdp->name != NULL; ++cmdp) {
cmdph = find_cmd (cmdp->name); cmdph = find_cmd (cmdp->name);
if (cmdph && cmdph->help) { if (cmdph && cmdph->help) {
printf ("%s", cmdph->help); sim_printf ("%s\r\n", cmdph->help);
if (sim_log)
fprintf (sim_log, "%s", cmdph->help);
} }
} }
return SCPE_OK; return SCPE_OK;
@ -566,11 +562,8 @@ for (i=(was_stepping ? sim_rem_step_line : 0);
if (cmdp && (cmdp->message)) /* special message handler? */ if (cmdp && (cmdp->message)) /* special message handler? */
cmdp->message (NULL, stat); /* let it deal with display */ cmdp->message (NULL, stat); /* let it deal with display */
else else
if (stat >= SCPE_BASE) { /* error? */ if (stat >= SCPE_BASE) /* error? */
printf ("%s\r\n", sim_error_text (stat)); sim_printf ("%s\r\n", sim_error_text (stat));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (stat));
}
fflush (sim_log); fflush (sim_log);
sim_fseeko (sim_log, cmd_log_start, SEEK_SET); sim_fseeko (sim_log, cmd_log_start, SEEK_SET);
cbuf[sizeof(cbuf)-1] = '\0'; cbuf[sizeof(cbuf)-1] = '\0';
@ -714,14 +707,10 @@ for (i=(was_stepping ? sim_rem_step_line : 0);
if ((sim_rem_single_mode[i]) && !got_command) { if ((sim_rem_single_mode[i]) && !got_command) {
break; break;
} }
printf ("Remote Console Command from %s> %s\r\n", lp->ipad, sim_rem_buf[i]); sim_printf ("Remote Console Command from %s> %s\r\n", lp->ipad, sim_rem_buf[i]);
if (sim_log)
fprintf (sim_log, "Remote Console Command from %s> %s\n", lp->ipad, sim_rem_buf[i]);
got_command = FALSE; got_command = FALSE;
if (strlen(sim_rem_buf[i]) >= sizeof(cbuf)) { if (strlen(sim_rem_buf[i]) >= sizeof(cbuf)) {
printf ("\nLine too long. Ignored. Continuing Simulator execution\n"); sim_printf ("\r\nLine too long. Ignored. Continuing Simulator execution\r\n");
if (sim_log)
fprintf (sim_log, "\r\nLine too long. Ignored. Continuing Simulator execution\r\n");
tmxr_linemsgf (lp, "\nLine too long. Ignored. Continuing Simulator execution\n"); tmxr_linemsgf (lp, "\nLine too long. Ignored. Continuing Simulator execution\n");
tmxr_send_buffered_data (lp); /* try to flush any buffered data */ tmxr_send_buffered_data (lp); /* try to flush any buffered data */
break; break;
@ -789,11 +778,8 @@ for (i=(was_stepping ? sim_rem_step_line : 0);
if (cmdp && (cmdp->message)) /* special message handler? */ if (cmdp && (cmdp->message)) /* special message handler? */
cmdp->message (NULL, stat); /* let it deal with display */ cmdp->message (NULL, stat); /* let it deal with display */
else else
if (stat >= SCPE_BASE) { /* error? */ if (stat >= SCPE_BASE) /* error? */
printf ("%s\r\n", sim_error_text (stat)); sim_printf ("%s\r\n", sim_error_text (stat));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (stat));
}
} }
fflush (sim_log); fflush (sim_log);
sim_fseeko (sim_log, cmd_log_start, SEEK_SET); sim_fseeko (sim_log, cmd_log_start, SEEK_SET);
@ -1082,24 +1068,13 @@ if (sim_deb_switches & SWMASK ('R')) {
sim_deb_switches |= SWMASK ('T'); sim_deb_switches |= SWMASK ('T');
} }
if (!sim_quiet) { if (!sim_quiet) {
printf ("Debug output to \"%s\"\n", sim_printf ("Debug output to \"%s\"\n", sim_logfile_name (sim_deb, sim_deb_ref));
sim_logfile_name (sim_deb, sim_deb_ref));
if (sim_deb_switches & SWMASK ('P')) if (sim_deb_switches & SWMASK ('P'))
printf (" Debug messages contain current PC value\n"); sim_printf (" Debug messages contain current PC value\n");
if (sim_deb_switches & SWMASK ('T')) if (sim_deb_switches & SWMASK ('T'))
printf (" Debug messages display time of day as hh:mm:ss.msec%s\n", sim_deb_switches & SWMASK ('R') ? " relative to the start of debugging" : ""); sim_printf (" Debug messages display time of day as hh:mm:ss.msec%s\n", sim_deb_switches & SWMASK ('R') ? " relative to the start of debugging" : "");
if (sim_deb_switches & SWMASK ('A')) if (sim_deb_switches & SWMASK ('A'))
printf (" Debug messages display time of day as seconds.msec%s\n", sim_deb_switches & SWMASK ('R') ? " relative to the start of debugging" : ""); sim_printf (" Debug messages display time of day as seconds.msec%s\n", sim_deb_switches & SWMASK ('R') ? " relative to the start of debugging" : "");
if (sim_log) {
fprintf (sim_log, "Debug output to \"%s\"\n",
sim_logfile_name (sim_deb, sim_deb_ref));
if (sim_deb_switches & SWMASK ('P'))
fprintf (sim_log, " Debug messages contain current PC value\n");
if (sim_deb_switches & SWMASK ('T'))
fprintf (sim_log, " Debug messages display time of day as hh:mm:ss.msec%s\n", sim_deb_switches & SWMASK ('R') ? " relative to the start of debugging" : "");
if (sim_deb_switches & SWMASK ('A'))
fprintf (sim_log, " Debug messages display time of day as seconds.msec%s\n", sim_deb_switches & SWMASK ('R') ? " relative to the start of debugging" : "");
}
time(&now); time(&now);
fprintf (sim_deb, "Debug output to \"%s\" at %s", sim_logfile_name (sim_deb, sim_deb_ref), ctime(&now)); fprintf (sim_deb, "Debug output to \"%s\" at %s", sim_logfile_name (sim_deb, sim_deb_ref), ctime(&now));
show_version (sim_deb, NULL, NULL, 0, NULL); show_version (sim_deb, NULL, NULL, 0, NULL);
@ -1142,11 +1117,8 @@ if (sim_deb == NULL) /* no debug? */
sim_close_logfile (&sim_deb_ref); sim_close_logfile (&sim_deb_ref);
sim_deb = NULL; sim_deb = NULL;
sim_deb_switches = 0; sim_deb_switches = 0;
if (!sim_quiet) { if (!sim_quiet)
printf ("Debug output disabled\n"); sim_printf ("Debug output disabled\n");
if (sim_log)
fprintf (sim_log, "Debug output disabled\n");
}
return SCPE_OK; return SCPE_OK;
} }
@ -1493,12 +1465,10 @@ if (sim_con_ldsc.conn || sim_con_ldsc.txbfd) { /* connected or buffered
tmxr_poll_rx (&sim_con_tmxr); /* poll (check disconn) */ tmxr_poll_rx (&sim_con_tmxr); /* poll (check disconn) */
if (sim_con_ldsc.conn || sim_con_ldsc.txbfd) { /* still connected? */ if (sim_con_ldsc.conn || sim_con_ldsc.txbfd) { /* still connected? */
if (!sim_con_ldsc.conn) { if (!sim_con_ldsc.conn) {
printf ("Running with Buffered Console\r\n"); /* print transition */ sim_printf ("Running with Buffered Console\r\n"); /* print transition */
fflush (stdout); fflush (stdout);
if (sim_log) { /* log file? */ if (sim_log) /* log file? */
fprintf (sim_log, "Running with Buffered Console\n");
fflush (sim_log); fflush (sim_log);
}
} }
return SCPE_OK; return SCPE_OK;
} }
@ -1507,12 +1477,10 @@ for (i = 0; i < sec; i++) { /* loop */
if (tmxr_poll_conn (&sim_con_tmxr) >= 0) { /* poll connect */ if (tmxr_poll_conn (&sim_con_tmxr) >= 0) { /* poll connect */
sim_con_ldsc.rcve = 1; /* rcv enabled */ sim_con_ldsc.rcve = 1; /* rcv enabled */
if (i) { /* if delayed */ if (i) { /* if delayed */
printf ("Running\r\n"); /* print transition */ sim_printf ("Running\r\n"); /* print transition */
fflush (stdout); fflush (stdout);
if (sim_log) { /* log file? */ if (sim_log) /* log file? */
fprintf (sim_log, "Running\n");
fflush (sim_log); fflush (sim_log);
}
} }
return SCPE_OK; /* ready to proceed */ return SCPE_OK; /* ready to proceed */
} }
@ -1520,12 +1488,10 @@ for (i = 0; i < sec; i++) { /* loop */
if ((c == SCPE_STOP) || stop_cpu) if ((c == SCPE_STOP) || stop_cpu)
return SCPE_STOP; return SCPE_STOP;
if ((i % 10) == 0) { /* Status every 10 sec */ if ((i % 10) == 0) { /* Status every 10 sec */
printf ("Waiting for console Telnet connection\r\n"); sim_printf ("Waiting for console Telnet connection\r\n");
fflush (stdout); fflush (stdout);
if (sim_log) { /* log file? */ if (sim_log) /* log file? */
fprintf (sim_log, "Waiting for console Telnet connection\n");
fflush (sim_log); fflush (sim_log);
}
} }
sim_os_sleep (1); /* wait 1 second */ sim_os_sleep (1); /* wait 1 second */
} }