Bug 1196430 - part 5 - dump allocation stacks for leaked objects in XPCOM_MEM_LOG_CLASSES; r=mccr8

This commit is contained in:
Nathan Froyd 2015-08-26 19:10:22 -04:00
parent 101eaf807e
commit 3f38bd6581

View File

@ -465,20 +465,33 @@ DumpSerialNumbers(PLHashEntry* aHashEntry, int aIndex, void* aClosure)
{ {
SerialNumberRecord* record = SerialNumberRecord* record =
reinterpret_cast<SerialNumberRecord*>(aHashEntry->value); reinterpret_cast<SerialNumberRecord*>(aHashEntry->value);
auto* outputFile = static_cast<FILE*>(aClosure);
#ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR #ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
fprintf((FILE*)aClosure, "%" PRIdPTR fprintf(outputFile, "%" PRIdPTR
" @%p (%d references; %d from COMPtrs)\n", " @%p (%d references; %d from COMPtrs)\n",
record->serialNumber, record->serialNumber,
NS_INT32_TO_PTR(aHashEntry->key), NS_INT32_TO_PTR(aHashEntry->key),
record->refCount, record->refCount,
record->COMPtrCount); record->COMPtrCount);
#else #else
fprintf((FILE*)aClosure, "%" PRIdPTR fprintf(outputFile, "%" PRIdPTR
" @%p (%d references)\n", " @%p (%d references)\n",
record->serialNumber, record->serialNumber,
NS_INT32_TO_PTR(aHashEntry->key), NS_INT32_TO_PTR(aHashEntry->key),
record->refCount); record->refCount);
#endif #endif
if (!record->allocationStack.empty()) {
static const size_t bufLen = 1024;
char buf[bufLen];
fprintf(outputFile, "allocation stack:\n");
for (size_t i = 0, length = record->allocationStack.size();
i < length;
++i) {
gCodeAddressService->GetLocation(i, record->allocationStack[i],
buf, bufLen);
fprintf(outputFile, "%s\n", buf);
}
}
return HT_ENUMERATE_NEXT; return HT_ENUMERATE_NEXT;
} }