Links:
Install Lua Debugger:
Just download debugger.lua to a directory where require() can find it:
curl -O https://raw.githubusercontent.com/slembcke/debugger.lua/master/debugger.lua
Usage:
Edit the file to debug:
local dbg = require("debugger")
Add the following anywhere (NOTE to NSE developers: this should be within the action section):
dbg()
Debugging Lua C extensions with gdb
This is straightforward:
Load
luainto the debugger:gdb lua Reading symbols from /usr/bin/lua...(no debugging symbols found)...done. (gdb)Set the breakpoint in the C code:
(gdb) b my_c_functionRun the Lua script in
gdbuntil the breakpoint:(gdb) run my_script.lua Starting program: /usr/bin/lua my_script.luaDebug as any other
gdbsession.