如果我理解正确,Lua 默认会在发生错误时调用调试库“debug.traceback”。
但是,当将 Lua 嵌入到 C 代码中时,就像这里的示例中所做的那样: Simple Lua API Example
我们只有堆栈顶部的错误消息。
IE
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 打印堆栈跟踪?