| 56 | } |
| 57 | |
| 58 | void Debugger::Attach() { |
| 59 | if (!running) |
| 60 | return; |
| 61 | |
| 62 | // execute helper code |
| 63 | if (!manager->helperCode.empty()) { |
| 64 | ExecuteOnLuaThread([this](lua_State *L) { |
| 65 | const int t = lua_gettop(L); |
| 66 | // 判断是不是主lua_state |
| 67 | int ret = lua_pushthread(L); |
| 68 | if (ret == 1) { |
| 69 | const int r = luaL_loadstring(L, manager->helperCode.c_str()); |
| 70 | if (r == LUA_OK) { |
| 71 | if (lua_pcall(L, 0, 0, 0) != LUA_OK) { |
| 72 | std::string msg = lua_tostring(L, -1); |
| 73 | printf("msg: %s", msg.c_str()); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | lua_settop(L, t); |
| 78 | }); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void Debugger::Detach() { |
| 83 | // states.clear(); |
nothing calls this directly
no test coverage detected