From c6de567cf638cef2537749eaa74c905e6a1235a8 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 4 Apr 2024 10:10:47 -1000 Subject: [PATCH] All VAXen: Add -O option to SET HISTORY logging to file - Extend maximum instruction history to 2 million - -O option in history logging to a file allows only capturing at most the last n instructions written to a log file. Otherwise, the default is to log all executed instructions to the log file which will consume prodigious amounts of storage. --- VAX/vax_cpu.c | 27 +++++++++++++++++++-------- VAX/vax_defs.h | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/VAX/vax_cpu.c b/VAX/vax_cpu.c index 3be7f0cf..b9a2a49b 100644 --- a/VAX/vax_cpu.c +++ b/VAX/vax_cpu.c @@ -1587,7 +1587,7 @@ for ( ;; ) { if (hst_p >= hst_lnt) hst_p = 0; if (hst_log && (hst_p == hst_log_p)) /* File Logging and Full, then write all records*/ - cpu_show_hist_records (hst_log, FALSE, hst_log_p, hst_lnt); + cpu_show_hist_records (hst_log, ((hst_switches & SWMASK('O')) != 0), hst_log_p, hst_lnt); } /* Dispatch to instructions */ @@ -3536,6 +3536,7 @@ t_stat r; if (cptr == NULL) { /* Clear History */ if (hst_log) { sim_set_fsize (hst_log, (t_addr)0); + rewind (hst_log); hst_log_p = 0; cpu_show_hist_records (hst_log, TRUE, 0, 0); } @@ -3611,6 +3612,10 @@ InstHistory *h; if (hst_lnt == 0) /* enabled? */ return SCPE_NOFNC; if (do_header) { + if (hst_switches & SWMASK('O')) { + sim_set_fsize (hst_log, (t_addr)0); + rewind (hst_log); + } if (hst_switches & SWMASK('T')) fprintf (st," TIME "); fprintf (st, "PC PSL IR\n\n"); @@ -4010,16 +4015,22 @@ fprintf (st, "indicats the number of seconds which the simulator must run before fprintf (st, "starts.\n\n"); fprintf (st, "The CPU can maintain a history of the most recently executed instructions.\n"); fprintf (st, "This is controlled by the SET CPU HISTORY and SHOW CPU HISTORY commands:\n\n"); -fprintf (st, " sim> SET CPU HISTORY clear history buffer\n"); -fprintf (st, " sim> SET CPU HISTORY=0 disable history\n"); -fprintf (st, " sim> SET CPU {-T} HISTORY=n{:file} enable history, length = n\n"); -fprintf (st, " sim> SHOW CPU HISTORY print CPU history\n"); -fprintf (st, " sim> SHOW CPU HISTORY=n print most recent n entries of history\n\n"); +fprintf (st, " sim> SET CPU HISTORY clear history buffer\n"); +fprintf (st, " sim> SET CPU HISTORY=0 disable history\n"); +fprintf (st, " sim> SET CPU {-T} {-O} HISTORY=n{:file} enable history, length = n\n"); +fprintf (st, " sim> SHOW CPU HISTORY print CPU history\n"); +fprintf (st, " sim> SHOW CPU HISTORY=n print most recent n entries of\n"); +fprintf (st, " history\n\n"); fprintf (st, "The -T switch causes simulator time to be recorded (and displayed)\n"); -fprintf (st, "with each history entry.\n"); +fprintf (st, "with each history entry. This may be useful when correlating history\n"); +fprintf (st, "with debug output.\n"); fprintf (st, "When writing history to a file (SET CPU HISTORY=n:file), 'n' specifies\n"); fprintf (st, "the buffer flush frequency. Warning: prodigious amounts of disk space\n"); -fprintf (st, "may be comsumed. The maximum length for the history is %d entries.\n\n", HIST_MAX); +fprintf (st, "may be comsumed.\n"); +fprintf (st, "Consumption of prodigious amounts of disk space can be avoided, if the\n"); +fprintf (st, "-O switch is specified which will cause each buffer flush to overwrite\n"); +fprintf (st, "any previously output history.\n"); +fprintf (st, "The maximum length for the history is %d entries.\n\n", HIST_MAX); fprintf (st, "Different VAX systems implemented different VAX architecture instructions\n"); fprintf (st, "in hardware with other instructions possibly emulated by software in the\n"); fprintf (st, "system. The instructions that a particular simulator implements can be\n"); diff --git a/VAX/vax_defs.h b/VAX/vax_defs.h index ec8cab9c..96610df1 100644 --- a/VAX/vax_defs.h +++ b/VAX/vax_defs.h @@ -847,7 +847,7 @@ void cpu_idle (void); /* Instruction History */ #define HIST_MIN 64 -#define HIST_MAX 250000 +#define HIST_MAX 2000000 #define OPND_SIZE 16 #define INST_SIZE 52