|
Hello all,Without debug information, it cannot get the line number when an error occurs. For instance.A simple test.lua:a = 5a.x = 8When running with the source code(luajit test.lua) or the bytecode generated with debuginfo( luajit -bg test.lua test.bc), it shows:luajit: test.lua:2: attempt to index global 'a' (a number value)
stack traceback:
test.lua:2: in main chunk
[C]: at 0x004048f0
But when I generate the bytecode with `-b`(luajit -b test.lua test.bc), and run the bytecode, it shows:--stack traceback:
test.bc: in function <test.bc:0>
[C]: at 0x004048f0
It cannot get the line number of the error since there is no debug information in the bytecode. Then how to get the line number of an error without debug information in LuaJIT bytecode since I only want to release my LuaJIT scripts generated by '-b'.
One way is to release the '-b' version and keep the '-bg' version locally. When there is an error stack trace occurs from the `-b` version, we can get the line number from the '-bg' version. Then the question is: how can we get the line number from the PC, (just like 0x004048f0) above? Are there any tool in LuaJIT similar to addr2line in C? Thanks.
Best Regards,
Baozeng Ding