From 2d6d3301c0e1027cb4f5f64041ecb1f7f4a61007 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Wed, 6 Jun 2007 22:05:25 +0000 Subject: [PATCH] Make nsTraceRefcnt print addresses along with serial numbers, and fix warning about casting to a function pointer. b=383234 r=peterv git-svn-id: svn://10.0.0.236/trunk@227614 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/base/nsTraceRefcntImpl.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mozilla/xpcom/base/nsTraceRefcntImpl.cpp b/mozilla/xpcom/base/nsTraceRefcntImpl.cpp index 98054138b7c..920d3e404be 100644 --- a/mozilla/xpcom/base/nsTraceRefcntImpl.cpp +++ b/mozilla/xpcom/base/nsTraceRefcntImpl.cpp @@ -43,6 +43,7 @@ #include "prprf.h" #include "prlog.h" #include "plstr.h" +#include "prlink.h" #include #include "nsCOMPtr.h" #include "nsCRT.h" @@ -439,13 +440,15 @@ static PRIntn PR_CALLBACK DumpSerialNumbers(PLHashEntry* aHashEntry, PRIntn aInd { serialNumberRecord* record = NS_REINTERPRET_CAST(serialNumberRecord *,aHashEntry->value); #ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR - fprintf((FILE*) aClosure, "%d (%d references; %d from COMPtrs)\n", + fprintf((FILE*) aClosure, "%d @%p (%d references; %d from COMPtrs)\n", record->serialNumber, + NS_INT32_TO_PTR(aHashEntry->key), record->refCount, record->COMPtrCount); #else - fprintf((FILE*) aClosure, "%d (%d references)\n", + fprintf((FILE*) aClosure, "%d @%p (%d references)\n", record->serialNumber, + NS_INT32_TO_PTR(aHashEntry->key), record->refCount); #endif return HT_ENUMERATE_NEXT; @@ -681,11 +684,20 @@ static void InitTraceLog(void) defined = InitLog("XPCOM_MEM_LEAKY_LOG", "for leaky", &gLeakyLog); if (defined) { gLogToLeaky = PR_TRUE; - void* p = nsnull; - void* q = nsnull; + PRFuncPtr p = nsnull, q = nsnull; #ifdef HAVE_LIBDL - p = dlsym(0, "__log_addref"); - q = dlsym(0, "__log_release"); + { + PRLibrary *lib = nsnull; + p = PR_FindFunctionSymbolAndLibrary("__log_addref", &lib); + if (lib) { + PR_UnloadLibrary(lib); + lib = nsnull; + } + q = PR_FindFunctionSymbolAndLibrary("__log_release", &lib); + if (lib) { + PR_UnloadLibrary(lib); + } + } #endif if (p && q) { leakyLogAddRef = (void (*)(void*,int,int)) p;