MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / AddDebugger

Method AddDebugger

emmy_debugger/src/debugger/emmy_debugger_manager.cpp:36–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36std::shared_ptr<Debugger> EmmyDebuggerManager::AddDebugger(lua_State* L)
37{
38 std::lock_guard<std::mutex> lock(debuggerMtx);
39
40 auto identify = GetUniqueIdentify(L);
41
42 std::shared_ptr<Debugger> debugger = nullptr;
43
44 auto it = debuggers.find(identify);
45
46 if (it == debuggers.end())
47 {
48 if (luaVersion != LuaVersion::LUA_JIT)
49 {
50 debugger = std::make_shared<Debugger>(reinterpret_cast<lua_State*>(identify), this);
51 }
52 else
53 {
54 // 如果首次add 的state不是main state,则main state视为空指针
55 // 但不影响luajit附加调试和远程调试
56 lua_State* mainState = nullptr;
57
58 int ret = lua_pushthread(L);
59 lua_pop(L, 1);
60 if (ret == 1)
61 {
62 mainState = L;
63 }
64
65 debugger = std::make_shared<Debugger>(mainState, this);
66 }
67 debuggers.insert({identify, debugger});
68 }
69 else
70 {
71 debugger = it->second;
72 }
73
74 debugger->SetCurrentState(L);
75 return debugger;
76}
77
78
79std::shared_ptr<Debugger> EmmyDebuggerManager::RemoveDebugger(lua_State* L)

Callers 6

TcpListenMethod · 0.80
TcpSharedListenMethod · 0.80
TcpConnectMethod · 0.80
PipeListenMethod · 0.80
PipeConnectMethod · 0.80
HookMethod · 0.80

Calls 5

findMethod · 0.80
endMethod · 0.80
insertMethod · 0.80
SetCurrentStateMethod · 0.80
lua_pushthreadFunction · 0.50

Tested by

no test coverage detected