From da134ebb2a906b37e51fae625b67f009baad2afe Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 4 Feb 2014 15:45:26 -0800 Subject: [PATCH] SCP: Added detailed help (including switches) for SET DEBUG command and an auto flush of the debug output when instruction execution stops. --- scp.c | 24 +++++++++++++++++++++++- sim_console.c | 37 ++++++++++++++++++++++++++++++------- sim_console.h | 1 + 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/scp.c b/scp.c index 5c1f2327..e254c661 100644 --- a/scp.c +++ b/scp.c @@ -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 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} 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; diff --git a/sim_console.c b/sim_console.c index c7fec1b8..8cc0c9a5 100644 --- a/sim_console.c +++ b/sim_console.c @@ -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) - fprintf (sim_log, "Debug output disabled\n"); + if (sim_log) + fprintf (sim_log, "Debug output disabled\n"); + } return SCPE_OK; } diff --git a/sim_console.h b/sim_console.h index a9d02290..a23068a3 100644 --- a/sim_console.h +++ b/sim_console.h @@ -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);