| 319 | } |
| 320 | |
| 321 | void EmmyFacade::Hook(lua_State *L, lua_Debug *ar) { |
| 322 | auto debugger = GetDebugger(L); |
| 323 | if (debugger) { |
| 324 | if (!debugger->IsRunning()) { |
| 325 | if (GetWorkMode() == WorkMode::EmmyCore) { |
| 326 | if (luaVersion != LuaVersion::LUA_JIT) { |
| 327 | if (debugger->IsMainCoroutine(L)) { |
| 328 | SetReadyHook(L); |
| 329 | } |
| 330 | } else { |
| 331 | SetReadyHook(L); |
| 332 | } |
| 333 | } |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | debugger->Hook(ar, L); |
| 338 | } else { |
| 339 | if (workMode == WorkMode::Attach) { |
| 340 | debugger = _emmyDebuggerManager.AddDebugger(L); |
| 341 | install_emmy_debugger(L); |
| 342 | if (_emmyDebuggerManager.IsRunning()) { |
| 343 | debugger->Start(); |
| 344 | debugger->Attach(); |
| 345 | } |
| 346 | // send attached notify |
| 347 | auto obj = nlohmann::json::object(); |
| 348 | obj["state"] = reinterpret_cast<int64_t>(L); |
| 349 | |
| 350 | this->transporter->Send(int(MessageCMD::AttachedNotify), obj); |
| 351 | |
| 352 | debugger->Hook(ar, L); |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | EmmyDebuggerManager &EmmyFacade::GetDebugManager() { |
| 358 | return _emmyDebuggerManager; |
no test coverage detected