1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsTraceRefcnt_h___
7 #define nsTraceRefcnt_h___
9 #include <stdio.h> // for FILE
15 static void Shutdown();
22 static nsresult
DumpStatistics(StatisticsType aType
= ALL_STATS
,
25 static void ResetStatistics();
27 static void DemangleSymbol(const char* aSymbol
, char* aBuffer
, int aBufLen
);
29 static void WalkTheStack(FILE* aStream
);
32 * This is a variant of |WalkTheStack| that uses |CodeAddressService| to cache
33 * the results of |NS_DescribeCodeAddress|. If |WalkTheStackCached| is being
34 * called frequently, it will be a few orders of magnitude faster than
35 * |WalkTheStack|. However, the cache uses a lot of memory, which can cause
36 * OOM crashes. Therefore, this should only be used for things like refcount
37 * logging which walk the stack extremely frequently.
39 static void WalkTheStackCached(FILE* aStream
);
42 * Tell nsTraceRefcnt whether refcounting, allocation, and destruction
43 * activity is legal. This is used to trigger assertions for any such
44 * activity that occurs because of static constructors or destructors.
46 static void SetActivityIsLegal(bool aLegal
);
49 #define NS_TRACE_REFCNT_CONTRACTID "@mozilla.org/xpcom/trace-refcnt;1"
50 #define NS_TRACE_REFCNT_CID \
51 { /* e3e7511e-a395-4924-94b1-d527861cded4 */ \
55 {0x94, 0xb1, 0xd5, 0x27, 0x86, 0x1c, 0xde, 0xd4} \
58 ////////////////////////////////////////////////////////////////////////////////
59 // And now for that utility that you've all been asking for...
62 NS_MeanAndStdDev(double aNumberOfValues
,
63 double aSumOfValues
, double aSumOfSquaredValues
,
64 double* aMeanResult
, double* aStdDevResult
);
66 ////////////////////////////////////////////////////////////////////////////////