diff --git a/src/WINNT/client_osi/libosi.def b/src/WINNT/client_osi/libosi.def index bbb229ed5a..9c4585110a 100644 --- a/src/WINNT/client_osi/libosi.def +++ b/src/WINNT/client_osi/libosi.def @@ -73,3 +73,4 @@ EXPORTS lock_ConvertRToW @66 osi_LogSaveStringW @67 osi_SetLockOrderValidation @68 + osi_DebugAdd @69 diff --git a/src/WINNT/client_osi/osilog.c b/src/WINNT/client_osi/osilog.c index 0f2fb65510..f9fbdab1a0 100644 --- a/src/WINNT/client_osi/osilog.c +++ b/src/WINNT/client_osi/osilog.c @@ -166,63 +166,78 @@ void osi_LogFree(osi_log_t *logp) } /* add an element to a log */ -void osi_LogAdd(osi_log_t *logp, char *formatp, size_t p0, size_t p1, size_t p2, size_t p3, size_t p4) +static void +osi_IntLogAdd(osi_log_t *logp, int debug, char *formatp, size_t p0, size_t p1, size_t p2, size_t p3, size_t p4) { osi_logEntry_t *lep; long ix; LARGE_INTEGER bigTime; /* handle init races */ - if (!logp) return; + if (!logp) + return; /* do this w/o locking for speed; it is obviously harmless if we're off * by a bit. */ - if (!logp->enabled) return; + if (logp->enabled) { - thrd_EnterCrit(&logp->cs); - if (logp->nused < logp->alloc) logp->nused++; - else { - logp->first++; - if (logp->first >= logp->alloc) logp->first -= logp->alloc; - } - ix = logp->first + logp->nused - 1; - if (ix >= logp->alloc) ix -= logp->alloc; + thrd_EnterCrit(&logp->cs); + if (logp->nused < logp->alloc) + logp->nused++; + else { + logp->first++; + if (logp->first >= logp->alloc) + logp->first -= logp->alloc; + } + ix = logp->first + logp->nused - 1; + if (ix >= logp->alloc) + ix -= logp->alloc; - lep = logp->datap + ix; /* ptr arith */ - lep->tid = thrd_Current(); + lep = logp->datap + ix; /* ptr arith */ + lep->tid = thrd_Current(); - /* get the time, using the high res timer if available */ - if (osi_logFreq) { - QueryPerformanceCounter(&bigTime); - lep->micros = (bigTime.LowPart / osi_logFreq) * osi_logTixToMicros; - } - else lep->micros = GetCurrentTime() * 1000; + /* get the time, using the high res timer if available */ + if (osi_logFreq) { + QueryPerformanceCounter(&bigTime); + lep->micros = (bigTime.LowPart / osi_logFreq) * osi_logTixToMicros; + } + else lep->micros = GetCurrentTime() * 1000; - lep->formatp = formatp; - lep->parms[0] = p0; - lep->parms[1] = p1; - lep->parms[2] = p2; - lep->parms[3] = p3; - lep->parms[4] = p4; + lep->formatp = formatp; + lep->parms[0] = p0; + lep->parms[1] = p1; + lep->parms[2] = p2; + lep->parms[3] = p3; + lep->parms[4] = p4; #ifdef NOTSERVICE - printf( "%9ld:", lep->micros ); - printf( formatp, p0, p1, p2, p3, p4); - printf( "\n" ); + printf( "%9ld:", lep->micros ); + printf( formatp, p0, p1, p2, p3, p4); + printf( "\n" ); #endif + thrd_LeaveCrit(&logp->cs); + } - if(ISCLIENTDEBUGLOG(osi_TraceOption)) { + if (debug || (logp->enabled && ISCLIENTDEBUGLOG(osi_TraceOption))) { char wholemsg[1024], msg[1000]; StringCbPrintfA(msg, sizeof(msg), formatp, p0, p1, p2, p3, p4); StringCbPrintfA(wholemsg, sizeof(wholemsg), "tid[%d] %s\n", - lep->tid, msg); + thrd_Current(), msg); OutputDebugStringA(wholemsg); } +} - thrd_LeaveCrit(&logp->cs); +void osi_LogAdd(osi_log_t *logp, char *formatp, size_t p0, size_t p1, size_t p2, size_t p3, size_t p4) +{ + osi_IntLogAdd(logp, FALSE, formatp, p0, p1, p2, p3, p4); +} + +void osi_DebugAdd(osi_log_t *logp, char *formatp, size_t p0, size_t p1, size_t p2, size_t p3, size_t p4) +{ + osi_IntLogAdd(logp, TRUE, formatp, p0, p1, p2, p3, p4); } void osi_LogPrint(osi_log_t *logp, FILE_HANDLE handle) diff --git a/src/WINNT/client_osi/osilog.h b/src/WINNT/client_osi/osilog.h index 00ba718828..559c8440d2 100644 --- a/src/WINNT/client_osi/osilog.h +++ b/src/WINNT/client_osi/osilog.h @@ -59,6 +59,8 @@ extern void osi_LogFree(osi_log_t *); extern void osi_LogAdd(osi_log_t *, char *, size_t, size_t, size_t, size_t, size_t); +extern void osi_DebugAdd(osi_log_t *, char *, size_t, size_t, size_t, size_t, size_t); + extern void osi_LogReset(osi_log_t *); extern long osi_LogFDCreate(osi_fdType_t *, osi_fd_t **); @@ -90,6 +92,15 @@ extern char *osi_HexifyString(char *s); #define osi_Log4(l,f,a,b,c,d) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), 0); } while(0) #define osi_Log5(l,f,a,b,c,d,e) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), (size_t) (e)); } while(0) +#define osi_Debug0(l,f) osi_DebugAdd((l), (f), 0, 0, 0, 0, 0) +#define osi_Debug1(l,f,a) osi_DebugAdd((l), (f), (size_t) (a), 0, 0, 0, 0) +#define osi_Debug2(l,f,a,b) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), 0, 0, 0) +#define osi_Debug3(l,f,a,b,c) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), 0, 0) +#define osi_Debug4(l,f,a,b,c,d) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), 0) +#define osi_Debug5(l,f,a,b,c,d,e) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), (size_t) (e)) + + + #ifdef DEBUG_VERBOSE #define DEBUG_EVENT1(a,b,c) {HANDLE h; char *ptbuf[1],buf[132];\ h = RegisterEventSource(NULL, a);\