Index: nse_main.cc =================================================================== --- nse_main.cc (revision 10802) +++ nse_main.cc (working copy) @@ -462,6 +462,21 @@ SCRIPT_ENGINE_DEBUGGING( const char* errmsg = lua_tostring(current.thread, -1); log_write(LOG_STDOUT, "%s: %s\n", SCRIPT_ENGINE, errmsg); + lua_getglobal(L, "debug"); + if (lua_istable(L, -1)) + { + lua_getfield(L, -1, "traceback"); + lua_pushthread(current.thread); + lua_xmove(current.thread, L, 1); + if (lua_pcall(L, 1, 1, 0) == 0) + { + const char *traceback = lua_tostring(L, -1); + log_write(LOG_STDOUT, "%s: %s\n", + SCRIPT_ENGINE, traceback); + } + lua_pop(L, 1); // pcall return + } + lua_pop(L, 1); // Pop whatever was "debug" ) SCRIPT_ENGINE_TRY(process_finalize(L, current.registry_idx)); }