SCP: Added detailed help (including switches) for SET DEBUG command and an auto flush of the debug output when instruction execution stops.

This commit is contained in:
Mark Pizzolato 2014-02-04 15:45:26 -08:00
parent 8cc3791e2a
commit da134ebb2a
3 changed files with 54 additions and 8 deletions

24
scp.c
View file

@ -953,10 +953,31 @@ static const char simh_help[] =
"++++++++ (STDOUT,DEBUG or filename)\n"
"+set nolog disables any currently active logging\n"
#define HLP_SET_DEBUG "*Commands SET Debug"
/***************** 80 character line width template *************************/
"3Debug\n"
"+set debug debug_file specify the debug destination\n"
"++++++++ (STDOUT,STDERR,LOG or filename)\n"
"+set nodebug disables any currently active debug output\n"
"4Switches\n"
" Debug message output contains a timestamp which indicates the number of\n"
" simulated instructions which have been executed prior to the debug event.\n\n"
" Debug message output can be enhanced to contain additional, potentially\n"
" useful information.\n"
"5-T\n"
" The -T switch causes debug output to contain a time of day displayed\n"
" as hh:mm:ss.msec.\n"
"5-A\n"
" The -A switch causes debug output to contain a time of day displayed\n"
" as seconds.msec.\n"
"5-R\n"
" The -R switch causes the time of day displayed due to the -T or -A\n"
" switches to be relative to the start time of debugging. If neither\n"
" -T or -A is explicitly specified, -T is implied.\n"
"5-P\n"
" The -P switch adds the output of the PC register variable to each debug\n"
" message. This may not be useful on all simulators if they either don't\n"
" have a register called PC, or if the PC register variable is actually\n"
" constructed from several different internal variables.\n"
#define HLP_SET_BREAK "*Commands SET Breakpoints"
"3Breakpoints\n"
"+set break <list> set breakpoints\n"
@ -1052,6 +1073,7 @@ static const char simh_help[] =
"+sh{ow} serial show serial devices\n"
"+sh{ow} multiplexer show open multiplexer devices\n"
"+sh{ow} clocks show calibrated timers\n"
"+sh{ow} throttle show throttle info\n"
"+sh{ow} on show on condition actions\n"
"+h{elp} <dev> show displays the device specific show commands\n"
"++++++++ available\n"
@ -5306,7 +5328,7 @@ signal (SIGTERM, SIG_DFL); /* cancel WRU */
if (sim_log) /* flush console log */
fflush (sim_log);
if (sim_deb) /* flush debug log */
fflush (sim_deb);
sim_debug_flush ();
for (i = 1; (dptr = sim_devices[i]) != NULL; i++) { /* flush attached files */
for (j = 0; j < dptr->numunits; j++) { /* if not buffered in mem */
uptr = dptr->units + j;

View file

@ -1084,30 +1084,53 @@ if (!sim_quiet) {
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);
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);
}
time(&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);
return SCPE_OK;
}
t_stat sim_debug_flush (void)
{
int32 saved_quiet = sim_quiet;
int32 saved_sim_switches = sim_switches;
int32 saved_deb_switches = sim_deb_switches;
struct timespec saved_deb_basetime = sim_deb_basetime;
char saved_debug_filename[CBUFSIZE];
if (sim_deb == NULL) /* no debug? */
return SCPE_OK;
strcpy (saved_debug_filename, sim_logfile_name (sim_deb, sim_deb_ref));
sim_quiet = 1;
sim_set_deboff (0, NULL);
sim_switches = saved_deb_switches;
sim_set_debon (0, saved_debug_filename);
sim_deb_basetime = saved_deb_basetime;
sim_switches = saved_sim_switches;
return SCPE_OK;
}
/* Set nodebug routine */
t_stat sim_set_deboff (int32 flag, char *cptr)
{
if (cptr && (*cptr != 0)) /* now eol? */
return SCPE_2MARG;
if (sim_deb == NULL) /* no log? */
if (sim_deb == NULL) /* no debug? */
return SCPE_OK;
sim_close_logfile (&sim_deb_ref);
sim_deb = NULL;
sim_deb_switches = 0;
sim_deb_PC = NULL;
if (!sim_quiet)
if (!sim_quiet) {
printf ("Debug output disabled\n");
if (sim_log)
if (sim_log)
fprintf (sim_log, "Debug output disabled\n");
}
return SCPE_OK;
}

View file

@ -68,6 +68,7 @@ t_stat sim_set_cons_unbuff (int32 flg, char *cptr);
t_stat sim_set_cons_log (int32 flg, char *cptr);
t_stat sim_set_cons_nolog (int32 flg, char *cptr);
t_stat sim_set_deboff (int32 flag, char *cptr);
t_stat sim_debug_flush (void);
t_stat sim_set_pchar (int32 flag, char *cptr);
t_stat sim_show_console (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
t_stat sim_show_remote_console (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);