On 3/14/14 8:48 PM, Ignacio Burgueño wrote: > Hi. I'm the author of StackTracePlus, a library to "enhance" stack > traces with additional information. > In my scripts, I usually just override debug.traceback with a custom > function. Works fine with Lua. > > Then, I got this issue reported today, saying that the technique is > not working with LuaJIT: > https://github.com/ignacio/StackTracePlus/issues/6 > > Checking the source, I found out that the interpreter does not use the > function at debug.traceback, so whatever you put there won't be picked up. > > What are the possibilities for the LuaJIT interpreter to behave like > the Lua one when generating stack traces? I mean, to pick up the > function in debug.traceback dynamically. > > Regards, > Ignacio An alternative could be to hook into package.loaders, wrap the compiled chunk in a function which passes it to xpcall, and generate your own stack trace from the handler (which is called before the stack unwinds).