Skip to content

Debug in Lua

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

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback: dig +short txt issue.imzye.com
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Buy Me a Coffee