]>
Commit | Line | Data |
---|---|---|
af53352a | 1 | Index: xpcom/base/nsTraceRefcntImpl.cpp |
2 | =================================================================== | |
3 | RCS file: /cvs/mozilla/xpcom/base/nsTraceRefcntImpl.cpp,v | |
4 | retrieving revision 1.98 | |
5 | diff -p -u -1 -2 -r1.98 nsTraceRefcntImpl.cpp | |
6 | --- xpcom/base/nsTraceRefcntImpl.cpp 3 Feb 2006 19:35:14 -0000 1.98 | |
7 | +++ xpcom/base/nsTraceRefcntImpl.cpp 6 Feb 2006 20:30:53 -0000 | |
8 | @@ -41,37 +41,24 @@ | |
9 | #include "nsISupports.h" | |
10 | #include "nsVoidArray.h" | |
11 | #include "prprf.h" | |
12 | #include "prlog.h" | |
13 | #include "plstr.h" | |
14 | #include <stdlib.h> | |
15 | #include "nsCOMPtr.h" | |
16 | #include "nsCRT.h" | |
17 | #include <math.h> | |
18 | ||
19 | #if defined(_WIN32) | |
20 | #include <windows.h> | |
21 | -#elif defined(linux) && defined(__GLIBC__) && (defined(__i386) || defined(PPC)) | |
22 | -#include <setjmp.h> | |
23 | - | |
24 | -// | |
25 | -// On glibc 2.1, the Dl_info api defined in <dlfcn.h> is only exposed | |
26 | -// if __USE_GNU is defined. I suppose its some kind of standards | |
27 | -// adherence thing. | |
28 | -// | |
29 | -#if (__GLIBC_MINOR__ >= 1) && !defined(__USE_GNU) | |
30 | -#define __USE_GNU | |
31 | -#endif | |
32 | - | |
33 | -#include <dlfcn.h> | |
34 | #endif | |
35 | ||
36 | #ifdef HAVE_LIBDL | |
37 | #include <dlfcn.h> | |
38 | #endif | |
39 | ||
40 | //////////////////////////////////////////////////////////////////////////////// | |
41 | ||
42 | NS_COM void | |
43 | NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues, | |
44 | double *meanResult, double *stdDevResult) | |
45 | { | |
46 | @@ -451,25 +438,25 @@ static PRIntn PR_CALLBACK DumpSerialNumb | |
47 | record->COMPtrCount); | |
48 | #else | |
49 | fprintf((FILE*) aClosure, "%d (%d references)\n", | |
50 | record->serialNumber, | |
51 | record->refCount); | |
52 | #endif | |
53 | return HT_ENUMERATE_NEXT; | |
54 | } | |
55 | ||
56 | ||
57 | #endif /* NS_BUILD_REFCNT_LOGGING */ | |
58 | ||
59 | -nsresult | |
60 | +NS_COM nsresult | |
61 | nsTraceRefcntImpl::DumpStatistics(StatisticsType type, FILE* out) | |
62 | { | |
63 | nsresult rv = NS_OK; | |
64 | #ifdef NS_BUILD_REFCNT_LOGGING | |
65 | if (gBloatLog == nsnull || gBloatView == nsnull) { | |
66 | return NS_ERROR_FAILURE; | |
67 | } | |
68 | if (out == nsnull) { | |
69 | out = gBloatLog; | |
70 | } | |
71 | ||
72 | LOCK_TRACELOG(); | |
73 | @@ -528,25 +515,25 @@ nsTraceRefcntImpl::DumpStatistics(Statis | |
74 | if (gSerialNumbers) { | |
75 | fprintf(out, "\n\nSerial Numbers of Leaked Objects:\n"); | |
76 | PL_HashTableEnumerateEntries(gSerialNumbers, DumpSerialNumbers, out); | |
77 | } | |
78 | ||
79 | done: | |
80 | gLogging = wasLogging; | |
81 | UNLOCK_TRACELOG(); | |
82 | #endif | |
83 | return rv; | |
84 | } | |
85 | ||
86 | -void | |
87 | +NS_COM void | |
88 | nsTraceRefcntImpl::ResetStatistics() | |
89 | { | |
90 | #ifdef NS_BUILD_REFCNT_LOGGING | |
91 | LOCK_TRACELOG(); | |
92 | if (gBloatView) { | |
93 | PL_HashTableDestroy(gBloatView); | |
94 | gBloatView = nsnull; | |
95 | } | |
96 | UNLOCK_TRACELOG(); | |
97 | #endif | |
98 | } | |
99 | ||
100 | @@ -812,43 +799,43 @@ static void InitTraceLog(void) | |
101 | ||
102 | if (gBloatLog || gRefcntsLog || gAllocLog || gLeakyLog || gCOMPtrLog) { | |
103 | gLogging = PR_TRUE; | |
104 | } | |
105 | ||
106 | gTraceLock = PR_NewLock(); | |
107 | } | |
108 | ||
109 | #endif | |
110 | ||
111 | #if defined(_WIN32) && defined(_M_IX86) && !defined(WINCE) // WIN32 x86 stack walking code | |
112 | #include "nsStackFrameWin.h" | |
113 | -void | |
114 | +NS_COM void | |
115 | nsTraceRefcntImpl::WalkTheStack(FILE* aStream) | |
116 | { | |
117 | DumpStackToFile(aStream); | |
118 | } | |
119 | ||
120 | // WIN32 x86 stack walking code | |
121 | // i386 or PPC Linux stackwalking code or Solaris | |
122 | -#elif (defined(linux) && defined(__GLIBC__) && (defined(__i386) || defined(PPC))) || (defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386))) | |
123 | +#elif (defined(linux) && defined(__GNUC__) && (defined(__i386) || defined(PPC))) || (defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386))) | |
124 | #include "nsStackFrameUnix.h" | |
125 | -void | |
126 | +NS_COM void | |
127 | nsTraceRefcntImpl::WalkTheStack(FILE* aStream) | |
128 | { | |
129 | DumpStackToFile(aStream); | |
130 | } | |
131 | ||
132 | #else // unsupported platform. | |
133 | ||
134 | -void | |
135 | +NS_COM void | |
136 | nsTraceRefcntImpl::WalkTheStack(FILE* aStream) | |
137 | { | |
138 | fprintf(aStream, "write me, dammit!\n"); | |
139 | } | |
140 | ||
141 | #endif | |
142 | ||
143 | //---------------------------------------------------------------------- | |
144 | ||
145 | // This thing is exported by libstdc++ | |
146 | // Yes, this is a gcc only hack | |
147 | #if defined(MOZ_DEMANGLE_SYMBOLS) | |
148 | Index: xpcom/base/nsStackFrameUnix.cpp | |
149 | =================================================================== | |
150 | RCS file: /cvs/mozilla/xpcom/base/nsStackFrameUnix.cpp,v | |
151 | retrieving revision 1.14 | |
152 | diff -p -u -1 -2 -r1.14 nsStackFrameUnix.cpp | |
153 | --- xpcom/base/nsStackFrameUnix.cpp 3 Feb 2006 19:35:14 -0000 1.14 | |
154 | +++ xpcom/base/nsStackFrameUnix.cpp 6 Feb 2006 20:28:06 -0000 | |
155 | @@ -74,43 +74,33 @@ void DemangleSymbol(const char * aSymbol | |
156 | /* See demangle.h in the gcc source for the voodoo */ | |
157 | char * demangled = abi::__cxa_demangle(aSymbol,0,0,0); | |
158 | ||
159 | if (demangled) | |
160 | { | |
161 | strncpy(aBuffer,demangled,aBufLen); | |
162 | free(demangled); | |
163 | } | |
164 | #endif // MOZ_DEMANGLE_SYMBOLS | |
165 | } | |
166 | ||
167 | ||
168 | -#if defined(linux) && defined(__GLIBC__) && (defined(__i386) || defined(PPC)) // i386 or PPC Linux stackwalking code | |
169 | +#if defined(linux) && defined(__GNUC__) && (defined(__i386) || defined(PPC)) // i386 or PPC Linux stackwalking code | |
170 | ||
171 | -#include <setjmp.h> | |
172 | -// | |
173 | ||
174 | void DumpStackToFile(FILE* aStream) | |
175 | { | |
176 | - jmp_buf jb; | |
177 | - setjmp(jb); | |
178 | - | |
179 | // Stack walking code courtesy Kipp's "leaky". | |
180 | ||
181 | - // Get the frame pointer out of the jmp_buf | |
182 | - void **bp = (void**) | |
183 | -#if defined(__i386) | |
184 | - (jb[0].__jmpbuf[JB_BP]); | |
185 | -#elif defined(PPC) | |
186 | - (jb[0].__jmpbuf[JB_GPR1]); | |
187 | -#endif | |
188 | + // Get the frame pointer | |
189 | + void **bp = (void**) __builtin_frame_address(0); | |
190 | ||
191 | int skip = 2; | |
192 | for ( ; (void**)*bp > bp; bp = (void**)*bp) { | |
193 | void *pc = *(bp+1); | |
194 | if (--skip <= 0) { | |
195 | Dl_info info; | |
196 | int ok = dladdr(pc, &info); | |
197 | if (!ok) { | |
198 | fprintf(aStream, "UNKNOWN %p\n", pc); | |
199 | continue; | |
200 | } | |
201 | ||
202 | ||
203 |