From cd44dc59cdfc39534aef4d417e9f3c412e3be139 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 3 Feb 2012 09:55:33 +0100 Subject: Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560) --- Source/JavaScriptCore/wtf/Assertions.cpp | 41 ++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'Source/JavaScriptCore/wtf/Assertions.cpp') diff --git a/Source/JavaScriptCore/wtf/Assertions.cpp b/Source/JavaScriptCore/wtf/Assertions.cpp index 3da67effe..80afcf414 100644 --- a/Source/JavaScriptCore/wtf/Assertions.cpp +++ b/Source/JavaScriptCore/wtf/Assertions.cpp @@ -272,6 +272,16 @@ void WTFGetBacktrace(void** stack, int* size) #endif } +#if OS(DARWIN) || OS(LINUX) +# if PLATFORM(QT) || PLATFORM(GTK) +# if defined(__GLIBC__) && !defined(__UCLIBC__) +# define WTF_USE_BACKTRACE_SYMBOLS 1 +# endif +# else +# define WTF_USE_DLADDR 1 +# endif +#endif + void WTFReportBacktrace() { static const int framesToShow = 31; @@ -281,11 +291,18 @@ void WTFReportBacktrace() WTFGetBacktrace(samples, &frames); +#if USE(BACKTRACE_SYMBOLS) + char** symbols = backtrace_symbols(samples, frames); + if (!symbols) + return; +#endif + for (int i = framesToSkip; i < frames; ++i) { const char* mangledName = 0; char* cxaDemangled = 0; - -#if !PLATFORM(GTK) && !PLATFORM(QT) && (OS(DARWIN) || OS(LINUX)) +#if USE(BACKTRACE_SYMBOLS) + mangledName = symbols[i]; +#elif USE(DLADDR) Dl_info info; if (dladdr(samples[i], &info) && info.dli_sname) mangledName = info.dli_sname; @@ -299,6 +316,26 @@ void WTFReportBacktrace() printf_stderr_common("%-3d %p\n", frameNumber, samples[i]); free(cxaDemangled); } + +#if USE(BACKTRACE_SYMBOLS) + free(symbols); +#endif +} + +#undef WTF_USE_BACKTRACE_SYMBOLS +#undef WTF_USE_DLADDR + +static WTFCrashHookFunction globalHook = 0; + +void WTFSetCrashHook(WTFCrashHookFunction function) +{ + globalHook = function; +} + +void WTFInvokeCrashHook() +{ + if (globalHook) + globalHook(); } void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) -- cgit v1.2.1