lua-users home
lua-l archive

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


2012/12/11 Philipp Kraus <philipp.kraus@flashpixx.de>:
> I have a set of Lua scripts, that are stored in a database. On another host
> system (cluster) a MPI spawned process get the scripts and run the Lua
> code some million times. Each script / function is a independend system
> in this process. At the moment I'm developing this system, so
> I need a debug interface for my Lua codes. I would run the Lua code from C/C++
> push values and functions to the stack and read the result.
> The information which is needed by this process is "which function is called and
> what data is put in / get out", so I need a stack trace during running.
> The programm throws exception on error, but I catch the exceptions, log the error
> and do the next step. The program need not to break, only the error must be logged
> with a trace in user-friendly representation to database.
>
> Do you have got an idea for a good error log creation?

Depending on how you call your Lua scripts, you may already have the
Lua call trace in the error messages. If that's not the case, you need
to use the last argument to lua_pcall, and have it point to
debug.traceback. If that's not clear enough you need to send us the
part of the code that leads to the lua_pcall, and we can show you how
to modify it to make use of debug.traceback.

The resulting traceback string will contain a line for each call
frame, with the script name, line number and function name. If for
some reason this information is wrong or incomplete in your stack
traces, it may be because of the way you create your scripts. If you
use luaL_loadstring, you might want to consider using luaL_loadbuffer
or lua_load directly, and properly set the "name" argument.