Basic Ideas on Lua debugger Development

Source: Internet
Author: User

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

 
 
  1. Static void LuaDebugCallBack (lua_State * L, lua_Debug * ar)
  2. {
  3. Lua_getinfo (L, "S", ar );
  4. Switch (ar-> event)
  5. {
  6. Case LUA_HOOKRET:
  7. M_iDeepFunc --;
  8. Break;
  9. Case LUA_HOOKCALL:
  10. M_iDeepFunc ++;
  11. Break;
  12. Case LUA_HOOKLINE:
  13. String strSource = ar-> source + 1;
  14. ULONG ulLine = ar-> currentline;
  15. // Print the global variable lua_pushvalue (state, LUA_GLOBALSINDEX), stack information (lua_getstack, lua_getinfo (, "nSlf", & d), and local variable (lua_getlocal ))
  16. .......
  17. Break;
  18. Defalut:
  19. Break;
  20. }
  21. }

Set the hook function:

 
 
  1. 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.