Introduction
RemDebug is a remote debugger for Lua 5.0 and 5.1. It lets you control the execution of another Lua program remotely, setting breakpoints and inspecting the current state of the program.
RemDebug is free software and uses the same license as Lua.
Installation
RemDebug uses LuaSocket 2.0 and LuaFileSystem 1.2, so first check if these libraries are installed in your system. Download and install LuaSocket and LuaFileSystem if they are not installed. RemDebug also uses the new package proposal for Lua 5.1, so if you use Lua 5.0 then download and install Compat-5.1 R5.
To install RemDebug, create a remdebug
folder in your package.path
and copy
engine.lua
to this folder. The controller.lua
file is a standalone application,
so it can be anywhere in your system.
RemDebug uses the new package proposal, so if you are using Lua 5.0
you should load compat-5.1.lua
through your LUA_INIT
environment variable.
Running
You should run the controller first, as in:
lua50 controller.lua
The controller will block, waiting for you to run the application. It should have the following lines added:
require"remdebug.engine" remdebug.engine.start()
Now run the application. A sample one, test.lua
, is provided with the source files. Just do
lua50 test.lua
If the application is a CGI script, or Lua page (.lp
file), point to it using a browser.
The application should block on the first statement after remdebug.engine.start()
, and the
controller will wait for further commands. Type help
to see the available commands.
Controller Commands
setb <file> <line>
- Sets a breakpoint for the Lua script
<file>
at line<line>
.<file>
should be the name of the script relative to the base path you set. delb <file> <line>
- Removes a previously set breakpoint.
delallb
- Removes all breakpoints.
setw <exp>
- Adds a new watch expression. The application will pause when it evaluates as true. The command will return the index of the watch expression. You need the index to remove it later.
delw <index>
- Removes the watch expression with this index.
delallw
- Removes all watch expressions.
eval <exp>
- Evaluates
<exp>
, which should be a Lua expression, in the context where where the program stopped (including any local variables and upvalues), and returns the value. exec <stmt>
- Executes
<stmt>
, which should be a Lua chunk, in the context where where the program stopped (including any local variables and upvalues). run
- Run the program, blocking the controller again, until the next breakpoint.
step
- Run the program, blocking the controller again, until the next line (stepping into functions).
over
- Run the program, blocking the controller again, until the next line (stepping over functions).
listb
- Lists current breakpoints
listw
- Lists current watch expressions
basedir [path]
- Sets the base path of the remote application, or shows the current one.
help
- Lists the commands.