summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/src/misc/prtrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/src/misc/prtrace.c')
-rw-r--r--nsprpub/pr/src/misc/prtrace.c369
1 files changed, 194 insertions, 175 deletions
diff --git a/nsprpub/pr/src/misc/prtrace.c b/nsprpub/pr/src/misc/prtrace.c
index 058f700b5..ef6b65104 100644
--- a/nsprpub/pr/src/misc/prtrace.c
+++ b/nsprpub/pr/src/misc/prtrace.c
@@ -85,18 +85,18 @@ static PRCondVar *logCVar; /* Sync Condidtion Variable */
** Inter-thread state communication.
** Controling thread writes to logOrder under protection of logCVar
** the logging thread reads logOrder and sets logState on Notify.
-**
+**
** logSegments, logCount, logLostData must be read and written under
** protection of logLock, logCVar.
-**
+**
*/
static enum LogState
{
LogNotRunning, /* Initial state */
LogReset, /* Causes logger to re-calc controls */
LogActive, /* Logging in progress, set only by log thread */
- LogSuspend, /* Suspend Logging */
- LogResume, /* Resume Logging => LogActive */
+ LogSuspend, /* Suspend Logging */
+ LogResume, /* Resume Logging => LogActive */
LogStop /* Stop the log thread */
} logOrder, logState, localState; /* controlling state variables */
static PRInt32 logSegments; /* Number of buffer segments */
@@ -129,21 +129,21 @@ static void NewTraceBuffer( PRInt32 size )
logSegSize = logEntriesPerSegment * sizeof(PRTraceEntry);
PR_ASSERT( bufSize != 0);
PR_LOG( lm, PR_LOG_ERROR,
- ("NewTraceBuffer: logSegments: %ld, logEntries: %ld, logEntriesPerSegment: %ld, logSegSize: %ld",
- logSegments, logEntries, logEntriesPerSegment, logSegSize ));
+ ("NewTraceBuffer: logSegments: %ld, logEntries: %ld, logEntriesPerSegment: %ld, logSegSize: %ld",
+ logSegments, logEntries, logEntriesPerSegment, logSegSize ));
tBuf = PR_Malloc( bufSize );
if ( tBuf == NULL )
{
PR_LOG( lm, PR_LOG_ERROR,
- ("PRTrace: Failed to get trace buffer"));
+ ("PRTrace: Failed to get trace buffer"));
PR_ASSERT( 0 );
- }
+ }
else
{
PR_LOG( lm, PR_LOG_NOTICE,
- ("PRTrace: Got trace buffer of size: %ld, at %p", bufSize, tBuf));
+ ("PRTrace: Got trace buffer of size: %ld, at %p", bufSize, tBuf));
}
next = 0;
@@ -166,7 +166,7 @@ static void _PR_InitializeTrace( void )
PR_ASSERT( traceLock != NULL );
PR_Lock( traceLock );
-
+
PR_INIT_CLIST( &qNameList );
lm = PR_NewLogModule("trace");
@@ -179,17 +179,17 @@ static void _PR_InitializeTrace( void )
logCVar = PR_NewCondVar( logLock );
PR_Unlock( traceLock );
- return;
+ return;
} /* end _PR_InitializeTrace() */
/*
** Create a Trace Handle
*/
PR_IMPLEMENT(PRTraceHandle)
- PR_CreateTrace(
- const char *qName, /* QName for this trace handle */
- const char *rName, /* RName for this trace handle */
- const char *description /* description for this trace handle */
+PR_CreateTrace(
+ const char *qName, /* QName for this trace handle */
+ const char *rName, /* RName for this trace handle */
+ const char *description /* description for this trace handle */
)
{
QName *qnp;
@@ -197,8 +197,9 @@ PR_IMPLEMENT(PRTraceHandle)
PRBool matchQname = PR_FALSE;
/* Self initialize, if necessary */
- if ( traceLock == NULL )
+ if ( traceLock == NULL ) {
_PR_InitializeTrace();
+ }
/* Validate input arguments */
PR_ASSERT( strlen(qName) <= PRTRACE_NAME_MAX );
@@ -234,10 +235,10 @@ PR_IMPLEMENT(PRTraceHandle)
{
qnp = PR_NEWZAP( QName );
PR_ASSERT( qnp != NULL );
- PR_INIT_CLIST( &qnp->link );
- PR_INIT_CLIST( &qnp->rNameList );
+ PR_INIT_CLIST( &qnp->link );
+ PR_INIT_CLIST( &qnp->rNameList );
strcpy( qnp->name, qName );
- PR_APPEND_LINK( &qnp->link, &qNameList );
+ PR_APPEND_LINK( &qnp->link, &qNameList );
}
/* Do we already have a matching RName? */
@@ -267,13 +268,13 @@ PR_IMPLEMENT(PRTraceHandle)
PR_ASSERT(0);
}
- PR_APPEND_LINK( &rnp->link, &qnp->rNameList ); /* add RName to QName's rnList */
+ PR_APPEND_LINK( &rnp->link, &qnp->rNameList ); /* add RName to QName's rnList */
rnp->qName = qnp; /* point the RName to the QName */
/* Unlock the Facility */
PR_Unlock( traceLock );
PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: Create: QName: %s %p, RName: %s %p\n\t",
- qName, qnp, rName, rnp ));
+ qName, qnp, rName, rnp ));
return((PRTraceHandle)rnp);
} /* end PR_CreateTrace() */
@@ -281,16 +282,16 @@ PR_IMPLEMENT(PRTraceHandle)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_DestroyTrace(
- PRTraceHandle handle /* Handle to be destroyed */
+PR_IMPLEMENT(void)
+PR_DestroyTrace(
+ PRTraceHandle handle /* Handle to be destroyed */
)
{
RName *rnp = (RName *)handle;
QName *qnp = rnp->qName;
- PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: Deleting: QName: %s, RName: %s",
- qnp->name, rnp->name));
+ PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: Deleting: QName: %s, RName: %s",
+ qnp->name, rnp->name));
/* Lock the Facility */
PR_Lock( traceLock );
@@ -299,8 +300,8 @@ PR_IMPLEMENT(void)
** Remove RName from the list of RNames in QName
** and free RName
*/
- PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: Deleting RName: %s, %p",
- rnp->name, rnp));
+ PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: Deleting RName: %s, %p",
+ rnp->name, rnp));
PR_REMOVE_LINK( &rnp->link );
PR_Free( rnp->lock );
PR_DELETE( rnp );
@@ -311,11 +312,11 @@ PR_IMPLEMENT(void)
*/
if ( PR_CLIST_IS_EMPTY( &qnp->rNameList ) )
{
- PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: Deleting unused QName: %s, %p",
- qnp->name, qnp));
+ PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: Deleting unused QName: %s, %p",
+ qnp->name, qnp));
PR_REMOVE_LINK( &qnp->link );
PR_DELETE( qnp );
- }
+ }
/* Unlock the Facility */
PR_Unlock( traceLock );
@@ -325,39 +326,42 @@ PR_IMPLEMENT(void)
/*
** Create a TraceEntry in the trace buffer
*/
-PR_IMPLEMENT(void)
- PR_Trace(
- PRTraceHandle handle, /* use this trace handle */
- PRUint32 userData0, /* User supplied data word 0 */
- PRUint32 userData1, /* User supplied data word 1 */
- PRUint32 userData2, /* User supplied data word 2 */
- PRUint32 userData3, /* User supplied data word 3 */
- PRUint32 userData4, /* User supplied data word 4 */
- PRUint32 userData5, /* User supplied data word 5 */
- PRUint32 userData6, /* User supplied data word 6 */
- PRUint32 userData7 /* User supplied data word 7 */
+PR_IMPLEMENT(void)
+PR_Trace(
+ PRTraceHandle handle, /* use this trace handle */
+ PRUint32 userData0, /* User supplied data word 0 */
+ PRUint32 userData1, /* User supplied data word 1 */
+ PRUint32 userData2, /* User supplied data word 2 */
+ PRUint32 userData3, /* User supplied data word 3 */
+ PRUint32 userData4, /* User supplied data word 4 */
+ PRUint32 userData5, /* User supplied data word 5 */
+ PRUint32 userData6, /* User supplied data word 6 */
+ PRUint32 userData7 /* User supplied data word 7 */
)
{
PRTraceEntry *tep;
PRInt32 mark;
- if ( (traceState == Suspended )
- || ( ((RName *)handle)->state == Suspended ))
+ if ( (traceState == Suspended )
+ || ( ((RName *)handle)->state == Suspended )) {
return;
+ }
/*
** Get the next trace entry slot w/ minimum delay
*/
PR_Lock( traceLock );
- tep = &tBuf[next++];
- if ( next > last )
+ tep = &tBuf[next++];
+ if ( next > last ) {
next = 0;
- if ( fetchLostData == PR_FALSE && next == fetchLastSeen )
+ }
+ if ( fetchLostData == PR_FALSE && next == fetchLastSeen ) {
fetchLostData = PR_TRUE;
-
+ }
+
mark = next;
-
+
PR_Unlock( traceLock );
/*
@@ -400,10 +404,10 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_SetTraceOption(
- PRTraceOption command, /* One of the enumerated values */
- void *value /* command value or NULL */
+PR_IMPLEMENT(void)
+PR_SetTraceOption(
+ PRTraceOption command, /* One of the enumerated values */
+ void *value /* command value or NULL */
)
{
RName * rnp;
@@ -417,79 +421,80 @@ PR_IMPLEMENT(void)
NewTraceBuffer( bufSize );
PR_Unlock( traceLock );
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceBufSize: %ld", bufSize));
+ ("PRSetTraceOption: PRTraceBufSize: %ld", bufSize));
break;
-
+
case PRTraceEnable :
rnp = *(RName **)value;
rnp->state = Running;
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceEnable: %p", rnp));
+ ("PRSetTraceOption: PRTraceEnable: %p", rnp));
break;
-
+
case PRTraceDisable :
rnp = *(RName **)value;
rnp->state = Suspended;
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceDisable: %p", rnp));
+ ("PRSetTraceOption: PRTraceDisable: %p", rnp));
break;
-
+
case PRTraceSuspend :
traceState = Suspended;
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceSuspend"));
+ ("PRSetTraceOption: PRTraceSuspend"));
break;
-
+
case PRTraceResume :
traceState = Running;
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceResume"));
+ ("PRSetTraceOption: PRTraceResume"));
break;
-
+
case PRTraceSuspendRecording :
PR_Lock( logLock );
logOrder = LogSuspend;
PR_NotifyCondVar( logCVar );
PR_Unlock( logLock );
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceSuspendRecording"));
+ ("PRSetTraceOption: PRTraceSuspendRecording"));
break;
-
+
case PRTraceResumeRecording :
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceResumeRecording"));
- if ( logState != LogSuspend )
+ ("PRSetTraceOption: PRTraceResumeRecording"));
+ if ( logState != LogSuspend ) {
break;
+ }
PR_Lock( logLock );
logOrder = LogResume;
PR_NotifyCondVar( logCVar );
PR_Unlock( logLock );
break;
-
+
case PRTraceStopRecording :
PR_Lock( logLock );
logOrder = LogStop;
PR_NotifyCondVar( logCVar );
PR_Unlock( logLock );
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceStopRecording"));
+ ("PRSetTraceOption: PRTraceStopRecording"));
break;
case PRTraceLockHandles :
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceLockTraceHandles"));
+ ("PRSetTraceOption: PRTraceLockTraceHandles"));
PR_Lock( traceLock );
break;
-
+
case PRTraceUnLockHandles :
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRSetTraceOption: PRTraceUnLockHandles"));
+ ("PRSetTraceOption: PRTraceUnLockHandles"));
PR_Unlock( traceLock );
break;
default:
PR_LOG( lm, PR_LOG_ERROR,
- ("PRSetTraceOption: Invalid command %ld", command ));
+ ("PRSetTraceOption: Invalid command %ld", command ));
PR_ASSERT( 0 );
break;
} /* end switch() */
@@ -499,10 +504,10 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_GetTraceOption(
- PRTraceOption command, /* One of the enumerated values */
- void *value /* command value or NULL */
+PR_IMPLEMENT(void)
+PR_GetTraceOption(
+ PRTraceOption command, /* One of the enumerated values */
+ void *value /* command value or NULL */
)
{
switch ( command )
@@ -510,12 +515,12 @@ PR_IMPLEMENT(void)
case PRTraceBufSize :
*((PRInt32 *)value) = bufSize;
PR_LOG( lm, PR_LOG_DEBUG,
- ("PRGetTraceOption: PRTraceBufSize: %ld", bufSize ));
+ ("PRGetTraceOption: PRTraceBufSize: %ld", bufSize ));
break;
-
+
default:
PR_LOG( lm, PR_LOG_ERROR,
- ("PRGetTraceOption: Invalid command %ld", command ));
+ ("PRGetTraceOption: Invalid command %ld", command ));
PR_ASSERT( 0 );
break;
} /* end switch() */
@@ -525,10 +530,10 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(PRTraceHandle)
- PR_GetTraceHandleFromName(
- const char *qName, /* QName search argument */
- const char *rName /* RName search argument */
+PR_IMPLEMENT(PRTraceHandle)
+PR_GetTraceHandleFromName(
+ const char *qName, /* QName search argument */
+ const char *rName /* RName search argument */
)
{
const char *qn, *rn, *desc;
@@ -536,7 +541,7 @@ PR_IMPLEMENT(PRTraceHandle)
RName *rnp = NULL;
PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: GetTraceHandleFromName:\n\t"
- "QName: %s, RName: %s", qName, rName ));
+ "QName: %s, RName: %s", qName, rName ));
qh = PR_FindNextTraceQname( NULL );
while (qh != NULL)
@@ -546,7 +551,7 @@ PR_IMPLEMENT(PRTraceHandle)
{
PR_GetTraceNameFromHandle( rh, &qn, &rn, &desc );
if ( (strcmp( qName, qn ) == 0)
- && (strcmp( rName, rn ) == 0 ))
+ && (strcmp( rName, rn ) == 0 ))
{
rnp = (RName *)rh;
goto foundIt;
@@ -564,12 +569,12 @@ foundIt:
/*
**
*/
-PR_IMPLEMENT(void)
- PR_GetTraceNameFromHandle(
- PRTraceHandle handle, /* handle as search argument */
- const char **qName, /* pointer to associated QName */
- const char **rName, /* pointer to associated RName */
- const char **description /* pointer to associated description */
+PR_IMPLEMENT(void)
+PR_GetTraceNameFromHandle(
+ PRTraceHandle handle, /* handle as search argument */
+ const char **qName, /* pointer to associated QName */
+ const char **rName, /* pointer to associated RName */
+ const char **description /* pointer to associated description */
)
{
RName *rnp = (RName *)handle;
@@ -580,8 +585,8 @@ PR_IMPLEMENT(void)
*description = rnp->desc;
PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: GetConterNameFromHandle: "
- "QNp: %p, RNp: %p,\n\tQName: %s, RName: %s, Desc: %s",
- qnp, rnp, qnp->name, rnp->name, rnp->desc ));
+ "QNp: %p, RNp: %p,\n\tQName: %s, RName: %s, Desc: %s",
+ qnp, rnp, qnp->name, rnp->name, rnp->desc ));
return;
} /* end PR_GetTraceNameFromHandle() */
@@ -589,24 +594,28 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(PRTraceHandle)
- PR_FindNextTraceQname(
- PRTraceHandle handle
+PR_IMPLEMENT(PRTraceHandle)
+PR_FindNextTraceQname(
+ PRTraceHandle handle
)
{
QName *qnp = (QName *)handle;
- if ( PR_CLIST_IS_EMPTY( &qNameList ))
- qnp = NULL;
- else if ( qnp == NULL )
+ if ( PR_CLIST_IS_EMPTY( &qNameList )) {
+ qnp = NULL;
+ }
+ else if ( qnp == NULL ) {
qnp = (QName *)PR_LIST_HEAD( &qNameList );
- else if ( PR_NEXT_LINK( &qnp->link ) == &qNameList )
+ }
+ else if ( PR_NEXT_LINK( &qnp->link ) == &qNameList ) {
qnp = NULL;
- else
+ }
+ else {
qnp = (QName *)PR_NEXT_LINK( &qnp->link );
+ }
- PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: FindNextQname: Handle: %p, Returns: %p",
- handle, qnp ));
+ PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: FindNextQname: Handle: %p, Returns: %p",
+ handle, qnp ));
return((PRTraceHandle)qnp);
} /* end PR_FindNextTraceQname() */
@@ -614,31 +623,35 @@ PR_IMPLEMENT(PRTraceHandle)
/*
**
*/
-PR_IMPLEMENT(PRTraceHandle)
- PR_FindNextTraceRname(
- PRTraceHandle rhandle,
- PRTraceHandle qhandle
+PR_IMPLEMENT(PRTraceHandle)
+PR_FindNextTraceRname(
+ PRTraceHandle rhandle,
+ PRTraceHandle qhandle
)
{
RName *rnp = (RName *)rhandle;
QName *qnp = (QName *)qhandle;
- if ( PR_CLIST_IS_EMPTY( &qnp->rNameList ))
+ if ( PR_CLIST_IS_EMPTY( &qnp->rNameList )) {
rnp = NULL;
- else if ( rnp == NULL )
+ }
+ else if ( rnp == NULL ) {
rnp = (RName *)PR_LIST_HEAD( &qnp->rNameList );
- else if ( PR_NEXT_LINK( &rnp->link ) == &qnp->rNameList )
+ }
+ else if ( PR_NEXT_LINK( &rnp->link ) == &qnp->rNameList ) {
rnp = NULL;
- else
+ }
+ else {
rnp = (RName *)PR_NEXT_LINK( &rnp->link );
+ }
- PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p",
- rhandle, qhandle, rnp ));
+ PR_LOG( lm, PR_LOG_DEBUG, ("PRTrace: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p",
+ rhandle, qhandle, rnp ));
return((PRTraceHandle)rnp);
} /* end PR_FindNextTraceRname() */
-
+
/*
**
*/
@@ -648,11 +661,12 @@ static PRFileDesc * InitializeRecording( void )
PRFileDesc *logFile;
/* Self initialize, if necessary */
- if ( traceLock == NULL )
+ if ( traceLock == NULL ) {
_PR_InitializeTrace();
+ }
PR_LOG( lm, PR_LOG_DEBUG,
- ("PR_RecordTraceEntries: begins"));
+ ("PR_RecordTraceEntries: begins"));
logLostData = 0; /* reset at entry */
logState = LogReset;
@@ -662,17 +676,17 @@ static PRFileDesc * InitializeRecording( void )
if ( logFileName == NULL )
{
PR_LOG( lm, PR_LOG_ERROR,
- ("RecordTraceEntries: Environment variable not defined. Exiting"));
+ ("RecordTraceEntries: Environment variable not defined. Exiting"));
return NULL;
}
-
+
/* Open the logfile */
logFile = PR_Open( logFileName, PR_WRONLY | PR_CREATE_FILE, 0666 );
if ( logFile == NULL )
{
PR_LOG( lm, PR_LOG_ERROR,
- ("RecordTraceEntries: Cannot open %s as trace log file. OS error: %ld",
- logFileName, PR_GetOSError()));
+ ("RecordTraceEntries: Cannot open %s as trace log file. OS error: %ld",
+ logFileName, PR_GetOSError()));
return NULL;
}
return logFile;
@@ -685,35 +699,35 @@ static void ProcessOrders( void )
{
switch ( logOrder )
{
- case LogReset :
- logOrder = logState = localState;
- PR_LOG( lm, PR_LOG_DEBUG,
- ("RecordTraceEntries: LogReset"));
- break;
+ case LogReset :
+ logOrder = logState = localState;
+ PR_LOG( lm, PR_LOG_DEBUG,
+ ("RecordTraceEntries: LogReset"));
+ break;
- case LogSuspend :
- localState = logOrder = logState = LogSuspend;
- PR_LOG( lm, PR_LOG_DEBUG,
- ("RecordTraceEntries: LogSuspend"));
- break;
+ case LogSuspend :
+ localState = logOrder = logState = LogSuspend;
+ PR_LOG( lm, PR_LOG_DEBUG,
+ ("RecordTraceEntries: LogSuspend"));
+ break;
- case LogResume :
- localState = logOrder = logState = LogActive;
- PR_LOG( lm, PR_LOG_DEBUG,
- ("RecordTraceEntries: LogResume"));
- break;
+ case LogResume :
+ localState = logOrder = logState = LogActive;
+ PR_LOG( lm, PR_LOG_DEBUG,
+ ("RecordTraceEntries: LogResume"));
+ break;
- case LogStop :
- logOrder = logState = LogStop;
- PR_LOG( lm, PR_LOG_DEBUG,
- ("RecordTraceEntries: LogStop"));
- break;
+ case LogStop :
+ logOrder = logState = LogStop;
+ PR_LOG( lm, PR_LOG_DEBUG,
+ ("RecordTraceEntries: LogStop"));
+ break;
- default :
- PR_LOG( lm, PR_LOG_ERROR,
- ("RecordTraceEntries: Invalid logOrder: %ld", logOrder ));
- PR_ASSERT( 0 );
- break;
+ default :
+ PR_LOG( lm, PR_LOG_ERROR,
+ ("RecordTraceEntries: Invalid logOrder: %ld", logOrder ));
+ PR_ASSERT( 0 );
+ break;
} /* end switch() */
return ;
} /* end ProcessOrders() */
@@ -727,17 +741,17 @@ static void WriteTraceSegment( PRFileDesc *logFile, void *buf, PRInt32 amount )
PR_LOG( lm, PR_LOG_ERROR,
- ("WriteTraceSegment: Buffer: %p, Amount: %ld", buf, amount));
- rc = PR_Write( logFile, buf , amount );
+ ("WriteTraceSegment: Buffer: %p, Amount: %ld", buf, amount));
+ rc = PR_Write( logFile, buf, amount );
if ( rc == -1 )
PR_LOG( lm, PR_LOG_ERROR,
- ("RecordTraceEntries: PR_Write() failed. Error: %ld", PR_GetError() ));
+ ("RecordTraceEntries: PR_Write() failed. Error: %ld", PR_GetError() ));
else if ( rc != amount )
PR_LOG( lm, PR_LOG_ERROR,
- ("RecordTraceEntries: PR_Write() Tried to write: %ld, Wrote: %ld", amount, rc));
- else
+ ("RecordTraceEntries: PR_Write() Tried to write: %ld, Wrote: %ld", amount, rc));
+ else
PR_LOG( lm, PR_LOG_DEBUG,
- ("RecordTraceEntries: PR_Write(): Buffer: %p, bytes: %ld", buf, amount));
+ ("RecordTraceEntries: PR_Write(): Buffer: %p, bytes: %ld", buf, amount));
return;
} /* end WriteTraceSegment() */
@@ -746,8 +760,8 @@ static void WriteTraceSegment( PRFileDesc *logFile, void *buf, PRInt32 amount )
**
*/
PR_IMPLEMENT(void)
- PR_RecordTraceEntries(
- void
+PR_RecordTraceEntries(
+ void
)
{
PRFileDesc *logFile;
@@ -760,7 +774,7 @@ PR_IMPLEMENT(void)
if ( logFile == NULL )
{
PR_LOG( lm, PR_LOG_DEBUG,
- ("PR_RecordTraceEntries: Failed to initialize"));
+ ("PR_RecordTraceEntries: Failed to initialize"));
return;
}
@@ -770,12 +784,14 @@ PR_IMPLEMENT(void)
PR_Lock( logLock );
- while ( (logCount == 0) && ( logOrder == logState ) )
+ while ( (logCount == 0) && ( logOrder == logState ) ) {
PR_WaitCondVar( logCVar, PR_INTERVAL_NO_TIMEOUT );
+ }
/* Handle state transitions */
- if ( logOrder != logState )
+ if ( logOrder != logState ) {
ProcessOrders();
+ }
/* recalculate local controls */
if ( logCount )
@@ -787,7 +803,7 @@ PR_IMPLEMENT(void)
logCount = (logCount % logSegments);
currentSegment = logCount;
PR_LOG( lm, PR_LOG_DEBUG,
- ("PR_RecordTraceEntries: LostData segments: %ld", logLostData));
+ ("PR_RecordTraceEntries: LostData segments: %ld", logLostData));
}
else
{
@@ -795,29 +811,32 @@ PR_IMPLEMENT(void)
}
buf = tBuf + ( logEntriesPerSegment * currentSegment );
- if (++currentSegment >= logSegments )
+ if (++currentSegment >= logSegments ) {
currentSegment = 0;
+ }
doWrite = PR_TRUE;
}
- else
+ else {
doWrite = PR_FALSE;
+ }
PR_Unlock( logLock );
if ( doWrite == PR_TRUE )
{
- if ( localState != LogSuspend )
+ if ( localState != LogSuspend ) {
WriteTraceSegment( logFile, buf, logSegSize );
+ }
else
PR_LOG( lm, PR_LOG_DEBUG,
- ("RecordTraceEntries: PR_Write(): is suspended" ));
+ ("RecordTraceEntries: PR_Write(): is suspended" ));
}
} /* end while(logState...) */
PR_Close( logFile );
PR_LOG( lm, PR_LOG_DEBUG,
- ("RecordTraceEntries: exiting"));
+ ("RecordTraceEntries: exiting"));
return;
} /* end PR_RecordTraceEntries() */
@@ -825,23 +844,23 @@ PR_IMPLEMENT(void)
**
*/
PR_IMPLEMENT(PRIntn)
- PR_GetTraceEntries(
- PRTraceEntry *buffer, /* where to write output */
- PRInt32 count, /* number to get */
- PRInt32 *found /* number you got */
+PR_GetTraceEntries(
+ PRTraceEntry *buffer, /* where to write output */
+ PRInt32 count, /* number to get */
+ PRInt32 *found /* number you got */
)
{
- PRInt32 rc;
+ PRInt32 rc;
PRInt32 copied = 0;
-
+
PR_Lock( traceLock );
-
+
/*
** Depending on where the LastSeen and Next indices are,
- ** copy the trace buffer in one or two pieces.
+ ** copy the trace buffer in one or two pieces.
*/
PR_LOG( lm, PR_LOG_ERROR,
- ("PR_GetTraceEntries: Next: %ld, LastSeen: %ld", next, fetchLastSeen));
+ ("PR_GetTraceEntries: Next: %ld, LastSeen: %ld", next, fetchLastSeen));
if ( fetchLastSeen <= next )
{
@@ -850,7 +869,7 @@ PR_IMPLEMENT(PRIntn)
*(buffer + copied++) = *(tBuf + fetchLastSeen++);
}
PR_LOG( lm, PR_LOG_ERROR,
- ("PR_GetTraceEntries: Copied: %ld, LastSeen: %ld", copied, fetchLastSeen));
+ ("PR_GetTraceEntries: Copied: %ld, LastSeen: %ld", copied, fetchLastSeen));
}
else /* copy in 2 parts */
{
@@ -861,14 +880,14 @@ PR_IMPLEMENT(PRIntn)
fetchLastSeen = 0;
PR_LOG( lm, PR_LOG_ERROR,
- ("PR_GetTraceEntries: Copied: %ld, LastSeen: %ld", copied, fetchLastSeen));
+ ("PR_GetTraceEntries: Copied: %ld, LastSeen: %ld", copied, fetchLastSeen));
while ( count-- > 0 && fetchLastSeen < next )
{
*(buffer + copied++) = *(tBuf + fetchLastSeen++);
}
PR_LOG( lm, PR_LOG_ERROR,
- ("PR_GetTraceEntries: Copied: %ld, LastSeen: %ld", copied, fetchLastSeen));
+ ("PR_GetTraceEntries: Copied: %ld, LastSeen: %ld", copied, fetchLastSeen));
}
*found = copied;