NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClass) { #ifdef NS_IMPL_REFCNT_LOGGING ASSERT_ACTIVITY_IS_LEGAL; if (!gInitialized) { InitTraceLog(); } if (gLogging == NoLogging) { return; } if (aRefcnt == 0 || gLogging == FullLogging) { AutoTraceLogLock lock; if (aRefcnt == 0 && gBloatLog) { BloatEntry* entry = GetBloatEntry(aClass, 0); if (entry) { entry->Dtor(); } } bool loggingThisType = (!gTypesToLog || LogThisType(aClass)); intptr_t serialno = 0; if (gSerialNumbers && loggingThisType) { serialno = GetSerialNumber(aPtr, false); NS_ASSERTION(serialno != 0, "Serial number requested for unrecognized pointer! " "Are you memmoving a refcounted object?"); int32_t* count = GetRefCount(aPtr); if (count) { (*count)--; } } bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno)); if (gRefcntsLog && loggingThisType && loggingThisObject) { // Can't use MOZ_LOG(), b/c it truncates the line fprintf(gRefcntsLog, "\n<%s> %p %" PRIuPTR " Release %" PRIuPTR " [thread %p]\n", aClass, aPtr, serialno, aRefcnt, PR_GetCurrentThread()); WalkTheStackCached(gRefcntsLog); fflush(gRefcntsLog); } // Here's the case where MOZ_COUNT_DTOR was not used, // yet we still want to see deletion information: if (aRefcnt == 0 && gAllocLog && loggingThisType && loggingThisObject) { fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Destroy [thread %p]\n", aClass, aPtr, serialno, PR_GetCurrentThread()); WalkTheStackCached(gAllocLog); } if (aRefcnt == 0 && gSerialNumbers && loggingThisType) { RecycleSerialNumberPtr(aPtr); } } #endif }
NS_LogAddRef(void* aPtr, nsrefcnt aRefcnt, const char* aClass, uint32_t aClassSize) { ASSERT_ACTIVITY_IS_LEGAL; if (!gInitialized) { InitTraceLog(); } if (gLogging == NoLogging) { return; } if (aRefcnt == 1 || gLogging == FullLogging) { AutoTraceLogLock lock; if (aRefcnt == 1 && gBloatLog) { BloatEntry* entry = GetBloatEntry(aClass, aClassSize); if (entry) { entry->Ctor(); } } // Here's the case where MOZ_COUNT_CTOR was not used, // yet we still want to see creation information: bool loggingThisType = (!gTypesToLog || LogThisType(aClass)); intptr_t serialno = 0; if (gSerialNumbers && loggingThisType) { serialno = GetSerialNumber(aPtr, aRefcnt == 1); MOZ_ASSERT(serialno != 0, "Serial number requested for unrecognized pointer! " "Are you memmoving a refcounted object?"); int32_t* count = GetRefCount(aPtr); if (count) { (*count)++; } } bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno)); if (aRefcnt == 1 && gAllocLog && loggingThisType && loggingThisObject) { fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Create [thread %p]\n", aClass, aPtr, serialno, PR_GetCurrentThread()); WalkTheStackCached(gAllocLog); } if (gRefcntsLog && loggingThisType && loggingThisObject) { // Can't use MOZ_LOG(), b/c it truncates the line fprintf(gRefcntsLog, "\n<%s> %p %" PRIuPTR " AddRef %" PRIuPTR " [thread %p]\n", aClass, aPtr, serialno, aRefcnt, PR_GetCurrentThread()); WalkTheStackCached(gRefcntsLog); fflush(gRefcntsLog); } } }
NS_LogCtor(void* aPtr, const char* aType, uint32_t aInstanceSize) { #ifdef NS_IMPL_REFCNT_LOGGING ASSERT_ACTIVITY_IS_LEGAL; if (!gInitialized) { InitTraceLog(); } if (gLogging != NoLogging) { AutoTraceLogLock lock; if (gBloatLog) { BloatEntry* entry = GetBloatEntry(aType, aInstanceSize); if (entry) { entry->Ctor(); } } bool loggingThisType = (!gTypesToLog || LogThisType(aType)); intptr_t serialno = 0; if (gSerialNumbers && loggingThisType) { serialno = GetSerialNumber(aPtr, true); } bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno)); if (gAllocLog && loggingThisType && loggingThisObject) { fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Ctor (%d)\n", aType, aPtr, serialno, aInstanceSize); WalkTheStackCached(gAllocLog); } } #endif }
NS_LogCtor(void* aPtr, const char* aType, uint32_t aInstanceSize) { ASSERT_ACTIVITY_IS_LEGAL; if (!gInitialized) { InitTraceLog(); } if (gLogging == NoLogging) { return; } AutoTraceLogLock lock; if (gBloatLog) { BloatEntry* entry = GetBloatEntry(aType, aInstanceSize); if (entry) { entry->Ctor(); } } bool loggingThisType = (!gTypesToLog || LogThisType(aType)); intptr_t serialno = 0; if (gSerialNumbers && loggingThisType) { serialno = GetSerialNumber(aPtr, true); MOZ_ASSERT(serialno != 0, "GetSerialNumber should never return 0 when passed true"); } bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno)); if (gAllocLog && loggingThisType && loggingThisObject) { fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Ctor (%d)\n", aType, aPtr, serialno, aInstanceSize); WalkTheStackCached(gAllocLog); } }
NS_LogDtor(void* aPtr, const char* aType, uint32_t aInstanceSize) { ASSERT_ACTIVITY_IS_LEGAL; if (!gInitialized) { InitTraceLog(); } if (gLogging == NoLogging) { return; } AutoTraceLogLock lock; if (gBloatLog) { BloatEntry* entry = GetBloatEntry(aType, aInstanceSize); if (entry) { entry->Dtor(); } } bool loggingThisType = (!gTypesToLog || LogThisType(aType)); intptr_t serialno = 0; if (gSerialNumbers && loggingThisType) { serialno = GetSerialNumber(aPtr, false); MOZ_ASSERT(serialno != 0, "Serial number requested for unrecognized pointer! " "Are you memmoving a MOZ_COUNT_CTOR-tracked object?"); RecycleSerialNumberPtr(aPtr); } bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno)); // (If we're on a losing architecture, don't do this because we'll be // using LogDeleteXPCOM instead to get file and line numbers.) if (gAllocLog && loggingThisType && loggingThisObject) { fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Dtor (%d)\n", aType, aPtr, serialno, aInstanceSize); WalkTheStackCached(gAllocLog); } }
NS_LogCOMPtrRelease(void* aCOMPtr, nsISupports* aObject) { #if defined(NS_IMPL_REFCNT_LOGGING) && defined(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR) // Get the most-derived object. void* object = dynamic_cast<void*>(aObject); // This is a very indirect way of finding out what the class is // of the object being logged. If we're logging a specific type, // then if (!gTypesToLog || !gSerialNumbers) { return; } if (!gInitialized) { InitTraceLog(); } if (gLogging == FullLogging) { AutoTraceLogLock lock; intptr_t serialno = GetSerialNumber(object, false); if (serialno == 0) { return; } int32_t* count = GetCOMPtrCount(object); if (count) { (*count)--; } bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno)); if (gCOMPtrLog && loggingThisObject) { fprintf(gCOMPtrLog, "\n<?> %p %" PRIdPTR " nsCOMPtrRelease %d %p\n", object, serialno, count ? (*count) : -1, aCOMPtr); WalkTheStackCached(gCOMPtrLog); } } #endif }
NS_LogDtor(void* aPtr, const char* aType, uint32_t aInstanceSize) { #ifdef NS_IMPL_REFCNT_LOGGING ASSERT_ACTIVITY_IS_LEGAL; if (!gInitialized) { InitTraceLog(); } if (gLogging != NoLogging) { AutoTraceLogLock lock; if (gBloatLog) { BloatEntry* entry = GetBloatEntry(aType, aInstanceSize); if (entry) { entry->Dtor(); } } bool loggingThisType = (!gTypesToLog || LogThisType(aType)); intptr_t serialno = 0; if (gSerialNumbers && loggingThisType) { serialno = GetSerialNumber(aPtr, false); RecycleSerialNumberPtr(aPtr); } bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno)); // (If we're on a losing architecture, don't do this because we'll be // using LogDeleteXPCOM instead to get file and line numbers.) if (gAllocLog && loggingThisType && loggingThisObject) { fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Dtor (%d)\n", aType, aPtr, serialno, aInstanceSize); WalkTheStackCached(gAllocLog); } } #endif }