Merge remote-tracking branch 'github-simh/master'
This commit is contained in:
commit
0bc76f59b9
4 changed files with 111 additions and 23 deletions
79
scp.c
79
scp.c
|
@ -476,6 +476,9 @@ FILE *sim_log = NULL; /* log file */
|
||||||
FILEREF *sim_log_ref = NULL; /* log file file reference */
|
FILEREF *sim_log_ref = NULL; /* log file file reference */
|
||||||
FILE *sim_deb = NULL; /* debug file */
|
FILE *sim_deb = NULL; /* debug file */
|
||||||
FILEREF *sim_deb_ref = NULL; /* debug file file reference */
|
FILEREF *sim_deb_ref = NULL; /* debug file file reference */
|
||||||
|
int32 sim_deb_switches = 0; /* debug switches */
|
||||||
|
REG *sim_deb_PC = NULL; /* debug PC register pointer */
|
||||||
|
struct timespec sim_deb_basetime; /* debug timestamp relative base time */
|
||||||
char *sim_prompt = NULL; /* prompt string */
|
char *sim_prompt = NULL; /* prompt string */
|
||||||
static FILE *sim_gotofile; /* the currently open do file */
|
static FILE *sim_gotofile; /* the currently open do file */
|
||||||
static int32 sim_goto_line[MAX_DO_NEST_LVL+1]; /* the current line number in the currently open do file */
|
static int32 sim_goto_line[MAX_DO_NEST_LVL+1]; /* the current line number in the currently open do file */
|
||||||
|
@ -2289,15 +2292,19 @@ if ((dptr = find_dev (gbuf))) { /* device match? */
|
||||||
uptr = dptr->units; /* first unit */
|
uptr = dptr->units; /* first unit */
|
||||||
ctbr = set_dev_tab; /* global table */
|
ctbr = set_dev_tab; /* global table */
|
||||||
lvl = MTAB_VDV; /* device match */
|
lvl = MTAB_VDV; /* device match */
|
||||||
|
GET_SWITCHES (cptr); /* get more switches */
|
||||||
}
|
}
|
||||||
else if ((dptr = find_unit (gbuf, &uptr))) { /* unit match? */
|
else if ((dptr = find_unit (gbuf, &uptr))) { /* unit match? */
|
||||||
if (uptr == NULL) /* invalid unit */
|
if (uptr == NULL) /* invalid unit */
|
||||||
return SCPE_NXUN;
|
return SCPE_NXUN;
|
||||||
ctbr = set_unit_tab; /* global table */
|
ctbr = set_unit_tab; /* global table */
|
||||||
lvl = MTAB_VUN; /* unit match */
|
lvl = MTAB_VUN; /* unit match */
|
||||||
|
GET_SWITCHES (cptr); /* get more switches */
|
||||||
}
|
}
|
||||||
else if ((gcmdp = find_ctab (set_glob_tab, gbuf))) /* global? */
|
else if ((gcmdp = find_ctab (set_glob_tab, gbuf))) { /* global? */
|
||||||
|
GET_SWITCHES (cptr); /* get more switches */
|
||||||
return gcmdp->action (gcmdp->arg, cptr); /* do the rest */
|
return gcmdp->action (gcmdp->arg, cptr); /* do the rest */
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (sim_dflt_dev->modifiers)
|
if (sim_dflt_dev->modifiers)
|
||||||
for (mptr = sim_dflt_dev->modifiers; mptr->mask != 0; mptr++) {
|
for (mptr = sim_dflt_dev->modifiers; mptr->mask != 0; mptr++) {
|
||||||
|
@ -2314,6 +2321,7 @@ else {
|
||||||
}
|
}
|
||||||
if (*cptr == 0) /* must be more */
|
if (*cptr == 0) /* must be more */
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
|
GET_SWITCHES (cptr); /* get more switches */
|
||||||
|
|
||||||
while (*cptr != 0) { /* do all mods */
|
while (*cptr != 0) { /* do all mods */
|
||||||
cptr = get_glyph (svptr = cptr, gbuf, ','); /* get modifier */
|
cptr = get_glyph (svptr = cptr, gbuf, ','); /* get modifier */
|
||||||
|
@ -6103,7 +6111,7 @@ return val;
|
||||||
have been generated.
|
have been generated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
t_stat fprint_val (FILE *stream, t_value val, uint32 radix,
|
t_stat sprint_val (char *buffer, t_value val, uint32 radix,
|
||||||
uint32 width, uint32 format)
|
uint32 width, uint32 format)
|
||||||
{
|
{
|
||||||
#define MAX_WIDTH ((int) ((CHAR_BIT * sizeof (t_value) * 4 + 3)/3))
|
#define MAX_WIDTH ((int) ((CHAR_BIT * sizeof (t_value) * 4 + 3)/3))
|
||||||
|
@ -6137,9 +6145,9 @@ switch (format) {
|
||||||
dbuf[MAX_WIDTH - (digit * 4)] = ',';
|
dbuf[MAX_WIDTH - (digit * 4)] = ',';
|
||||||
d = d - commas;
|
d = d - commas;
|
||||||
if (width > MAX_WIDTH) {
|
if (width > MAX_WIDTH) {
|
||||||
if (!stream)
|
if (!buffer)
|
||||||
return width;
|
return width;
|
||||||
fprintf (stream, "%*s", -((int)width), dbuf);
|
sprintf (buffer, "%*s", -((int)width), dbuf);
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -6159,9 +6167,26 @@ switch (format) {
|
||||||
d = MAX_WIDTH - (ndigits + commas);
|
d = MAX_WIDTH - (ndigits + commas);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!stream)
|
if (!buffer)
|
||||||
return strlen(dbuf+d);
|
return strlen(dbuf+d);
|
||||||
if (fputs (&dbuf[d], stream) == EOF)
|
if (width < strlen(dbuf+d))
|
||||||
|
return SCPE_IOERR;
|
||||||
|
strcpy(buffer, dbuf+d);
|
||||||
|
return SCPE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
t_stat fprint_val (FILE *stream, t_value val, uint32 radix,
|
||||||
|
uint32 width, uint32 format)
|
||||||
|
{
|
||||||
|
char dbuf[MAX_WIDTH + 1];
|
||||||
|
t_stat r;
|
||||||
|
|
||||||
|
if (!stream)
|
||||||
|
return sprint_val (NULL, val, radix, width, format);
|
||||||
|
if (width > MAX_WIDTH)
|
||||||
|
width = MAX_WIDTH;
|
||||||
|
r = sprint_val (dbuf, val, radix, width, format);
|
||||||
|
if (fputs (dbuf, stream) == EOF)
|
||||||
return SCPE_IOERR;
|
return SCPE_IOERR;
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
@ -6844,7 +6869,7 @@ return SCPE_OK;
|
||||||
/* Debug printout routines, from Dave Hittner */
|
/* Debug printout routines, from Dave Hittner */
|
||||||
|
|
||||||
const char* debug_bstates = "01_^";
|
const char* debug_bstates = "01_^";
|
||||||
const char* debug_fmt = "DBG(%.0f)%s> %s %s: ";
|
char debug_line_prefix[256];
|
||||||
int32 debug_unterm = 0;
|
int32 debug_unterm = 0;
|
||||||
|
|
||||||
/* Finds debug phrase matching bitmask from from device DEBTAB table */
|
/* Finds debug phrase matching bitmask from from device DEBTAB table */
|
||||||
|
@ -6870,12 +6895,35 @@ return debtab_nomatch;
|
||||||
|
|
||||||
/* Prints standard debug prefix unless previous call unterminated */
|
/* Prints standard debug prefix unless previous call unterminated */
|
||||||
|
|
||||||
static void sim_debug_prefix (uint32 dbits, DEVICE* dptr)
|
static const char *sim_debug_prefix (uint32 dbits, DEVICE* dptr)
|
||||||
{
|
{
|
||||||
if (!debug_unterm) {
|
|
||||||
char* debug_type = get_dbg_verb (dbits, dptr);
|
char* debug_type = get_dbg_verb (dbits, dptr);
|
||||||
fprintf(sim_deb, debug_fmt, sim_gtime(), AIO_MAIN_THREAD ? "" : "+", dptr->name, debug_type);
|
static const char* debug_fmt = "DBG(%.0f)%s> %s %s: ";
|
||||||
|
char tim_t[32] = "";
|
||||||
|
char tim_a[32] = "";
|
||||||
|
char pc_s[64] = "";
|
||||||
|
struct timespec time_now;
|
||||||
|
|
||||||
|
if (sim_deb_switches & (SWMASK ('T') | SWMASK ('R') | SWMASK ('A'))) {
|
||||||
|
clock_gettime(CLOCK_REALTIME, &time_now);
|
||||||
|
if (sim_deb_switches & SWMASK ('R'))
|
||||||
|
sim_timespec_diff (&time_now, &time_now, &sim_deb_basetime);
|
||||||
}
|
}
|
||||||
|
if (sim_deb_switches & SWMASK ('T')) {
|
||||||
|
struct tm *now = gmtime(&time_now.tv_sec);
|
||||||
|
|
||||||
|
sprintf(tim_t, "%02d:%02d:%02d.%03d ", now->tm_hour, now->tm_min, now->tm_sec, (int)(time_now.tv_nsec/1000000));
|
||||||
|
}
|
||||||
|
if (sim_deb_switches & SWMASK ('A')) {
|
||||||
|
sprintf(tim_t, "%lld.%03d ", (long long)(time_now.tv_sec), (int)(time_now.tv_nsec/1000000));
|
||||||
|
}
|
||||||
|
if (sim_deb_switches & SWMASK ('P')) {
|
||||||
|
t_value val = get_rval (sim_deb_PC, 0);
|
||||||
|
sprintf(pc_s, "-%s:", sim_deb_PC->name);
|
||||||
|
sprint_val (&pc_s[strlen(pc_s)], val, sim_deb_PC->radix, sim_deb_PC->width, sim_deb_PC->flags & REG_FMT);
|
||||||
|
}
|
||||||
|
sprintf(debug_line_prefix, "DBG(%s%s%.0f%s)%s> %s %s: ", tim_t, tim_a, sim_gtime(), pc_s, AIO_MAIN_THREAD ? "" : "+", dptr->name, debug_type);
|
||||||
|
return debug_line_prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fprint_fields (FILE *stream, t_value before, t_value after, BITFIELD* bitdefs)
|
void fprint_fields (FILE *stream, t_value before, t_value after, BITFIELD* bitdefs)
|
||||||
|
@ -6927,7 +6975,7 @@ void sim_debug_bits(uint32 dbits, DEVICE* dptr, BITFIELD* bitdefs,
|
||||||
uint32 before, uint32 after, int terminate)
|
uint32 before, uint32 after, int terminate)
|
||||||
{
|
{
|
||||||
if (sim_deb && (dptr->dctrl & dbits)) {
|
if (sim_deb && (dptr->dctrl & dbits)) {
|
||||||
sim_debug_prefix(dbits, dptr); /* print prefix if required */
|
fprintf(sim_deb, "%s", sim_debug_prefix(dbits, dptr)); /* print prefix if required */
|
||||||
fprint_fields (sim_deb, (t_value)before, (t_value)after, bitdefs); /* print xlation, transition */
|
fprint_fields (sim_deb, (t_value)before, (t_value)after, bitdefs); /* print xlation, transition */
|
||||||
if (terminate)
|
if (terminate)
|
||||||
fprintf(sim_deb, "\r\n");
|
fprintf(sim_deb, "\r\n");
|
||||||
|
@ -6954,6 +7002,7 @@ if (sim_deb && (dptr->dctrl & dbits)) {
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
int32 i, j, len;
|
int32 i, j, len;
|
||||||
char* debug_type = get_dbg_verb (dbits, dptr);
|
char* debug_type = get_dbg_verb (dbits, dptr);
|
||||||
|
const char* debug_prefix = sim_debug_prefix(dbits, dptr); /* prefix to print if required */
|
||||||
|
|
||||||
buf[bufsize-1] = '\0';
|
buf[bufsize-1] = '\0';
|
||||||
|
|
||||||
|
@ -7005,9 +7054,7 @@ if (sim_deb && (dptr->dctrl & dbits)) {
|
||||||
if (debug_unterm)
|
if (debug_unterm)
|
||||||
fprintf (sim_deb, "%.*s\r\n", i-j, &buf[j]);
|
fprintf (sim_deb, "%.*s\r\n", i-j, &buf[j]);
|
||||||
else /* print prefix when required */
|
else /* print prefix when required */
|
||||||
fprintf (sim_deb, "DBG(%.0f)%s> %s %s: %.*s\r\n", sim_gtime(),
|
fprintf (sim_deb, "%s%.*s\r\n", debug_prefix, i-j, &buf[j]);
|
||||||
AIO_MAIN_THREAD ? "" : "+",
|
|
||||||
dptr->name, debug_type, i-j, &buf[j]);
|
|
||||||
debug_unterm = 0;
|
debug_unterm = 0;
|
||||||
}
|
}
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
|
@ -7017,9 +7064,7 @@ if (sim_deb && (dptr->dctrl & dbits)) {
|
||||||
if (debug_unterm)
|
if (debug_unterm)
|
||||||
fprintf (sim_deb, "%.*s", i-j, &buf[j]);
|
fprintf (sim_deb, "%.*s", i-j, &buf[j]);
|
||||||
else /* print prefix when required */
|
else /* print prefix when required */
|
||||||
fprintf (sim_deb, "DBG(%.0f)%s> %s %s: %.*s", sim_gtime(),
|
fprintf (sim_deb, "DBG(%.0f)%s> %s %s: %.*s", debug_prefix, i-j, &buf[j]);
|
||||||
AIO_MAIN_THREAD ? "" : "+",
|
|
||||||
dptr->name, debug_type, i-j, &buf[j]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set unterminated flag for next time */
|
/* Set unterminated flag for next time */
|
||||||
|
|
3
scp.h
3
scp.h
|
@ -166,6 +166,9 @@ extern FILE *sim_log; /* log file */
|
||||||
extern FILEREF *sim_log_ref; /* log file file reference */
|
extern FILEREF *sim_log_ref; /* log file file reference */
|
||||||
extern FILE *sim_deb; /* debug file */
|
extern FILE *sim_deb; /* debug file */
|
||||||
extern FILEREF *sim_deb_ref; /* debug file file reference */
|
extern FILEREF *sim_deb_ref; /* debug file file reference */
|
||||||
|
extern int32 sim_deb_switches; /* debug display flags */
|
||||||
|
extern struct timespec sim_deb_basetime; /* debug base time for relative time output */
|
||||||
|
extern REG *sim_deb_PC; /* debug PC register */
|
||||||
extern UNIT *sim_clock_queue;
|
extern UNIT *sim_clock_queue;
|
||||||
extern int32 sim_is_running;
|
extern int32 sim_is_running;
|
||||||
extern char *sim_prompt; /* prompt string */
|
extern char *sim_prompt; /* prompt string */
|
||||||
|
|
|
@ -986,6 +986,7 @@ t_stat sim_set_logon (int32 flag, char *cptr)
|
||||||
{
|
{
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
t_stat r;
|
t_stat r;
|
||||||
|
time_t now;
|
||||||
|
|
||||||
if ((cptr == NULL) || (*cptr == 0)) /* need arg */
|
if ((cptr == NULL) || (*cptr == 0)) /* need arg */
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
|
@ -1001,6 +1002,8 @@ if (!sim_quiet)
|
||||||
sim_logfile_name (sim_log, sim_log_ref));
|
sim_logfile_name (sim_log, sim_log_ref));
|
||||||
fprintf (sim_log, "Logging to file \"%s\"\n",
|
fprintf (sim_log, "Logging to file \"%s\"\n",
|
||||||
sim_logfile_name (sim_log, sim_log_ref)); /* start of log */
|
sim_logfile_name (sim_log, sim_log_ref)); /* start of log */
|
||||||
|
time(&now);
|
||||||
|
fprintf (sim_log, "Logging to file \"%s\" at %s", sim_logfile_name (sim_log, sim_log_ref), ctime(&now));
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1039,7 +1042,9 @@ t_stat sim_set_debon (int32 flag, char *cptr)
|
||||||
{
|
{
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
t_stat r;
|
t_stat r;
|
||||||
|
time_t now;
|
||||||
|
|
||||||
|
sim_deb_switches = sim_switches; /* save debug switches */
|
||||||
if ((cptr == NULL) || (*cptr == 0)) /* need arg */
|
if ((cptr == NULL) || (*cptr == 0)) /* need arg */
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
cptr = get_glyph_nc (cptr, gbuf, 0); /* get file name */
|
cptr = get_glyph_nc (cptr, gbuf, 0); /* get file name */
|
||||||
|
@ -1049,12 +1054,37 @@ r = sim_open_logfile (gbuf, FALSE, &sim_deb, &sim_deb_ref);
|
||||||
|
|
||||||
if (r != SCPE_OK)
|
if (r != SCPE_OK)
|
||||||
return r;
|
return r;
|
||||||
if (!sim_quiet)
|
|
||||||
|
if (sim_deb_switches & SWMASK ('R')) {
|
||||||
|
clock_gettime(CLOCK_REALTIME, &sim_deb_basetime);
|
||||||
|
if (!(sim_deb_switches & (SWMASK ('A') || SWMASK ('T'))))
|
||||||
|
sim_deb_switches |= SWMASK ('T');
|
||||||
|
}
|
||||||
|
if (sim_deb_switches & SWMASK ('P'))
|
||||||
|
sim_deb_PC = find_reg ("PC", NULL, sim_dflt_dev);
|
||||||
|
if (!sim_quiet) {
|
||||||
printf ("Debug output to \"%s\"\n",
|
printf ("Debug output to \"%s\"\n",
|
||||||
sim_logfile_name (sim_deb, sim_deb_ref));
|
sim_logfile_name (sim_deb, sim_deb_ref));
|
||||||
if (sim_log)
|
if (sim_deb_switches & SWMASK ('P'))
|
||||||
|
printf (" Debug messages contain current PC value\n");
|
||||||
|
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" : "");
|
||||||
|
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" : "");
|
||||||
|
}
|
||||||
|
if (sim_log) {
|
||||||
fprintf (sim_log, "Debug output to \"%s\"\n",
|
fprintf (sim_log, "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'))
|
||||||
|
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);
|
||||||
|
fprintf (sim_deb, "Debug output to \"%s\" at %s", sim_logfile_name (sim_deb, sim_deb_ref), ctime(&now));
|
||||||
|
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,6 +1098,8 @@ if (sim_deb == NULL) /* no log? */
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
sim_close_logfile (&sim_deb_ref);
|
sim_close_logfile (&sim_deb_ref);
|
||||||
sim_deb = NULL;
|
sim_deb = NULL;
|
||||||
|
sim_deb_switches = 0;
|
||||||
|
sim_deb_PC = NULL;
|
||||||
if (!sim_quiet)
|
if (!sim_quiet)
|
||||||
printf ("Debug output disabled\n");
|
printf ("Debug output disabled\n");
|
||||||
if (sim_log)
|
if (sim_log)
|
||||||
|
@ -1081,9 +1113,16 @@ t_stat sim_show_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cpt
|
||||||
{
|
{
|
||||||
if (cptr && (*cptr != 0))
|
if (cptr && (*cptr != 0))
|
||||||
return SCPE_2MARG;
|
return SCPE_2MARG;
|
||||||
if (sim_deb)
|
if (sim_deb) {
|
||||||
fprintf (st, "Debug output enabled to \"%s\"\n",
|
fprintf (st, "Debug output enabled 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'))
|
||||||
|
fprintf (st, " Debug messages contain current PC value\n");
|
||||||
|
if (sim_deb_switches & SWMASK ('T'))
|
||||||
|
fprintf (st, " 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 (st, " Debug messages display time of day as seconds.msec%s\n", sim_deb_switches & SWMASK ('R') ? " relative to the start of debugging" : "");
|
||||||
|
}
|
||||||
else fprintf (st, "Debug output disabled\n");
|
else fprintf (st, "Debug output disabled\n");
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,3 +124,4 @@ extern t_bool sim_asynch_timer;
|
||||||
extern DEVICE sim_timer_dev;
|
extern DEVICE sim_timer_dev;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue