|
On Mar 4, 2015, at 11:42 PM, Sean Conner <sean@conman.org> wrote:
Ah, yep, I meant the call stack, not the data stack. And I meant an api_check() fail, not assert. Sorry for the confusion! If I'm running in the debugger and hit an api_check fail I can dump the Lua call stack, no problem. But if it's someone else is running the app, they can only give me a C stack trace. Having the Lua stack as well has been extremely useful. This helped me debug a lot of my misuse of the C API (had to make lua_State* L a global in 5.3): void luaAssert(int x, const char* file, int line, const char* expr) { if ( !x ) { if ( L != NULL ) { lua_checkstack(L, 4); // XXX - is that enough space? luaL_traceback(L, L, NULL, 0); printf("%s\n\n", lua_tostring(L, -1)); } printf("%s:%u: failed assertion `%s'\n", file, line, expr); abort(); } } Then in luaconf.h (might should be in lua_user.h instead, I suppose): extern void pc_luaAssert(int x, const char* file, int line, const char* expr); #define luai_apicheck(e) pc_luaAssert(e, __FILE__, __LINE__, #e) -D |