lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


MobDebug is a remote debugger for Lua. Details and background
information from an earlier post:
http://lua-users.org/lists/lua-l/2012-06/msg00814.html.

The most recent version adds support for coroutine debugging and
on/off methods to turn debugging on and off. This may be needed for
performance reasons as running with debugging on is much slower for
many applications than normal execution. When debugging is off, the
application will run with its normal speed (debug hook is not set);
obviously all debugging functions stop working until on() call is
executed. This allows to wrap a particular section of code into on()
and off() calls and execute the rest of the code normally.

The added coroutine support allows to step through resume() and
yield() methods. It is not available by default and needs to be turn
on either by adding on() call to the coroutine, or by using coro()
method to set it on for all coroutines created by using
coroutine.create() call as in the following example:

require("mobdebug").start()
require("mobdebug").coro() -- this will enable coroutine debugging for
all coroutines

local function testme()
  print('1')
  coroutine.yield()
  print('2')
  coroutine.yield()
  print('3')
  coroutine.yield()
end

print('0')
local co = coroutine.create(testme)
while coroutine.status(co) ~= 'dead' do
  coroutine.resume(co)
end
print('4')

The module is on available github (https://github.com/pkulchenko/MobDebug).

Paul.