Created
February 9, 2015 00:05
-
-
Save yorung/6b51703f4d7fddf72039 to your computer and use it in GitHub Desktop.
Lua stack dump (wrong! numbers on the Lua stack will be replaced with string)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _dumpStack(lua_State* L, const char* func, int line) | |
{ | |
int top = lua_gettop(L); | |
printf("(%s,%d) top=%d\n", func, line, top); | |
for (int i = 0; i < top; i++) { | |
int positive = top - i; | |
int negative = -(i + 1); | |
int type = lua_type(L, positive); | |
const char* typeName = lua_typename(L, type); | |
const char* value = lua_tostring(L, positive); // danger!!! numbers on the Lua stack will be replaced with string | |
printf("%d/%d: type=%s value=%s\n", positive, negative, typeName, value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment