tech-kern archive

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

Re: Lua in-kernel (lbuf library)

Am 19.10.13 14:02, schrieb Alexander Nasonov:


> Lets say you want to iterate over all "ps" processes from ddb (if gdb
> has python support, why can't we have a cooler thing?). You do this:
> ddb> lua on
> ddb> for p in processes:match("ps") do print( end
> 906
> 2245
> 4935
> ...
> ddb> =processes:find(1).path
> "/sbin/init"
> ddb> lua off
> You can do a lot without ever accessing elements by integer indices.

Actually it would be quite nice to have a 'lua' command in ddb (instead
of 'lua on' that drops you in an interactive Lua mode, like the 'lua'
command line command.  As the system is perhaps in a weird state when
ddb is entered, it would be a good idea when the Lua state for ddb would
have been created e.g. during system startup, and maybe during normal
system operation, luactl(8) could be used to load scripts into it, which
can define functions that will be available once ddb is entered.

for those planning to tinker which such stuff, don't only look at the
Lua C API, but especially try to understand Lua's metatable concept.
This is where the real strength and power of Lua comes from.  You can
e.g. define what '' or ' = 42' really means.

Home | Main Index | Thread Index | Old Index