lua-users home
lua-l archive

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


Glenn Maynard wrote:
> That makes some sort of sense for recursive tail calls, but if f tail
> calls g, f is the real caller of g--if f was originally called by a,
> I don't want debug calls telling me that g was called by a; it wasn't.  
> Since it doesn't know anymore, I'd much rather have it say "don't know"
> than to give a wrong answer (like C stack traces do).

But this is only a matter of definition. Right now the Lua manual
specifies 'level n+1 is the function that has called level n'
(probably to be backwards compatible with Lua 4). Changing this to
'level n is the function at n levels below your current running
function' makes more sense IMHO.

I guess it happens more often that you have to work around the
phantom tailcall frames, than that this piece of information has
any benefit.

And as I pointed out, when you start your application in a
debugger, it could/should of course keep track of tailcalls.
The circular buffer idea mentioned by Rici should do just fine.
And best of all it does not have any impact on the Lua core.

Oh and BTW: If you are debugging state machines you definitely
want the engine to store a state trace itself. Nothing a stock
debugger provides (such as a stack backtrace) can be as detailed
and up to the point as a state trace.