tset.de » dbghelper: a debugging helper module for lua

dbghelper: a debugging helper module for lua

What is it?

dbghelper is a module for lua 5.1 and 5.2 to aid debugging of lua programs. It injects a function resumeuntil into the debug table, which can resume a coroutine until a debug event occurs or the coroutine yields or returns.

Documentation

Usage

require "dbghelper"

cr = coroutine.create(function_to_debug)
ok, what = debug.resumeuntil(cr, mask, count, ...)

Arguments

cr
coroutine to debug
mask, count
as for debug.sethook
...
extra arguments to pass to the coroutine resume function (only use if the coroutine has yielded or on the first call)

Return values

ok
true if the coroutine can be resumed, false if not
what
event that caused resumeuntil to return, can be any one of
  • 'line', 'count', 'call', 'tail call', 'return', 'tail return' or 'yield' if ok is true,
  • 'return' or 'error' if ok is false.

Notes

Look at the included dbgtest.lua for some examples.

Download and building

You can get dbghelper-0.2 by clicking on this link.

The module source comes with a makefile. It tries to discover what version of lua you are using and where your include files are, but may not be too smart at that. Also, you need access to lua's source tree, especially lstate.h, to compile this. The location must be changed in the makefile.

License

The dbghelper module and all accompanying documentation and additional source code is released under the MIT/X11 license.

Copyright (c) 2012 Gunnar Zötl 
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
  

Contact

If you have anything to say about this, comments, bug reports, whatever, feel free to email them to