lua-users home
lua-l archive

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

In a spurt of energy over Easter, I wrote a simple console-based debugger for Lua, which I hope will prove useful. I've set up a
CVSTrac (temporarily) at

Unfortunately, I haven't yet set up anonymous CVS access on that
server. However, the debugger (in it's basic form) is a single
Lua file which can be downloaded directly from:

As it says on the home page, I'm aware that the name 'ldb' has
already been used. If this is a problem, I'm happy to change the
name. Suggestions are welcome.

As always, I'd like to extend my thanks to the denizens of
irc:// -- especially Slade, who wrote
and designed the initial version of lrcon, and who has
helped make sure that the code is Windows friendly, as
well as edrx, davidm123 and the others who have tried
early versions and provided bug reports, enhancement
suggestions, and general encouragement.

My main goals in creating this debugger were:

-- to simplify my life
-- to make it possible to do stack inspection while
   debugging C modules
-- to allow easy configuration and customization
-- to produce something usable fast which will not occupy
   my future life

I hope it helps others as well.

The design of the command-line interface was vaguely based on gdb and
is intended to minimize typing.

The debugger is still incomplete -- in particular, it has no
breakpoint support -- but I believe that that feature can be
added in another day's work, possibly this weekend. There are
almost certainly bugs as well, but I've found it usable (in
fact, I've been using it to debug Lua modules.)

Any feedback is more than welcome. Please use the ticket system
on CVSTrac rather than this mailing list for bug reports and
enhancement suggestions.

The CVS includes a few "goodies" in addition to the basic
ldb.lua file:

-- lrcon, the Lua Remote CONsole, which is a joint effort
   to allow the debugger to be embedded in remote applications.
   It is intended to be used with a telnet or MUD client,
   and has been (lightly) tested on Windows, Mac OS X,
   Linux (xubuntu) and FreeBSD (4.10 and 5.1). (I'm aware
   of the existence of RemDebug; the point of lrcon was
   to provide something a bit more self-contained and

-- ldbglue.c, a very small Lua module which makes it easier
   to use the debugger in conjunction with gdb, by creating
   an ldb() function which can be called from gdb.

-- ldb-config-example.lua: a description of the debugger's
   configuration system, which allows customization of
   the input/output system (for use with lrcon) and the
   'edit' command, which opens the current function in
   an external editor. (I've only tested this with
   gvim on xubuntu, but there are some example configurations
   which may work or be made to work with other editors.)

-- lua511-apicheck.diff: A patch against Lua 5.1.1 (it
   may work on 5.1.2, but I haven't tested it yet) which
   appends a meaningful message to every use of api_check
   in the Lua source, and allows the configuration of
   something other than assert() to handle api_check errors.
   In particular, you can use this to start up the debugger
   when an api_check goes off: I've found this to be
   particularly useful for debugging modules.