|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 #ifndef nsTraceRefcnt_h___ |
|
6 #define nsTraceRefcnt_h___ |
|
7 |
|
8 #include <stdio.h> // for FILE |
|
9 #include "nscore.h" |
|
10 |
|
11 class nsTraceRefcnt |
|
12 { |
|
13 public: |
|
14 static void Startup(); |
|
15 static void Shutdown(); |
|
16 |
|
17 enum StatisticsType { |
|
18 ALL_STATS, |
|
19 NEW_STATS |
|
20 }; |
|
21 |
|
22 static nsresult DumpStatistics(StatisticsType type = ALL_STATS, |
|
23 FILE* out = 0); |
|
24 |
|
25 static void ResetStatistics(void); |
|
26 |
|
27 static void DemangleSymbol(const char * aSymbol, |
|
28 char * aBuffer, |
|
29 int aBufLen); |
|
30 |
|
31 static void WalkTheStack(FILE* aStream); |
|
32 /** |
|
33 * Tell nsTraceRefcnt whether refcounting, allocation, and destruction |
|
34 * activity is legal. This is used to trigger assertions for any such |
|
35 * activity that occurs because of static constructors or destructors. |
|
36 */ |
|
37 static void SetActivityIsLegal(bool aLegal); |
|
38 }; |
|
39 |
|
40 #define NS_TRACE_REFCNT_CONTRACTID "@mozilla.org/xpcom/trace-refcnt;1" |
|
41 #define NS_TRACE_REFCNT_CID \ |
|
42 { /* e3e7511e-a395-4924-94b1-d527861cded4 */ \ |
|
43 0xe3e7511e, \ |
|
44 0xa395, \ |
|
45 0x4924, \ |
|
46 {0x94, 0xb1, 0xd5, 0x27, 0x86, 0x1c, 0xde, 0xd4} \ |
|
47 } \ |
|
48 |
|
49 //////////////////////////////////////////////////////////////////////////////// |
|
50 // And now for that utility that you've all been asking for... |
|
51 |
|
52 extern "C" void |
|
53 NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues, |
|
54 double *meanResult, double *stdDevResult); |
|
55 |
|
56 //////////////////////////////////////////////////////////////////////////////// |
|
57 #endif |