lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm using Lua 5.1 final, and I need a stack dump function.  What I came up with doesn't seem to print accurately, or anything at all.  Does anyone know how I might change this to make it work ? It's very difficult for me to work if I cannot see my Lua error messages:


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 ---------------" );
}


Relax. Yahoo! Mail virus scanning helps detect nasty viruses!