diff -u -p -8 -r1.12 nsStackFrameUnix.cpp --- xpcom/base/nsStackFrameUnix.cpp 18 Apr 2004 14:18:12 -0000 1.12 +++ xpcom/base/nsStackFrameUnix.cpp 23 Jan 2006 09:23:04 -0000 @@ -77,19 +77,30 @@ void DemangleSymbol(const char * aSymbol if (demangled) { strncpy(aBuffer,demangled,aBufLen); free(demangled); } #endif // MOZ_DEMANGLE_SYMBOLS } +#if defined(linux) // Linux +#if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 3)) // use glibc backtrace() +#include +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 // void DumpStackToFile(FILE* aStream) { jmp_buf jb; setjmp(jb); @@ -135,16 +146,23 @@ void DumpStackToFile(FILE* aStream) PRUint32 off = (char*)pc - (char*)info.dli_saddr; fprintf(aStream, "%s+0x%08X [%s +0x%08X]\n", 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)) /* * Stack walking code for Solaris courtesy of Bart Smaalder's "memtrak". */ #include #include diff -u -p -8 -r1.96 nsTraceRefcntImpl.cpp --- xpcom/base/nsTraceRefcntImpl.cpp 24 Jun 2005 00:24:41 -0000 1.96 +++ xpcom/base/nsTraceRefcntImpl.cpp 23 Jan 2006 09:24:05 -0000 @@ -823,18 +823,18 @@ static void InitTraceLog(void) #include "nsStackFrameWin.h" void nsTraceRefcntImpl::WalkTheStack(FILE* aStream) { DumpStackToFile(aStream); } // WIN32 x86 stack walking code -// i386 or PPC Linux stackwalking code or Solaris -#elif (defined(linux) && defined(__GLIBC__) && (defined(__i386) || defined(PPC))) || (defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386))) +// Linux stackwalking code or Solaris +#elif (defined(linux) && defined(__GLIBC__)) || (defined(__sun) && (defined(__sparc) || defined(sparc) || defined(__i386) || defined(i386))) #include "nsStackFrameUnix.h" void nsTraceRefcntImpl::WalkTheStack(FILE* aStream) { DumpStackToFile(aStream); } #else // unsupported platform.