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

Method stopProfiling

valdi/src/valdi/hermes/HermesJavaScriptContext.cpp:1230–1254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1228}
1229
1230Result<std::vector<std::string>> HermesJavaScriptContext::stopProfiling() {
1231#ifdef HERMES_ENABLE_DEBUGGER
1232 static const int kProfilerStopMessageId = -2;
1233 std::vector<std::string> ret;
1234 auto* debuggerService = HermesDebuggerServer::getInstance(_logger);
1235 if (debuggerService == nullptr || _debuggerRuntimeId == kRuntimeIdUndefined) {
1236 return Error("Profiler uninitialized");
1237 }
1238 auto debuggerConnection = debuggerService->getDebuggerConnection(_debuggerRuntimeId);
1239
1240 std::promise<std::string> profilingResultPromise;
1241 debuggerConnection->setCDPMessageListener([&](const Value& message) {
1242 if (message.getMapValue("id").toInt() == kProfilerStopMessageId) {
1243 profilingResultPromise.set_value(valueToJsonString(message.getMapValue("result").getMapValue("profile")));
1244 debuggerConnection->setCDPMessageListener(nullptr);
1245 }
1246 });
1247 debuggerConnection->handleCDPMessage(
1248 HermesDebuggerConnection::createEvent(STRING_LITERAL("Profiler.stop"), kProfilerStopMessageId));
1249 ret.push_back(profilingResultPromise.get_future().get());
1250 return ret;
1251#else
1252 return Error("Profiler disabled");
1253#endif
1254}
1255
1256void HermesJavaScriptContext::setExceptionToTracker(JSExceptionTracker& exceptionTracker) {
1257 auto exception = _runtime->getThrownValue();

Callers

nothing calls this directly

Calls 9

valueToJsonStringFunction · 0.85
getDebuggerConnectionMethod · 0.80
setCDPMessageListenerMethod · 0.80
getMapValueMethod · 0.80
set_valueMethod · 0.80
handleCDPMessageMethod · 0.80
getMethod · 0.65
ErrorInterface · 0.50
toIntMethod · 0.45

Tested by

no test coverage detected