是否可以在Lua端(不是C / C ++端)转储堆栈?
与此类似,但从Lua方面
static void stackDump (lua_State *L) {
int i=lua_gettop(L);
printf(" ---------------- Stack Dump ----------------" );
while( i ) {
int t = lua_type(L, i);
switch (t) {
case LUA_TSTRING:
printf("%d:`%s'", i, lua_tostring(L, i));
break;
case LUA_TBOOLEAN:
printf("%d: %s",i,lua_toboolean(L, i) ? "true" : "false");
break;
case LUA_TNUMBER:
printf("%d: %g", i, lua_tonumber(L, i));
break;
default: printf("%d: %s", i, lua_typename(L, t)); break;
}
i--;
}
printf("--------------- Stack Dump Finished ---------------" );
}