AboutLua DebuggerThe basic idea of development is the content to be introduced in this article. In the past, we had to createLuaRemoteDebuggerFor use by the task department. Here is a brief introduction.DebuggerThe server class is CLuaDebug!
CLuaDebug initialization:
Implement callback Hook Function
- Static void LuaDebugCallBack (lua_State * L, lua_Debug * ar)
- {
- Lua_getinfo (L, "S", ar );
- Switch (ar-> event)
- {
- Case LUA_HOOKRET:
- M_iDeepFunc --;
- Break;
- Case LUA_HOOKCALL:
- M_iDeepFunc ++;
- Break;
- Case LUA_HOOKLINE:
- String strSource = ar-> source + 1;
- ULONG ulLine = ar-> currentline;
- // Print the global variable lua_pushvalue (state, LUA_GLOBALSINDEX), stack information (lua_getstack, lua_getinfo (, "nSlf", & d), and local variable (lua_getlocal ))
- .......
- Break;
- Defalut:
- Break;
- }
- }
Set the hook function:
- lua_sethook(state, CLuaDebug::LuaDebugCallBack, LUA_MASKLINE|LUA_MASKCALL|LUA_MASKRET, 0);
Summary: I have finished introducing the basic idea of Lua debugger development. I hope this article will be helpful to you!