【发布时间】:2012-08-28 16:45:28
【问题描述】:
如果我理解正确的话,Lua 默认会在出错时调用调试库“debug.traceback”。
但是,当将 Lua 嵌入到 C 代码中时,就像这里的示例中所做的那样: Simple Lua API Example
我们只有栈顶的错误信息。
即
if (status) {
/* If something went wrong, error message is at the top of */
/* the stack */
fprintf(stderr, "Couldn't load file: %s\n", lua_tostring(L, -1));
/* I want to print a stacktrace here. How do I do that? */
exit(1);
}
在初始错误后如何从 C 打印堆栈跟踪?
【问题讨论】:
-
在 Lua 5.2 中你可以使用 luaL_traceback。
标签: lua stack-trace traceback lua-api