| 1228 | } |
| 1229 | |
| 1230 | Result<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 | |
| 1256 | void HermesJavaScriptContext::setExceptionToTracker(JSExceptionTracker& exceptionTracker) { |
| 1257 | auto exception = _runtime->getThrownValue(); |
nothing calls this directly
no test coverage detected