| 3174 | Ref<JSStackTraceProvider> JavaScriptRuntime::captureCurrentStackTrace() { |
| 3175 | if (_javaScriptContext == nullptr) { |
| 3176 | return nullptr; |
| 3177 | } |
| 3178 | |
| 3179 | // Debugger and force flags always enable stack trace capture |
| 3180 | bool shouldCapture = _forceStackTraceCapture || _enableDebugger; |
| 3181 | |
| 3182 | auto listener = getListener(); |
| 3183 | if (!shouldCapture && listener && isInJsThread()) { |
| 3184 | auto currentContext = Context::currentRef(); |
| 3185 | if (currentContext != nullptr && !currentContext->getScopeName().isEmpty()) { |
| 3186 | auto runtimeTweaks = listener->getRuntimeTweaks(); |
| 3187 | shouldCapture = runtimeTweaks != nullptr && runtimeTweaks->enableScopedContextStackTraceCapture(); |
| 3188 | } |
| 3189 | } |
| 3190 | |
| 3191 | if (!shouldCapture) { |
| 3192 | return nullptr; |
| 3193 | } |
| 3194 | |
| 3195 | return doCaptureCurrentStackTrace(*_javaScriptContext); |
| 3196 | } |
| 3197 | |
| 3198 | void JavaScriptRuntime::setForceStackTraceCapture(bool force) { |
| 3199 | _forceStackTraceCapture = force; |
| 3200 | } |
| 3201 | |
| 3202 | Ref<JSStackTraceProvider> JavaScriptRuntime::doCaptureCurrentStackTrace(IJavaScriptContext& jsContext) { |
| 3203 | JSExceptionTracker exceptionTracker(jsContext); |
no test coverage detected