|
Lines 77-95
void DemangleSymbol(const char * aSymbol
|
Link Here
|
|---|
|
if (demangled) | if (demangled) |
{ | { |
strncpy(aBuffer,demangled,aBufLen); | strncpy(aBuffer,demangled,aBufLen); |
free(demangled); | free(demangled); |
} | } |
#endif // MOZ_DEMANGLE_SYMBOLS | #endif // MOZ_DEMANGLE_SYMBOLS |
} | } |
| |
|
#if defined(linux) // Linux |
|
#if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 3)) // use glibc backtrace() |
|
#include <execinfo.h> |
|
void DumpStackToFile(FILE* aStream) |
|
{ |
|
void *array[20]; |
|
size_t size; |
| |
#if defined(linux) && defined(__GLIBC__) && (defined(__i386) || defined(PPC)) // i386 or PPC Linux stackwalking code |
fflush(aStream); |
|
size = backtrace (array, 20); |
|
backtrace_symbols_fd (array, size, fileno(aStream)); |
|
} |
| |
|
#elif defined(__GLIBC__) && (defined(__i386) || defined(PPC)) // old style i386 or PPC Linux stackwalking code |
#include <setjmp.h> | #include <setjmp.h> |
// | // |
| |
void DumpStackToFile(FILE* aStream) | void DumpStackToFile(FILE* aStream) |
{ | { |
jmp_buf jb; | jmp_buf jb; |
setjmp(jb); | setjmp(jb); |
| |
|
Lines 135-150
void DumpStackToFile(FILE* aStream)
|
Link Here
|
|---|
|
| |
PRUint32 off = (char*)pc - (char*)info.dli_saddr; | PRUint32 off = (char*)pc - (char*)info.dli_saddr; |
fprintf(aStream, "%s+0x%08X [%s +0x%08X]\n", | fprintf(aStream, "%s+0x%08X [%s +0x%08X]\n", |
symbol, off, info.dli_fname, foff); | symbol, off, info.dli_fname, foff); |
} | } |
} | } |
} | } |
| |
|
#else // not implemented |
|
void DumpStackToFile(FILE* aStream) |
|
{ |
|
fprintf(aStream, "Info: Stacktrace not implemented for this Linux platform\n"); |
|
} |
|
#endif // Linux |
|
|
#elif defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386)) | #elif defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386)) |
| |
/* | /* |
* Stack walking code for Solaris courtesy of Bart Smaalder's "memtrak". | * Stack walking code for Solaris courtesy of Bart Smaalder's "memtrak". |
*/ | */ |
| |
#include <synch.h> | #include <synch.h> |
#include <ucontext.h> | #include <ucontext.h> |
|
Lines 823-840
static void InitTraceLog(void)
|
Link Here
|
|---|
|
#include "nsStackFrameWin.h" | #include "nsStackFrameWin.h" |
void | void |
nsTraceRefcntImpl::WalkTheStack(FILE* aStream) | nsTraceRefcntImpl::WalkTheStack(FILE* aStream) |
{ | { |
DumpStackToFile(aStream); | DumpStackToFile(aStream); |
} | } |
| |
// WIN32 x86 stack walking code | // WIN32 x86 stack walking code |
// i386 or PPC Linux stackwalking code or Solaris |
// Linux stackwalking code or Solaris |
#elif (defined(linux) && defined(__GLIBC__) && (defined(__i386) || defined(PPC))) || (defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386))) |
#elif (defined(linux) && defined(__GLIBC__)) || (defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386))) |
#include "nsStackFrameUnix.h" | #include "nsStackFrameUnix.h" |
void | void |
nsTraceRefcntImpl::WalkTheStack(FILE* aStream) | nsTraceRefcntImpl::WalkTheStack(FILE* aStream) |
{ | { |
DumpStackToFile(aStream); | DumpStackToFile(aStream); |
} | } |
| |
#else // unsupported platform. | #else // unsupported platform. |