diff --git a/scp.c b/scp.c index 2620f938..70ef09b1 100644 --- a/scp.c +++ b/scp.c @@ -516,7 +516,7 @@ void int_handler (int signal); t_stat set_prompt (int32 flag, CONST char *cptr); t_stat sim_set_asynch (int32 flag, CONST char *cptr); t_stat sim_set_environment (int32 flag, CONST char *cptr); -static const char *get_dbg_verb (uint32 dbits, DEVICE* dptr); +static const char *get_dbg_verb (uint32 dbits, DEVICE* dptr, UNIT *uptr); /* Global data */ @@ -2152,6 +2152,8 @@ static C1TAB set_dev_tab[] = { static C1TAB set_unit_tab[] = { { "ENABLED", &set_unit_enbdis, 1 }, { "DISABLED", &set_unit_enbdis, 0 }, + { "DEBUG", &set_dev_debug, 2+1 }, + { "NODEBUG", &set_dev_debug, 2+0 }, { NULL, NULL, 0 } }; @@ -2198,6 +2200,7 @@ static SHTAB show_dev_tab[] = { }; static SHTAB show_unit_tab[] = { + { "DEBUG", &show_dev_debug, 1 }, { NULL, NULL, 0 } }; @@ -2674,6 +2677,7 @@ void fprint_set_help_ex (FILE *st, DEVICE *dptr, t_bool silent) MTAB *mptr; DEBTAB *dep; t_bool found = FALSE; +t_bool deb_desc_available = FALSE; char buf[CBUFSIZE], header[CBUFSIZE]; sprintf (header, "\n%s device SET commands:\n\n", dptr->name); @@ -2707,13 +2711,11 @@ if ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) { sprintf (buf, "set %s NODEBUG", sim_dname (dptr)); fprintf (st, "%-30s\tDisables debugging for device %s\n", buf, sim_dname (dptr)); if (dptr->debflags) { - t_bool desc_available = FALSE; - strcpy (buf, ""); fprintf (st, "set %s DEBUG=", sim_dname (dptr)); for (dep = dptr->debflags; dep->name != NULL; dep++) { fprintf (st, "%s%s", ((dep == dptr->debflags) ? "" : ";"), dep->name); - desc_available |= ((dep->desc != NULL) && (dep->desc[0] != '\0')); + deb_desc_available |= ((dep->desc != NULL) && (dep->desc[0] != '\0')); } fprintf (st, "\n"); fprintf (st, "%-30s\tEnables specific debugging for device %s\n", buf, sim_dname (dptr)); @@ -2722,11 +2724,6 @@ if ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) { fprintf (st, "%s%s", ((dep == dptr->debflags) ? "" : ";"), dep->name); fprintf (st, "\n"); fprintf (st, "%-30s\tDisables specific debugging for device %s\n", buf, sim_dname (dptr)); - if (desc_available) { - fprintf (st, "\n*%s device DEBUG settings:\n", sim_dname (dptr)); - for (dep = dptr->debflags; dep->name != NULL; dep++) - fprintf (st, "%4s%-12s%s\n", "", dep->name, dep->desc ? dep->desc : ""); - } } } if ((dptr->modifiers) && (dptr->units) && (dptr->numunits != 1)) { @@ -2736,6 +2733,27 @@ if ((dptr->modifiers) && (dptr->units) && (dptr->numunits != 1)) { fprintf (st, "%-30s\tEnables unit %sn\n", buf, sim_dname (dptr)); sprintf (buf, "set %sn DISABLE", sim_dname (dptr)); fprintf (st, "%-30s\tDisables unit %sn\n", buf, sim_dname (dptr)); + } + if (((dptr->flags & DEV_DEBUG) || (dptr->debflags)) && + ((DEV_TYPE(dptr) == DEV_DISK) || (DEV_TYPE(dptr) == DEV_TAPE))) { + sprintf (buf, "set %sn DEBUG", sim_dname (dptr)); + fprintf (st, "%-30s\tEnables debugging for device unit %sn\n", buf, sim_dname (dptr)); + sprintf (buf, "set %sn NODEBUG", sim_dname (dptr)); + fprintf (st, "%-30s\tDisables debugging for device unit %sn\n", buf, sim_dname (dptr)); + if (dptr->debflags) { + strcpy (buf, ""); + fprintf (st, "set %sn DEBUG=", sim_dname (dptr)); + for (dep = dptr->debflags; dep->name != NULL; dep++) + fprintf (st, "%s%s", ((dep == dptr->debflags) ? "" : ";"), dep->name); + fprintf (st, "\n"); + fprintf (st, "%-30s\tEnables specific debugging for device unit %sn\n", buf, sim_dname (dptr)); + fprintf (st, "set %sn NODEBUG=", sim_dname (dptr)); + for (dep = dptr->debflags; dep->name != NULL; dep++) + fprintf (st, "%s%s", ((dep == dptr->debflags) ? "" : ";"), dep->name); + fprintf (st, "\n"); + fprintf (st, "%-30s\tDisables specific debugging for device unit %sn\n", buf, sim_dname (dptr)); + } + } for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) { if ((!MODMASK(mptr,MTAB_VUN)) && MODMASK(mptr,MTAB_XTD)) @@ -2751,6 +2769,11 @@ if ((dptr->modifiers) && (dptr->units) && (dptr->numunits != 1)) { } } } +if (deb_desc_available) { + fprintf (st, "\n*%s device DEBUG settings:\n", sim_dname (dptr)); + for (dep = dptr->debflags; dep->name != NULL; dep++) + fprintf (st, "%4s%-12s%s\n", "", dep->name, dep->desc ? dep->desc : ""); + } if (!found && !silent) fprintf (st, "No SET help is available for the %s device\n", dptr->name); } @@ -4661,7 +4684,7 @@ while (*cptr != 0) { /* do all mods */ if (cvptr) /* = value? */ return SCPE_ARG; if (uptr->flags & UNIT_DIS) /* disabled? */ - return SCPE_UDIS; + return SCPE_UDIS; if ((mptr->valid) && /* invalid? */ ((r = mptr->valid (uptr, mptr->match, cvptr, mptr->desc)) != SCPE_OK)) return r; @@ -4769,20 +4792,28 @@ else { return SCPE_OK; } -/* Set device debug enabled/disabled routine */ +/* Set device/unit debug enabled/disabled routine */ -t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr) +t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flags, CONST char *cptr) { +int32 flag = flags & 1; +t_bool uflag = ((flags & 2) != 0); char gbuf[CBUFSIZE]; DEBTAB *dep; if ((dptr->flags & DEV_DEBUG) == 0) return SCPE_NOFNC; if (cptr == NULL) { /* no arguments? */ - dptr->dctrl = flag ? (dptr->debflags ? flag : 0xFFFFFFFF) : 0;/* disable/enable w/o table */ + if (uflag) + uptr->dctrl = flag ? (dptr->debflags ? flag : 0xFFFFFFFF) : 0;/* disable/enable w/o table */ + else + dptr->dctrl = flag ? (dptr->debflags ? flag : 0xFFFFFFFF) : 0;/* disable/enable w/o table */ if (flag && dptr->debflags) { /* enable with table? */ for (dep = dptr->debflags; dep->name != NULL; dep++) - dptr->dctrl = dptr->dctrl | dep->mask; /* set all */ + if (uflag) + uptr->dctrl = uptr->dctrl | dep->mask; /* set all */ + else + dptr->dctrl = dptr->dctrl | dep->mask; /* set all */ } return SCPE_OK; } @@ -4793,8 +4824,15 @@ while (*cptr) { for (dep = dptr->debflags; dep->name != NULL; dep++) { if (strcmp (dep->name, gbuf) == 0) { /* match? */ if (flag) - dptr->dctrl = dptr->dctrl | dep->mask; - else dptr->dctrl = dptr->dctrl & ~dep->mask; + if (uflag) + uptr->dctrl = uptr->dctrl | dep->mask; + else + dptr->dctrl = dptr->dctrl | dep->mask; + else + if (uflag) + uptr->dctrl = uptr->dctrl & ~dep->mask; + else + dptr->dctrl = dptr->dctrl & ~dep->mask; break; } } /* end for */ @@ -5407,11 +5445,38 @@ fprintf (st, "Radix=%d\n", dptr->dradix); return SCPE_OK; } -t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr) +t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 uflag, CONST char *cptr) { -int32 any = 0; DEBTAB *dep; +uint32 unit; +int32 any = 0; +if (uflag) { + if ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) { + if (!uptr->dctrl) + return SCPE_OK; + if (dptr->debflags == NULL) + fprintf (st, "%s: Debugging enabled\n", sim_uname (uptr)); + else { + uint32 dctrl = uptr->dctrl; + + for (dep = dptr->debflags; (dctrl != 0) && (dep->name != NULL); dep++) { + if ((dctrl & dep->mask) == dep->mask) { + dctrl &= ~dep->mask; + if (any) + fputc (';', st); + else + fprintf (st, "%s: Debug=", sim_uname (uptr)); + fputs (dep->name, st); + any = 1; + } + } + if (any) + fputc ('\n', st); + } + } + return SCPE_OK; + } if ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) { if (dptr->dctrl == 0) fputs ("Debugging disabled", st); @@ -5432,6 +5497,8 @@ if ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) { } } fputc ('\n', st); + for (unit = 0; unit < dptr->numunits; unit++) + show_dev_debug (st, dptr, &dptr->units[unit], 1, NULL); return SCPE_OK; } else return SCPE_NOFNC; @@ -5718,7 +5785,7 @@ if (dir) { #endif t_offset FileSize; char FileName[PATH_MAX + 1]; - const char *MatchName = 1 + strrchr (cptr, '/');; + const char *MatchName = 1 + strrchr (cptr, '/'); char *p_name; struct tm *local; #if defined (HAVE_GLOB) @@ -9068,17 +9135,23 @@ uint32 i, j; if (uptr == NULL) return NULL; +if (uptr->dptr) + return uptr->dptr; for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { for (j = 0; j < dptr->numunits; j++) { - if (uptr == (dptr->units + j)) + if (uptr == (dptr->units + j)) { + uptr->dptr = dptr; return dptr; + } } } for (i = 0; inumunits; j++) { - if (uptr == (dptr->units + j)) + if (uptr == (dptr->units + j)) { + uptr->dptr = dptr; return dptr; + } } } return NULL; @@ -11142,7 +11215,7 @@ if (exp->buf_size) { free (bstr); } if (exp->dptr && (exp->dbit & exp->dptr->dctrl)) - fprintf (st, " Expect Debugging via: SET %s DEBUG%s%s\n", sim_dname(exp->dptr), exp->dptr->debflags ? "=" : "", exp->dptr->debflags ? get_dbg_verb (exp->dbit, exp->dptr) : ""); + fprintf (st, " Expect Debugging via: SET %s DEBUG%s%s\n", sim_dname(exp->dptr), exp->dptr->debflags ? "=" : "", exp->dptr->debflags ? get_dbg_verb (exp->dbit, exp->dptr, NULL) : ""); fprintf (st, " Match Rules:\n"); if (!*match) return sim_exp_showall (st, exp); @@ -11404,7 +11477,7 @@ if (after) if (delay) fprintf (st, " Default delay between character input is %u instructions\n", after); if (snd->dptr && (snd->dbit & snd->dptr->dctrl)) - fprintf (st, " Send Debugging via: SET %s DEBUG%s%s\n", sim_dname(snd->dptr), snd->dptr->debflags ? "=" : "", snd->dptr->debflags ? get_dbg_verb (snd->dbit, snd->dptr) : ""); + fprintf (st, " Send Debugging via: SET %s DEBUG%s%s\n", sim_dname(snd->dptr), snd->dptr->debflags ? "=" : "", snd->dptr->debflags ? get_dbg_verb (snd->dbit, snd->dptr, NULL) : ""); return SCPE_OK; } @@ -11481,7 +11554,7 @@ int32 debug_unterm = 0; /* Finds debug phrase matching bitmask from from device DEBTAB table */ -static const char *get_dbg_verb (uint32 dbits, DEVICE* dptr) +static const char *get_dbg_verb (uint32 dbits, DEVICE* dptr, UNIT *uptr) { static const char *debtab_none = "DEBTAB_ISNULL"; static const char *debtab_nomatch = "DEBTAB_NOMATCH"; @@ -11491,7 +11564,7 @@ int32 offset = 0; if (dptr->debflags == 0) return debtab_none; -dbits &= dptr->dctrl; /* Look for just the bits that matched */ +dbits &= (dptr->dctrl | (uptr ? uptr->dctrl : 0));/* Look for just the bits that matched */ /* Find matching words for bitmask */ @@ -11507,9 +11580,9 @@ return some_match ? some_match : debtab_nomatch; /* Prints standard debug prefix unless previous call unterminated */ -static const char *sim_debug_prefix (uint32 dbits, DEVICE* dptr) +static const char *sim_debug_prefix (uint32 dbits, DEVICE* dptr, UNIT* uptr) { -const char* debug_type = get_dbg_verb (dbits, dptr); +const char* debug_type = get_dbg_verb (dbits, dptr, uptr); char tim_t[32] = ""; char tim_a[32] = ""; char pc_s[64] = ""; @@ -11602,7 +11675,7 @@ if (sim_deb && dptr && (dptr->dctrl & dbits)) { sim_oline = NULL; /* avoid potential debug to active socket */ if (!debug_unterm) - fprintf(sim_deb, "%s", sim_debug_prefix(dbits, dptr)); /* print prefix if required */ + fprintf(sim_deb, "%s", sim_debug_prefix(dbits, dptr, NULL)); /* print prefix if required */ if (header) fprintf(sim_deb, "%s: ", header); fprint_fields (sim_deb, (t_value)before, (t_value)after, bitdefs); /* print xlation, transition */ @@ -11777,29 +11850,25 @@ return stat | SCPE_NOMESSAGE; Callers should be calling sim_debug() which is a macro defined in scp.h which evaluates the action condition before incurring call overhead. */ -void _sim_debug (uint32 dbits, DEVICE* vdptr, const char* fmt, ...) +static void _sim_vdebug (uint32 dbits, DEVICE* dptr, UNIT *uptr, const char* fmt, va_list arglist) { -DEVICE *dptr = (DEVICE *)vdptr; -if (sim_deb && dptr && (dptr->dctrl & dbits)) { +if (sim_deb && dptr && ((dptr->dctrl | (uptr ? uptr->dctrl : 0)) & dbits)) { TMLN *saved_oline = sim_oline; char stackbuf[STACKBUFSIZE]; int32 bufsize = sizeof(stackbuf); char *buf = stackbuf; - va_list arglist; int32 i, j, len; - const char* debug_prefix = sim_debug_prefix(dbits, dptr); /* prefix to print if required */ + const char* debug_prefix = sim_debug_prefix(dbits, dptr, uptr); /* prefix to print if required */ sim_oline = NULL; /* avoid potential debug to active socket */ buf[bufsize-1] = '\0'; while (1) { /* format passed string, args */ - va_start (arglist, fmt); #if defined(NO_vsnprintf) len = vsprintf (buf, fmt, arglist); #else /* !defined(NO_vsnprintf) */ len = vsnprintf (buf, bufsize-1, fmt, arglist); #endif /* NO_vsnprintf */ - va_end (arglist); /* If the formatted result didn't fit into the buffer, then grow the buffer and try again */ @@ -11847,14 +11916,35 @@ if (sim_deb && dptr && (dptr->dctrl & dbits)) { free (buf); sim_oline = saved_oline; /* restore original socket */ } -return; +} + +void _sim_debug_unit (uint32 dbits, UNIT *uptr, const char* fmt, ...) +{ +DEVICE *dptr = (uptr ? uptr->dptr : NULL); + +if (sim_deb && (((dptr ? dptr->dctrl : 0) | (uptr ? uptr->dctrl : 0)) & dbits)) { + va_list arglist; + va_start (arglist, fmt); + _sim_vdebug (dbits, dptr, uptr, fmt, arglist); + va_end (arglist); + } +} + +void _sim_debug_device (uint32 dbits, DEVICE* dptr, const char* fmt, ...) +{ +if (sim_deb && dptr && (dptr->dctrl & dbits)) { + va_list arglist; + va_start (arglist, fmt); + _sim_vdebug (dbits, dptr, NULL, fmt, arglist); + va_end (arglist); + } } void sim_data_trace(DEVICE *dptr, UNIT *uptr, const uint8 *data, const char *position, size_t len, const char *txt, uint32 reason) { -if (sim_deb && (dptr->dctrl & reason)) { - sim_debug (reason, dptr, "%s %s %slen: %08X\n", sim_uname(uptr), txt, position, (unsigned int)len); +if (sim_deb && ((dptr->dctrl | (uptr ? uptr->dctrl : 0)) & reason)) { + _sim_debug_unit (reason, uptr, "%s %s %slen: %08X\n", sim_uname(uptr), txt, position, (unsigned int)len); if (data && len) { unsigned int i, same, group, sidx, oidx, ridx, eidx, soff; char outbuf[80], strbuf[28], rad50buf[36], ebcdicbuf[32]; @@ -11901,7 +11991,7 @@ if (sim_deb && (dptr->dctrl & reason)) { continue; } if (same > 0) { - sim_debug (reason, dptr, "%04X thru %04X same as above\n", i-(16*same), i-1); + _sim_debug_unit (reason, uptr, "%04X thru %04X same as above\n", i-(16*same), i-1); same = 0; } group = (((len - i) > 16) ? 16 : (len - i)); @@ -11944,10 +12034,10 @@ if (sim_deb && (dptr->dctrl & reason)) { strbuf[soff+sidx] = '\0'; ebcdicbuf[eidx] = '\0'; rad50buf[ridx] = '\0'; - sim_debug (reason, dptr, "%04X%-48s %s%s%s\n", i, outbuf, strbuf, ebcdicbuf, rad50buf); + _sim_debug_unit (reason, uptr, "%04X%-48s %s%s%s\n", i, outbuf, strbuf, ebcdicbuf, rad50buf); } if (same > 0) { - sim_debug (reason, dptr, "%04X thru %04X same as above\n", i-(16*same), (unsigned int)(len-1)); + _sim_debug_unit (reason, uptr, "%04X thru %04X same as above\n", i-(16*same), (unsigned int)(len-1)); } } } diff --git a/scp.h b/scp.h index faa97710..35bb97d2 100644 --- a/scp.h +++ b/scp.h @@ -305,16 +305,23 @@ void sim_debug_bits_hdr (uint32 dbits, DEVICE* dptr, const char *header, BITFIELD* bitdefs, uint32 before, uint32 after, int terminate); void sim_debug_bits (uint32 dbits, DEVICE* dptr, BITFIELD* bitdefs, uint32 before, uint32 after, int terminate); +void _sim_debug_unit (uint32 dbits, UNIT *uptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4); +void _sim_debug_device (uint32 dbits, DEVICE* dptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4); #if defined (__DECC) && defined (__VMS) && (defined (__VAX) || (__DECC_VER < 60590001)) #define CANT_USE_MACRO_VA_ARGS 1 #endif #ifdef CANT_USE_MACRO_VA_ARGS -#define _sim_debug sim_debug +#define _sim_debug_device sim_debug void sim_debug (uint32 dbits, DEVICE* dptr, const char *fmt, ...) GCC_FMT_ATTR(3, 4); +#define _sim_debug_unit sim_debug_unit +void sim_debug_unit (uint32 dbits, DEVICE* dptr, const char *fmt, ...) GCC_FMT_ATTR(3, 4); #else -void _sim_debug (uint32 dbits, DEVICE* dptr, const char *fmt, ...) GCC_FMT_ATTR(3, 4); -#define sim_debug(dbits, dptr, ...) do { if (sim_deb && dptr && ((dptr)->dctrl & (dbits))) _sim_debug (dbits, dptr, __VA_ARGS__);} while (0) +void _sim_debug_unit (uint32 dbits, UNIT *uptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4); +void _sim_debug_device (uint32 dbits, DEVICE* dptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4); +#define sim_debug(dbits, dptr, ...) do { if (sim_deb && dptr && ((dptr)->dctrl & (dbits))) _sim_debug_device (dbits, dptr, __VA_ARGS__);} while (0) +#define sim_debug_unit(dbits, uptr, ...) do { if (sim_deb && uptr && (((uptr)->dctrl | (uptr)->dptr->dctrl) & (dbits))) _sim_debug_unit (dbits, uptr, __VA_ARGS__);} while (0) #endif + void fprint_stopped_gen (FILE *st, t_stat v, REG *pc, DEVICE *dptr); #define SCP_HELP_FLAT (1u << 31) /* Force flat help when prompting is not possible */ #define SCP_HELP_ONECMD (1u << 30) /* Display one topic, do not prompt */ diff --git a/sim_console.c b/sim_console.c index 06a462dd..43208219 100644 --- a/sim_console.c +++ b/sim_console.c @@ -2329,17 +2329,33 @@ if (sim_deb) { 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" : ""); for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { + t_bool unit_debug = FALSE; + uint32 unit; + + for (unit = 0; unit < dptr->numunits; unit++) + if (dptr->units[unit].dctrl) { + unit_debug = TRUE; + break; + } if (!(dptr->flags & DEV_DIS) && ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) && - (dptr->dctrl)) { + ((dptr->dctrl) || unit_debug)) { fprintf (st, "Device: %-6s ", dptr->name); show_dev_debug (st, dptr, NULL, 0, NULL); } } for (i = 0; sim_internal_device_count && (dptr = sim_internal_devices[i]); ++i) { + t_bool unit_debug = FALSE; + uint32 unit; + + for (unit = 0; unit < dptr->numunits; unit++) + if (dptr->units[unit].dctrl) { + unit_debug = TRUE; + break; + } if (!(dptr->flags & DEV_DIS) && ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) && - (dptr->dctrl)) { + ((dptr->dctrl) || unit_debug)) { fprintf (st, "Device: %-6s ", dptr->name); show_dev_debug (st, dptr, NULL, 0, NULL); } diff --git a/sim_defs.h b/sim_defs.h index fd24e958..a51cb7b2 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -580,6 +580,8 @@ struct UNIT { t_bool (*cancel)(UNIT *); double usecs_remaining; /* time balance for long delays */ char *uname; /* Unit name */ + DEVICE *dptr; /* DEVICE linkage (backpointer) */ + uint32 dctrl; /* debug control */ #ifdef SIM_ASYNCH_IO void (*a_check_completion)(UNIT *); t_bool (*a_is_active)(UNIT *); @@ -634,7 +636,7 @@ struct UNIT { #define UNIT_NO_FIO 0000004 /* fileref is NOT a FILE * */ #define UNIT_DISK_CHK 0000010 /* disk data debug checking (sim_disk) */ #define UNIT_TMR_UNIT 0000020 /* Unit registered as a calibrated timer */ -#define UNIT_V_DF_TAPE 5 /* Bit offset for Tape Density reservation */ +#define UNIT_V_DF_TAPE 6 /* Bit offset for Tape Density reservation */ #define UNIT_S_DF_TAPE 3 /* Bits Reserved for Tape Density */ struct BITFIELD { diff --git a/sim_disk.c b/sim_disk.c index 0aaf9c99..024fc7cd 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -132,7 +132,7 @@ if ((!callback) || !ctx->asynch_io) \ pthread_mutex_lock (&ctx->io_lock); \ \ - sim_debug (ctx->dbit, ctx->dptr, \ + sim_debug_unit (ctx->dbit, uptr, \ "sim_disk AIO_CALL(op=%d, unit=%d, lba=0x%X, sects=%d)\n",\ op, (int)(uptr-ctx->dptr->units), _lba, _sects);\ \ @@ -168,7 +168,7 @@ struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; this thread needs to run */ sim_os_set_thread_priority (PRIORITY_ABOVE_NORMAL); -sim_debug (ctx->dbit, ctx->dptr, "_disk_io(unit=%d) starting\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "_disk_io(unit=%d) starting\n", (int)(uptr-ctx->dptr->units)); pthread_mutex_lock (&ctx->io_lock); pthread_cond_signal (&ctx->startup_cond); /* Signal we're ready to go */ @@ -195,7 +195,7 @@ while (ctx->asynch_io) { } pthread_mutex_unlock (&ctx->io_lock); -sim_debug (ctx->dbit, ctx->dptr, "_disk_io(unit=%d) exiting\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "_disk_io(unit=%d) exiting\n", (int)(uptr-ctx->dptr->units)); return NULL; } @@ -216,7 +216,7 @@ static void _disk_completion_dispatch (UNIT *uptr) struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; DISK_PCALLBACK callback = ctx->callback; -sim_debug (ctx->dbit, ctx->dptr, "_disk_completion_dispatch(unit=%d, dop=%d, callback=%p)\n", (int)(uptr-ctx->dptr->units), ctx->io_dop, ctx->callback); +sim_debug_unit (ctx->dbit, uptr, "_disk_completion_dispatch(unit=%d, dop=%d, callback=%p)\n", (int)(uptr-ctx->dptr->units), ctx->io_dop, ctx->callback); if (ctx->io_dop != DOP_DONE) abort(); /* horribly wrong, stop */ @@ -232,7 +232,7 @@ static t_bool _disk_is_active (UNIT *uptr) struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_disk_is_active(unit=%d, dop=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_dop); + sim_debug_unit (ctx->dbit, uptr, "_disk_is_active(unit=%d, dop=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_dop); return (ctx->io_dop != DOP_DONE); } return FALSE; @@ -243,7 +243,7 @@ static t_bool _disk_cancel (UNIT *uptr) struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_disk_cancel(unit=%d, dop=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_dop); + sim_debug_unit (ctx->dbit, uptr, "_disk_cancel(unit=%d, dop=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_dop); if (ctx->asynch_io) { pthread_mutex_lock (&ctx->io_lock); while (ctx->io_dop != DOP_DONE) @@ -386,14 +386,16 @@ return SCPE_OK; t_bool sim_disk_isavailable (UNIT *uptr) { struct disk_context *ctx; +t_bool is_available; if (!(uptr->flags & UNIT_ATT)) /* attached? */ return FALSE; switch (DK_GET_FMT (uptr)) { /* case on format */ case DKUF_F_STD: /* SIMH format */ - return TRUE; + is_available = TRUE; + break; case DKUF_F_VHD: /* VHD format */ - return TRUE; + is_available = TRUE; break; case DKUF_F_RAW: /* Raw Physical Disk Access */ ctx = (struct disk_context *)uptr->disk_ctx; @@ -417,11 +419,14 @@ switch (DK_GET_FMT (uptr)) { /* case on format */ } else ctx->media_removed = 1; - return !ctx->media_removed; + is_available = !ctx->media_removed; break; default: - return FALSE; + is_available = FALSE; + break; } +sim_debug_unit (ctx->dbit, uptr, "sim_disk_isavailable(unit=%d)=%s\n", (int)(uptr-ctx->dptr->units), is_available ? "true" : "false"); +return is_available; } t_bool sim_disk_isavailable_a (UNIT *uptr, DISK_PCALLBACK callback) @@ -481,7 +486,7 @@ return SCPE_NOFNC; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; pthread_attr_t attr; -sim_debug (ctx->dbit, ctx->dptr, "sim_disk_set_async(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_disk_set_async(unit=%d)\n", (int)(uptr-ctx->dptr->units)); ctx->asynch_io = sim_asynch_enabled; ctx->asynch_io_latency = latency; @@ -518,7 +523,7 @@ struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; /* make sure device exists */ if (!ctx) return SCPE_UNATT; -sim_debug (ctx->dbit, ctx->dptr, "sim_disk_clr_async(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_disk_clr_async(unit=%d)\n", (int)(uptr-ctx->dptr->units)); if (ctx->asynch_io) { pthread_mutex_lock (&ctx->io_lock); @@ -543,7 +548,7 @@ uint32 err, tbc; size_t i; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; -sim_debug (ctx->dbit, ctx->dptr, "_sim_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "_sim_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); da = ((t_offset)lba) * ctx->sector_size; tbc = sects * ctx->sector_size; @@ -567,7 +572,7 @@ t_stat r; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; t_seccnt sread = 0; -sim_debug (ctx->dbit, ctx->dptr, "sim_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "sim_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); if ((sects == 1) && /* Single sector reads */ (lba >= (uptr->capac*ctx->capac_factor)/(ctx->sector_size/((ctx->dptr->flags & DEV_SECTORS) ? 512 : 1)))) {/* beyond the end of the disk */ @@ -659,7 +664,7 @@ uint32 err, tbc; size_t i; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; -sim_debug (ctx->dbit, ctx->dptr, "_sim_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "_sim_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); da = ((t_offset)lba) * ctx->sector_size; tbc = sects * ctx->sector_size; @@ -682,7 +687,7 @@ uint32 f = DK_GET_FMT (uptr); t_stat r; uint8 *tbuf = NULL; -sim_debug (ctx->dbit, ctx->dptr, "sim_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "sim_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); if (uptr->dynflags & UNIT_DISK_CHK) { DEVICE *dptr = find_dev_from_unit (uptr); @@ -1553,7 +1558,7 @@ ctx->xfer_element_size = (uint32)xfer_element_size; /* save xfer_element_siz ctx->dptr = dptr; /* save DEVICE pointer */ ctx->dbit = dbit; /* save debug bit */ ctx->media_removed = 0; /* default present */ -sim_debug (ctx->dbit, ctx->dptr, "sim_disk_attach(unit=%d,filename='%s')\n", (int)(uptr-ctx->dptr->units), uptr->filename); +sim_debug_unit (ctx->dbit, uptr, "sim_disk_attach(unit=%d,filename='%s')\n", (int)(uptr-ctx->dptr->units), uptr->filename); ctx->auto_format = auto_format; /* save that we auto selected format */ ctx->storage_sector_size = (uint32)sector_size; /* Default */ if ((sim_switches & SWMASK ('R')) || /* read only? */ @@ -1790,7 +1795,7 @@ if ((uptr == NULL) || !(uptr->flags & UNIT_ATT)) ctx = (struct disk_context *)uptr->disk_ctx; fileref = uptr->fileref; -sim_debug (ctx->dbit, ctx->dptr, "sim_disk_detach(unit=%d,filename='%s')\n", (int)(uptr-ctx->dptr->units), uptr->filename); +sim_debug_unit (ctx->dbit, uptr, "sim_disk_detach(unit=%d,filename='%s')\n", (int)(uptr-ctx->dptr->units), uptr->filename); switch (DK_GET_FMT (uptr)) { /* case on format */ case DKUF_F_STD: /* Simh */ @@ -1966,7 +1971,7 @@ struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; if (!(uptr->flags & UNIT_ATT)) /* attached? */ return SCPE_OK; -sim_debug (ctx->dbit, ctx->dptr, "sim_disk_reset(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_disk_reset(unit=%d)\n", (int)(uptr-ctx->dptr->units)); _sim_disk_io_flush(uptr); AIO_VALIDATE; @@ -2554,7 +2559,7 @@ OVERLAPPED pos; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; long long addr; -sim_debug (ctx->dbit, ctx->dptr, "sim_os_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "sim_os_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); addr = ((long long)lba) * ctx->sector_size; memset (&pos, 0, sizeof (pos)); @@ -2575,7 +2580,7 @@ OVERLAPPED pos; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; long long addr; -sim_debug (ctx->dbit, ctx->dptr, "sim_os_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "sim_os_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); addr = ((long long)lba) * ctx->sector_size; memset (&pos, 0, sizeof (pos)); @@ -2657,7 +2662,7 @@ struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; off_t addr; ssize_t bytesread; -sim_debug (ctx->dbit, ctx->dptr, "sim_os_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "sim_os_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); addr = ((off_t)lba) * ctx->sector_size; bytesread = pread((int)((long)uptr->fileref), buf, sects * ctx->sector_size, addr); @@ -2677,7 +2682,7 @@ struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; off_t addr; ssize_t byteswritten; -sim_debug (ctx->dbit, ctx->dptr, "sim_os_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); +sim_debug_unit (ctx->dbit, uptr, "sim_os_disk_wrsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); addr = ((off_t)lba) * ctx->sector_size; byteswritten = pwrite((int)((long)uptr->fileref), buf, sects * ctx->sector_size, addr); diff --git a/sim_tape.c b/sim_tape.c index 8f2976a5..bc52bd23 100644 --- a/sim_tape.c +++ b/sim_tape.c @@ -178,7 +178,7 @@ if ((!callback) || !ctx->asynch_io) \ pthread_mutex_lock (&ctx->io_lock); \ \ - sim_debug (ctx->dbit, ctx->dptr, \ + sim_debug_unit (ctx->dbit, uptr, \ "sim_tape AIO_CALL(op=%d, unit=%d)\n", op, (int)(uptr-ctx->dptr->units));\ \ if (ctx->callback) \ @@ -229,7 +229,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; this thread needs to run */ sim_os_set_thread_priority (PRIORITY_ABOVE_NORMAL); - sim_debug (ctx->dbit, ctx->dptr, "_tape_io(unit=%d) starting\n", (int)(uptr-ctx->dptr->units)); + sim_debug_unit (ctx->dbit, uptr, "_tape_io(unit=%d) starting\n", (int)(uptr-ctx->dptr->units)); pthread_mutex_lock (&ctx->io_lock); pthread_cond_signal (&ctx->startup_cond); /* Signal we're ready to go */ @@ -298,7 +298,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; } pthread_mutex_unlock (&ctx->io_lock); - sim_debug (ctx->dbit, ctx->dptr, "_tape_io(unit=%d) exiting\n", (int)(uptr-ctx->dptr->units)); + sim_debug_unit (ctx->dbit, uptr, "_tape_io(unit=%d) exiting\n", (int)(uptr-ctx->dptr->units)); return NULL; } @@ -317,7 +317,7 @@ static void _tape_completion_dispatch (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; TAPE_PCALLBACK callback = ctx->callback; -sim_debug (ctx->dbit, ctx->dptr, "_tape_completion_dispatch(unit=%d, top=%d, callback=%p)\n", (int)(uptr-ctx->dptr->units), ctx->io_top, ctx->callback); +sim_debug_unit (ctx->dbit, uptr, "_tape_completion_dispatch(unit=%d, top=%d, callback=%p)\n", (int)(uptr-ctx->dptr->units), ctx->io_top, ctx->callback); if (ctx->io_top != TOP_DONE) abort(); /* horribly wrong, stop */ @@ -342,7 +342,7 @@ static t_bool _tape_is_active (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_tape_is_active(unit=%d, top=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_top); + sim_debug_unit (ctx->dbit, uptr, "_tape_is_active(unit=%d, top=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_top); return (ctx->io_top != TOP_DONE); } return FALSE; @@ -353,7 +353,7 @@ static t_bool _tape_cancel (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_tape_cancel(unit=%d, top=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_top); + sim_debug_unit (ctx->dbit, uptr, "_tape_cancel(unit=%d, top=%d)\n", (int)(uptr-ctx->dptr->units), ctx->io_top); if (ctx->asynch_io) { pthread_mutex_lock (&ctx->io_lock); while (ctx->io_top != TOP_DONE) @@ -1174,7 +1174,7 @@ t_stat st; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rdrecf(unit=%d, buf=%p, max=%d)\n", (int)(uptr-ctx->dptr->units), buf, max); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_rdrecf(unit=%d, buf=%p, max=%d)\n", (int)(uptr-ctx->dptr->units), buf, max); opos = uptr->pos; /* old position */ st = sim_tape_rdrlfwd (uptr, &tbc); /* read rec lnt */ @@ -1241,7 +1241,7 @@ t_stat st; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rdrecr(unit=%d, buf=%p, max=%d)\n", (int)(uptr-ctx->dptr->units), buf, max); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_rdrecr(unit=%d, buf=%p, max=%d)\n", (int)(uptr-ctx->dptr->units), buf, max); st = sim_tape_rdrlrev (uptr, &tbc); /* read rec lnt */ if (st != MTSE_OK) @@ -1294,7 +1294,7 @@ t_mtrlnt sbc; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrrecf(unit=%d, buf=%p, bc=%d)\n", (int)(uptr-ctx->dptr->units), buf, bc); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_wrrecf(unit=%d, buf=%p, bc=%d)\n", (int)(uptr-ctx->dptr->units), buf, bc); sim_tape_data_trace(uptr, buf, bc, "Record Write", ctx->dptr->dctrl & MTSE_DBG_DAT, MTSE_DBG_STR); MT_CLR_PNU (uptr); @@ -1377,7 +1377,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrtmk(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_wrtmk(unit=%d)\n", (int)(uptr-ctx->dptr->units)); if (MT_GET_FMT (uptr) == MTUF_F_P7B) { /* P7B? */ uint8 buf = P7B_EOF; /* eof mark */ return sim_tape_wrrecf (uptr, &buf, 1); /* write char */ @@ -1403,7 +1403,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wreom(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_wreom(unit=%d)\n", (int)(uptr-ctx->dptr->units)); if (MT_GET_FMT (uptr) == MTUF_F_P7B) /* cant do P7B */ return MTSE_FMT; @@ -1433,7 +1433,7 @@ t_stat r; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wreomrw(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_wreomrw(unit=%d)\n", (int)(uptr-ctx->dptr->units)); if (MT_GET_FMT (uptr) == MTUF_F_P7B) /* cant do P7B */ return MTSE_FMT; r = sim_tape_wrdata (uptr, MTR_EOM); @@ -1868,7 +1868,7 @@ const uint32 byte_length = (gaplen * density) / 10; /* the size of the reque if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrgap(unit=%d, gaplen=%u)\n", (int)(uptr-ctx->dptr->units), gaplen); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_wrgap(unit=%d, gaplen=%u)\n", (int)(uptr-ctx->dptr->units), gaplen); if (density == 0) /* if the density has not been set */ return MTSE_IOERR; /* then report an I/O error */ @@ -1964,7 +1964,7 @@ t_stat st; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecf(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_sprecf(unit=%d)\n", (int)(uptr-ctx->dptr->units)); st = sim_tape_rdrlfwd (uptr, bc); /* get record length */ *bc = MTR_L (*bc); @@ -2007,7 +2007,7 @@ t_mtrlnt tbc; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecsf(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_sprecsf(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); *skipped = 0; while (*skipped < count) { /* loopo */ @@ -2054,7 +2054,7 @@ t_stat st; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecr(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_sprecr(unit=%d)\n", (int)(uptr-ctx->dptr->units)); if (MT_TST_PNU (uptr)) { MT_CLR_PNU (uptr); @@ -2103,7 +2103,7 @@ t_mtrlnt tbc; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecsr(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_sprecsr(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); *skipped = 0; while (*skipped < count) { /* loopo */ @@ -2154,7 +2154,7 @@ uint32 filerecsskipped; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilebyrecf(unit=%d, count=%d, check_leot=%d)\n", (int)(uptr-ctx->dptr->units), count, check_leot); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_spfilebyrecf(unit=%d, count=%d, check_leot=%d)\n", (int)(uptr-ctx->dptr->units), count, check_leot); if (check_leot) { t_mtrlnt rbc; @@ -2224,7 +2224,7 @@ uint32 totalrecsskipped; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilef(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_spfilef(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); return sim_tape_spfilebyrecf (uptr, count, skipped, &totalrecsskipped, FALSE); } @@ -2267,7 +2267,7 @@ uint32 filerecsskipped; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilebyrecr(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_spfilebyrecr(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); *skipped = 0; *recsskipped = 0; @@ -2322,7 +2322,7 @@ uint32 totalrecsskipped; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfiler(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_spfiler(unit=%d, count=%d)\n", (int)(uptr-ctx->dptr->units), count); return sim_tape_spfilebyrecr (uptr, count, skipped, &totalrecsskipped); } @@ -2345,7 +2345,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (uptr->flags & UNIT_ATT) { if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n");/* that's a problem */ - sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rewind(unit=%d)\n", (int)(uptr-ctx->dptr->units)); + sim_debug_unit (ctx->dbit, uptr, "sim_tape_rewind(unit=%d)\n", (int)(uptr-ctx->dptr->units)); } uptr->pos = 0; MT_CLR_PNU (uptr); @@ -2370,7 +2370,7 @@ t_stat r = MTSE_OK; if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_position(unit=%d, flags=0x%X, recs=%d, files=%d)\n", (int)(uptr-ctx->dptr->units), flags, recs, files); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_position(unit=%d, flags=0x%X, recs=%d, files=%d)\n", (int)(uptr-ctx->dptr->units), flags, recs, files); *recsskipped = *filesskipped = *objectsskipped = 0; if (flags & MTPOS_M_REW) @@ -2436,7 +2436,7 @@ if (!(uptr->flags & UNIT_ATT)) /* attached? */ if (ctx == NULL) /* if not properly attached? */ return sim_messagef (SCPE_IERR, "Bad Attach\n"); /* that's a problem */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_reset(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug_unit (ctx->dbit, uptr, "sim_tape_reset(unit=%d)\n", (int)(uptr-ctx->dptr->units)); _sim_tape_io_flush(uptr); AIO_VALIDATE; diff --git a/slirp/debug.h b/slirp/debug.h index 26edcc91..aba02476 100644 --- a/slirp/debug.h +++ b/slirp/debug.h @@ -21,7 +21,7 @@ extern int slirp_debug; #define dfd stderr #define DEBUG_CALL(x) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, "%s...\n", x); fflush(dfd); };} while (0) -#define DEBUG_ARG(x, y) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, x, y); _sim_debug (slirp_dbit, slirp_dptr, "\n"); fflush(dfd); };} while (0) +#define DEBUG_ARG(x, y) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, x, y); _sim_debug_device (slirp_dbit, slirp_dptr, "\n"); fflush(dfd); };} while (0) #define DEBUG_ARGS(...) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, ## __VA_ARGS__); fflush(dfd); };} while (0) #define DEBUG_MISC(...) do {if (slirp_debug & DBG_MISC) { fprintf (dfd, ## __VA_ARGS__); fflush(dfd); };} while (0) #define DEBUG_ERROR(...) do {if (slirp_debug & DBG_ERROR) { fprintf (dfd, ## __VA_ARGS__); fflush(dfd); };} while (0) @@ -49,14 +49,14 @@ extern "C" { extern void *slirp_dptr; extern unsigned int slirp_dbit; -extern void _sim_debug (unsigned int dbits, DEVICE* dptr, const char* fmt, ...); +extern void _sim_debug_device (unsigned int dbits, DEVICE* dptr, const char* fmt, ...); -#define DEBUG_CALL(x) do {if (slirp_debug & DBG_CALL) { _sim_debug (slirp_dbit, slirp_dptr, "%s...\n", x); };} while (0) -#define DEBUG_ARG(x, y) do {if (slirp_debug & DBG_CALL) {_sim_debug (slirp_dbit, slirp_dptr, x, y); _sim_debug (slirp_dbit, slirp_dptr, "\n"); };} while (0) -#define DEBUG_ARGS(...) do {if (slirp_debug & DBG_CALL) { _sim_debug (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0) -#define DEBUG_MISC(...) do {if (slirp_debug & DBG_MISC) { _sim_debug (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0) -#define DEBUG_ERROR(...) do {if (slirp_debug & DBG_ERROR) { _sim_debug (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0) -#define DPRINTF(fmt, ...) do {if (slirp_debug & DBG_CALL) { _sim_debug (slirp_dbit, slirp_dptr, fmt, ## __VA_ARGS__); };} while (0) +#define DEBUG_CALL(x) do {if (slirp_debug & DBG_CALL) { _sim_debug_device (slirp_dbit, slirp_dptr, "%s...\n", x); };} while (0) +#define DEBUG_ARG(x, y) do {if (slirp_debug & DBG_CALL) {_sim_debug_device (slirp_dbit, slirp_dptr, x, y); _sim_debug_device (slirp_dbit, slirp_dptr, "\n"); };} while (0) +#define DEBUG_ARGS(...) do {if (slirp_debug & DBG_CALL) { _sim_debug_device (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0) +#define DEBUG_MISC(...) do {if (slirp_debug & DBG_MISC) { _sim_debug_device (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0) +#define DEBUG_ERROR(...) do {if (slirp_debug & DBG_ERROR) { _sim_debug_device (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0) +#define DPRINTF(fmt, ...) do {if (slirp_debug & DBG_CALL) { _sim_debug_device (slirp_dbit, slirp_dptr, fmt, ## __VA_ARGS__); };} while (0) #if defined(__cplusplus) }