1
0
mirror of https://github.com/simh/simh.git synced 2026-01-25 19:56:25 +00:00

ALL simulators with instruction history support: Minor history enhancements

- Issue reasonable error message explaining invalid SET CPU HISTORY=n input
- Let SIGINT (^C) abort SHOW HISTORY output
This commit is contained in:
Mark Pizzolato
2023-12-04 10:57:31 -10:00
parent 42d6f414fc
commit 6d376b2fd9
29 changed files with 245 additions and 74 deletions

View File

@@ -1768,7 +1768,10 @@ if (cptr == NULL) {
return SCPE_OK;
}
lnt = (uint32) get_uint (cptr, 10, HIST_MAX, &r);
if ((r != SCPE_OK) || (lnt && (lnt < HIST_MIN))) return SCPE_ARG;
if (r != SCPE_OK)
return sim_messagef (SCPE_ARG, "Invalid Numeric Value: %s. Maximum is %d\n", cptr, HIST_MAX);
if (lnt && (lnt < HIST_MIN))
return sim_messagef (SCPE_ARG, "%d is less than the minumum history value of %d\n", lnt, HIST_MIN);
hst_p = 0;
if (hst_lnt) {
free (hst);
@@ -1847,13 +1850,18 @@ InstHistory *h;
if (hst_lnt == 0) return SCPE_NOFNC; /* enabled? */
if (cptr) {
lnt = (int32) get_uint (cptr, 10, hst_lnt, &r);
if ((r != SCPE_OK) || (lnt == 0)) return SCPE_ARG;
if ((r != SCPE_OK) || (lnt == 0))
return sim_messagef (SCPE_ARG, "Invalid count specifier: %s, max is %d\n", cptr, hst_lnt);
}
else lnt = hst_lnt;
di = hst_p - lnt; /* work forward */
if (di < 0) di = di + hst_lnt;
fprintf (st, "PC Ra Rb IR\n\n");
for (k = 0; k < lnt; k++) { /* print specified */
if (stop_cpu) { /* Control-C (SIGINT) */
stop_cpu = FALSE;
break; /* abandon remaining output */
}
h = &hst[(++di) % hst_lnt]; /* entry pointer */
if (h->pc & HIST_PC) { /* instruction? */
cpu_fprint_one_inst (st, h->ir, h->pc, h->ra, h->rb);