lua-users home
lua-l archive

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


2013/9/23 Ignacio Burgueño <iburgueno@gmail.com>:
> I'd like to announce StackTracePlus.
>
> https://github.com/ignacio/StackTracePlus

Timing is interesting, I worked on something similar in the last few weeks.

I usually can interpret Lua traces without knowing the locals value,
since I can re-compute their value mentally by following the code
path. There is one exception though, it's when a loop is involved,
since the default traces don't tell at what iteration the error
happened. So my version of the improved debug.traceback adds just
that, iterator values in "for" loops (because "while" and "repeat"
loops are too generic).

I started with a pure Lua implementation there:

    https://bitbucket.org/doub/mechanicus/src/9aab46f/common/lua/debug/iterators.lua

Then I back-ported the feature in the Lua sources so that I don't have
to require my module in every place I want improved traces:

    https://bitbucket.org/doub/canopywater/src/6da78fe/srcweb/lua-5.2.2/patches/traceback-iterators

It's much more simple (or streamlined depending on the point of view)
than your implementation, but it might be of interest to some. It
introduces lines of the form:

    in iteration i=1
    in iteration k="a"

in the traces. Note that while it shows the user variable name (i, k),
the value is that of the internal "for" control/index variable (so if
you re-assign to the variable inside the loop, you still see the value
at the beginning of the iteration).