static int DumpSerialNumbers(PLHashEntry* aHashEntry, int aIndex, void* aClosure) { SerialNumberRecord* record = static_cast<SerialNumberRecord*>(aHashEntry->value); auto* outputFile = static_cast<FILE*>(aClosure); #ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR fprintf(outputFile, "%" PRIdPTR " @%p (%d references; %d from COMPtrs)\n", record->serialNumber, aHashEntry->key, record->refCount, record->COMPtrCount); #else fprintf(outputFile, "%" PRIdPTR " @%p (%d references)\n", record->serialNumber, aHashEntry->key, record->refCount); #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; }
static void PrintStackFrameCached(uint32_t aFrameNumber, void* aPC, void* aSP, void* aClosure) { auto stream = static_cast<FILE*>(aClosure); static const size_t buflen = 1024; char buf[buflen]; gCodeAddressService->GetLocation(aFrameNumber, aPC, buf, buflen); fprintf(stream, " %s\n", buf); fflush(stream); }