Skip to content

Debug in Lua

homepage-banner

This document introduces 2 simple methods to debug Lua code.

debug library

function myfunction ()
   print(debug.traceback("Stack trace"))
   print(debug.getinfo(1, "Sl"))
   print("Stack trace end")

   return 10
end

myfunction ()
print(debug.getinfo(1))
  • n selects fields name and namewhat
  • f selects field func
  • S selects fields source, short_src, what, and linedefined
  • l selects field currentline
  • u selects field nup

clidebugger

https://github.com/ToddWegner/clidebugger

Reference

  • https://www.lua.org/pil/23.html
  • https://www.tutorialspoint.com/lua/lua_debugging.htm
Feedback







Disclaimer
  • Welcome to visit the knowledge base of SRE and DevOps!
  • License under CC BY-NC 4.0
  • Made with Material for MkDocs and improve writing by generative AI tools
  • Copyright issue feedback me#imzye.com, replace # with @