From ecd7a45ec2a634d65245f1896755aac1b1bb63c6 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 12 Sep 2013 08:12:07 +0000 Subject: [PATCH] Restore the dump_stack routine, it's really useful for debugging. --- ncat/ncat_lua.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ncat/ncat_lua.c b/ncat/ncat_lua.c index e69e8554d..f90b40f6e 100644 --- a/ncat/ncat_lua.c +++ b/ncat/ncat_lua.c @@ -140,6 +140,16 @@ void lua_report(lua_State *L, char *prefix, int panic) loguser("%s: %s.", prefix, errormsg); } +void dump_stack(lua_State *L, char* title) { + int i; + logdebug("DUMPING THE STACK title=%s.\n", title); + for (i = 1; i <= lua_gettop(L); ++i) { + fprintf(stderr, "%d %s %s\n", i, luaL_typename(L, i), luaL_tolstring(L, i, 0)); + lua_pop(L, 1); + } + logdebug("END OF DUMP.\n\n"); +} + static int traceback (lua_State *L) { const char *msg;