[luci] How to Debug LuCI modules?

Jo-Philipp Wich xm at subsignal.org
Thu Jan 14 11:51:01 CET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Patrick

> Is it possible to debug a module line by line?  

There is a "luci.debug" module, it was originally intended to trace the
memory usage of functions but it can also generate a line-by-line call
trace. Use it this way:

require "luci.debug".trap_memtrace("/tmp/trace", "l")   -- (L, not one)

This should create a file /tmp/trace on each invocation.
Apart from that you're pretty much limited to "printf" debugging and
what Lua offers in its debug api [1] . There is no interactive debugger
like gdb as far as I know.


> Also, in LuCI how does session data are preserved? I'm guessing it
> has something todo with 'stok' in the URL.

The unique session identifier is stored in the "sysauth" cookie, it is
tied to a per-session storage in /tmp which can be accessed through the
luci.sauth api. The stok in the url is a security mechanism to prevent
xrsf attacks, it is just a weak shared secret to make urls unpredictable.


~ JoW

[1] http://www.lua.org/manual/5.1/manual.html#5.9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktO9xIACgkQdputYINPTPPYwACgorYXg83MJdS5HlLXA3X9TpBQ
5PYAnj3qxUHOiiKIFkgt7vKUkAQS3+2H
=fzmd
-----END PGP SIGNATURE-----


More information about the luci mailing list