Loading tools/trace-malloc/lib/nsTraceMalloc.c +12 −8 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ #endif /* WIN32 */ /* * Record the intervals in a platform independent manner. */ #define MILLISECONDS_NOW PR_IntervalToMilliseconds(PR_IntervalNow()) #ifdef XP_UNIX #define WRITE_FLAGS "w" Loading Loading @@ -1385,7 +1389,7 @@ __ptr_t malloc(size_t size) site = backtrace(1); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1418,7 +1422,7 @@ __ptr_t calloc(size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1476,7 +1480,7 @@ __ptr_t realloc(__ptr_t ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -1532,7 +1536,7 @@ void free(__ptr_t ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading Loading @@ -1967,7 +1971,7 @@ MallocCallback(void *ptr, size_t size) site = backtrace(4); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1998,7 +2002,7 @@ CallocCallback(void *ptr, size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -2050,7 +2054,7 @@ ReallocCallback(void * oldptr, void *ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -2105,7 +2109,7 @@ FreeCallback(void * ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading tools/trace-malloc/spacetrace.c +1 −16 Original line number Diff line number Diff line Loading @@ -2211,23 +2211,8 @@ void tmEventHandler(tmreader* aReader, tmevent* aEvent) */ if(NULL != CALLSITE_RUN(callsite)) { static PRIntervalTime sec2int = 0; PRUint32 timeval = 0; PRUint64 timeval64 = LL_INIT(0, 0); char eventType = aEvent->type; if(0 == sec2int) { sec2int = PR_SecondsToInterval(1); } /* ** Convert the interval to a timeval. */ LL_MUL(timeval64, (PRUint64)aEvent->u.alloc.interval, (PRUint64)ST_TIMEVAL_RESOLUTION); LL_DIV(timeval64, timeval64, (PRUint64)sec2int); LL_L2UI(timeval, timeval64); /* ** Play a nasty trick on reallocs of size zero. ** They are to become free events. Loading @@ -2237,7 +2222,7 @@ void tmEventHandler(tmreader* aReader, tmevent* aEvent) { eventType = TM_EVENT_FREE; } trackEvent(timeval, eventType, callsite, aEvent->u.alloc.ptr, aEvent->u.alloc.size, oldcallsite, oldptr, oldsize); trackEvent(aEvent->u.alloc.interval, eventType, callsite, aEvent->u.alloc.ptr, aEvent->u.alloc.size, oldcallsite, oldptr, oldsize); } } else Loading tools/trace-malloc/spacetrace.h +2 −3 Original line number Diff line number Diff line Loading @@ -114,9 +114,8 @@ /* ** Set the desired resolution of the timevals. ** Too large, and you'll wrap uint32. ** A value of 1 would mean report in seconds. ** A value of 1000 would mean to report in milliseconds. ** The resolution is just mimicking what is recorded in the trace-malloc ** output, and that is currently milliseconds. */ #define ST_TIMEVAL_RESOLUTION 1000 #define ST_TIMEVAL_FORMAT "%.3f" Loading xpcom/base/nsTraceMalloc.c +12 −8 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ #endif /* WIN32 */ /* * Record the intervals in a platform independent manner. */ #define MILLISECONDS_NOW PR_IntervalToMilliseconds(PR_IntervalNow()) #ifdef XP_UNIX #define WRITE_FLAGS "w" Loading Loading @@ -1385,7 +1389,7 @@ __ptr_t malloc(size_t size) site = backtrace(1); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1418,7 +1422,7 @@ __ptr_t calloc(size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1476,7 +1480,7 @@ __ptr_t realloc(__ptr_t ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -1532,7 +1536,7 @@ void free(__ptr_t ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading Loading @@ -1967,7 +1971,7 @@ MallocCallback(void *ptr, size_t size) site = backtrace(4); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1998,7 +2002,7 @@ CallocCallback(void *ptr, size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -2050,7 +2054,7 @@ ReallocCallback(void * oldptr, void *ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -2105,7 +2109,7 @@ FreeCallback(void * ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading Loading
tools/trace-malloc/lib/nsTraceMalloc.c +12 −8 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ #endif /* WIN32 */ /* * Record the intervals in a platform independent manner. */ #define MILLISECONDS_NOW PR_IntervalToMilliseconds(PR_IntervalNow()) #ifdef XP_UNIX #define WRITE_FLAGS "w" Loading Loading @@ -1385,7 +1389,7 @@ __ptr_t malloc(size_t size) site = backtrace(1); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1418,7 +1422,7 @@ __ptr_t calloc(size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1476,7 +1480,7 @@ __ptr_t realloc(__ptr_t ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -1532,7 +1536,7 @@ void free(__ptr_t ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading Loading @@ -1967,7 +1971,7 @@ MallocCallback(void *ptr, size_t size) site = backtrace(4); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1998,7 +2002,7 @@ CallocCallback(void *ptr, size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -2050,7 +2054,7 @@ ReallocCallback(void * oldptr, void *ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -2105,7 +2109,7 @@ FreeCallback(void * ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading
tools/trace-malloc/spacetrace.c +1 −16 Original line number Diff line number Diff line Loading @@ -2211,23 +2211,8 @@ void tmEventHandler(tmreader* aReader, tmevent* aEvent) */ if(NULL != CALLSITE_RUN(callsite)) { static PRIntervalTime sec2int = 0; PRUint32 timeval = 0; PRUint64 timeval64 = LL_INIT(0, 0); char eventType = aEvent->type; if(0 == sec2int) { sec2int = PR_SecondsToInterval(1); } /* ** Convert the interval to a timeval. */ LL_MUL(timeval64, (PRUint64)aEvent->u.alloc.interval, (PRUint64)ST_TIMEVAL_RESOLUTION); LL_DIV(timeval64, timeval64, (PRUint64)sec2int); LL_L2UI(timeval, timeval64); /* ** Play a nasty trick on reallocs of size zero. ** They are to become free events. Loading @@ -2237,7 +2222,7 @@ void tmEventHandler(tmreader* aReader, tmevent* aEvent) { eventType = TM_EVENT_FREE; } trackEvent(timeval, eventType, callsite, aEvent->u.alloc.ptr, aEvent->u.alloc.size, oldcallsite, oldptr, oldsize); trackEvent(aEvent->u.alloc.interval, eventType, callsite, aEvent->u.alloc.ptr, aEvent->u.alloc.size, oldcallsite, oldptr, oldsize); } } else Loading
tools/trace-malloc/spacetrace.h +2 −3 Original line number Diff line number Diff line Loading @@ -114,9 +114,8 @@ /* ** Set the desired resolution of the timevals. ** Too large, and you'll wrap uint32. ** A value of 1 would mean report in seconds. ** A value of 1000 would mean to report in milliseconds. ** The resolution is just mimicking what is recorded in the trace-malloc ** output, and that is currently milliseconds. */ #define ST_TIMEVAL_RESOLUTION 1000 #define ST_TIMEVAL_FORMAT "%.3f" Loading
xpcom/base/nsTraceMalloc.c +12 −8 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ #endif /* WIN32 */ /* * Record the intervals in a platform independent manner. */ #define MILLISECONDS_NOW PR_IntervalToMilliseconds(PR_IntervalNow()) #ifdef XP_UNIX #define WRITE_FLAGS "w" Loading Loading @@ -1385,7 +1389,7 @@ __ptr_t malloc(size_t size) site = backtrace(1); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1418,7 +1422,7 @@ __ptr_t calloc(size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1476,7 +1480,7 @@ __ptr_t realloc(__ptr_t ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -1532,7 +1536,7 @@ void free(__ptr_t ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading Loading @@ -1967,7 +1971,7 @@ MallocCallback(void *ptr, size_t size) site = backtrace(4); if (site) log_event4(logfp, TM_EVENT_MALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -1998,7 +2002,7 @@ CallocCallback(void *ptr, size_t count, size_t size) size *= count; if (site) log_event4(logfp, TM_EVENT_CALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size); if (get_allocations()) { suppress_tracing++; Loading Loading @@ -2050,7 +2054,7 @@ ReallocCallback(void * oldptr, void *ptr, size_t size) site = backtrace(1); if (site) { log_event7(logfp, TM_EVENT_REALLOC, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), size, oldsite ? oldsite->serial : 0, (uint32)NS_PTR_TO_INT32(oldptr), oldsize); Loading Loading @@ -2105,7 +2109,7 @@ FreeCallback(void * ptr) if (site) { alloc = (allocation*) he; log_event4(logfp, TM_EVENT_FREE, site->serial, PR_IntervalNow(), site->serial, MILLISECONDS_NOW, (uint32)NS_PTR_TO_INT32(ptr), alloc->size); } PL_HashTableRawRemove(allocations, hep, he); Loading