void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack* callStack) { #if OS(DARWIN) || (OS(LINUX) && !PLATFORM(GTK)) static const int framesToShow = 31; static const int framesToSkip = 3; // WTFGetBacktrace, appendAPIBacktrace, reportAPIException. void* samples[framesToShow + framesToSkip]; int frames = framesToShow + framesToSkip; WTFGetBacktrace(samples, &frames); void** stack = samples + framesToSkip; int size = frames - framesToSkip; for (int i = 0; i < size; ++i) { const char* mangledName = nullptr; char* cxaDemangled = nullptr; Dl_info info; if (dladdr(stack[i], &info) && info.dli_sname) mangledName = info.dli_sname; if (mangledName) cxaDemangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, nullptr); if (mangledName || cxaDemangled) callStack->append(ScriptCallFrame(cxaDemangled ? cxaDemangled : mangledName, ASCIILiteral("[native code]"), 0, 0)); else callStack->append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), 0, 0)); free(cxaDemangled); } #else UNUSED_PARAM(callStack); #endif }
void WTFReportBacktrace() { static const int framesToShow = 31; static const int framesToSkip = 2; void* samples[framesToShow + framesToSkip]; int frames = framesToShow + framesToSkip; WTFGetBacktrace(samples, &frames); for (int i = framesToSkip; i < frames; ++i) { const char* mangledName = 0; char* cxaDemangled = 0; #if !PLATFORM(GTK) && !PLATFORM(QT) && (OS(DARWIN) || OS(LINUX)) Dl_info info; if (dladdr(samples[i], &info) && info.dli_sname) mangledName = info.dli_sname; if (mangledName) cxaDemangled = abi::__cxa_demangle(mangledName, 0, 0, 0); #endif const int frameNumber = i - framesToSkip + 1; if (mangledName || cxaDemangled) fprintf(stderr, "%-3d %p %s\n", frameNumber, samples[i], cxaDemangled ? cxaDemangled : mangledName); else fprintf(stderr, "%-3d %p\n", frameNumber, samples[i]); free(cxaDemangled); } }
void WTFReportBacktrace(int framesToShow) { static const int framesToSkip = 2; // Use alloca to allocate on the stack since this function is used in OOM situations. void** samples = static_cast<void**>(alloca((framesToShow + framesToSkip) * sizeof(void *))); int frames = framesToShow + framesToSkip; WTFGetBacktrace(samples, &frames); WTFPrintBacktrace(samples + framesToSkip, frames - framesToSkip); }
void WTFReportBacktrace() { static const int framesToShow = 31; static const int framesToSkip = 2; void* samples[framesToShow + framesToSkip]; int frames = framesToShow + framesToSkip; WTFGetBacktrace(samples, &frames); WTFPrintBacktrace(samples + framesToSkip, frames - framesToSkip); }
void ScriptElement::stopLoadRequest() { if (m_cachedScript) { if (!m_willBeParserExecuted) m_cachedScript->removeClient(this); #if PLATFORM(CHROMIUM) ASSERT(m_cachedScriptState == Set); m_cachedScriptState = ZeroedInStopLoadRequest; m_backtraceSize = MaxBacktraceSize; WTFGetBacktrace(m_backtrace, &m_backtraceSize); #endif m_cachedScript = 0; } }
void ScriptElement::notifyFinished(CachedResource* o) { ASSERT(!m_willBeParserExecuted); ASSERT_UNUSED(o, o == m_cachedScript); if (m_willExecuteInOrder) m_element->document()->scriptRunner()->notifyInOrderScriptReady(); else m_element->document()->scriptRunner()->queueScriptForExecution(this, m_cachedScript, ScriptRunner::ASYNC_EXECUTION); #if PLATFORM(CHROMIUM) ASSERT(m_cachedScriptState == Set); m_cachedScriptState = ZeroedInNotifyFinished; m_backtraceSize = MaxBacktraceSize; WTFGetBacktrace(m_backtrace, &m_backtraceSize); #endif m_cachedScript = 0; }
void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack& callStack) { #if OS(DARWIN) || (OS(LINUX) && !PLATFORM(GTK)) static const int framesToShow = 31; static const int framesToSkip = 3; // WTFGetBacktrace, appendAPIBacktrace, reportAPIException. void* samples[framesToShow + framesToSkip]; int frames = framesToShow + framesToSkip; WTFGetBacktrace(samples, &frames); void** stack = samples + framesToSkip; int size = frames - framesToSkip; for (int i = 0; i < size; ++i) { auto demangled = StackTrace::demangle(stack[i]); if (demangled) callStack.append(ScriptCallFrame(demangled->demangledName() ? demangled->demangledName() : demangled->mangledName(), ASCIILiteral("[native code]"), noSourceID, 0, 0)); else callStack.append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), noSourceID, 0, 0)); } #else UNUSED_PARAM(callStack); #endif }