MCPcopy Create free account
hub / github.com/Snapchat/Valdi / captureStackTraces

Method captureStackTraces

valdi/src/valdi/runtime/JavaScript/JavaScriptRuntime.cpp:3578–3624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3576 return;
3577 }
3578
3579 if (_onDaemonClientEventFunction) {
3580 notifyDaemonClientEvent(jsEntry.jsContext,
3581 eventType,
3582 daemonClient,
3583 payload,
3584 _onDaemonClientEventFunction.value().get(),
3585 jsEntry.exceptionTracker);
3586 }
3587}
3588
3589void JavaScriptRuntime::notifyDaemonClientEvent(IJavaScriptContext& jsContext,
3590 DaemonClientEventType eventType,
3591 const JSValue& daemonClient,
3592 const JSValue& payload,
3593 const JSValue& onDaemonClientEventFunction,
3594 JSExceptionTracker& exceptionTracker) {
3595 std::initializer_list<JSValueRef> params = {
3596 jsContext.newNumber(static_cast<int32_t>(eventType)),
3597 JSValueRef::makeUnretained(jsContext, daemonClient),
3598 JSValueRef::makeUnretained(jsContext, payload),
3599 };
3600
3601 JSFunctionCallContext callContext(jsContext, params.begin(), params.size(), exceptionTracker);
3602
3603 jsContext.callObjectAsFunction(onDaemonClientEventFunction, callContext);
3604 if (!exceptionTracker) {
3605 onRecoverableError("notifyDaemonClientEvent", exceptionTracker);
3606 }
3607}
3608
3609void JavaScriptRuntime::setDefaultViewManagerContext(const Ref<ViewManagerContext>& viewManagerContext) {
3610 dispatchOnJsThreadUnattributed([=](auto& /*entry*/) { _defaultViewManagerContext = viewManagerContext; });
3611}
3612
3613std::future<Result<DumpedLogs>> JavaScriptRuntime::dumpLogs(bool includeMetadata, bool includeVerbose) {
3614 auto promise = Valdi::makeShared<std::promise<Result<DumpedLogs>>>();
3615 auto future = promise->get_future();
3616
3617 dispatchOnJsThreadUnattributed([promise, this, includeMetadata, includeVerbose](
3618 JavaScriptEntryParameters& jsEntry) {
3619 auto bugReportModule = importModule(STRING_LITERAL("valdi_core/src/BugReporter"), jsEntry);
3620 if (!jsEntry.exceptionTracker) {
3621 promise->set_value(jsEntry.exceptionTracker.extractError());
3622 return;
3623 }
3624
3625 auto jsValue = bugReportModule->getJsValue(jsEntry.jsContext, jsEntry.exceptionTracker);
3626 if (!jsEntry.exceptionTracker) {
3627 promise->set_value(jsEntry.exceptionTracker.extractError());

Callers 2

onANRMethod · 0.45

Calls 12

requestInterruptMethod · 0.80
setCapturedStacktraceMethod · 0.80
finishedCaptureMethod · 0.80
chronoMethod · 0.80
getCapturedStacktraceMethod · 0.80
StringBoxClass · 0.70
startMethod · 0.65
valueMethod · 0.65
isCurrentMethod · 0.45
asyncMethod · 0.45
elapsedMethod · 0.45

Tested by

no test coverage detected