[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Minor oddity in traceback generation
- From: Daurnimator <quae@...>
- Date: Sun, 27 Sep 2015 12:28:39 +1000
I just observed that currently, tracebacks are 'shortened' based on
the 'level' passed.
local function deep(lvl, ...)
if lvl == 0 then
print(debug.traceback(...))
return
end
deep(lvl-1, ...)
end
deep(40, "my message", tonumber(arg[1]))
$ lua traceback-test.lua 1
my message
stack traceback:
traceback-test.lua:3: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
...
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in local 'deep'
traceback-test.lua:8: in main chunk
[C]: in ?
$ lua traceback-test.lua 9
my message
stack traceback:
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
...
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in upvalue 'deep'
traceback-test.lua:6: in local 'deep'
traceback-test.lua:8: in main chunk
[C]: in ?
Notice that the bit before the "..." gets shorter as you provide a
higher level argument.
This makes it hard to transparently wrap error producing functions,
as the amount of wrapping you do will effect the usefulness of the traceback
The fix should be simple enough: change luaL_traceback (
http://www.lua.org/source/5.3/lauxlib.c.html#luaL_traceback )
to calculate the `mark` based on the `level` argument.