Lua

Debugging with Lua
Login

Debugging with Lua

Home

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:

  1. Load lua into the debugger:

    gdb lua
    Reading symbols from /usr/bin/lua...(no debugging symbols found)...done.
    (gdb)
    
  2. Set the breakpoint in the C code:

    (gdb) b my_c_function
    
  3. Run the Lua script in gdb until the breakpoint:

    (gdb) run my_script.lua
    Starting program: /usr/bin/lua my_script.lua
    
  4. Debug as any other gdb session.