diff options
Diffstat (limited to 'src/sysbin')
-rw-r--r-- | src/sysbin/lx/main.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/sysbin/lx/main.c b/src/sysbin/lx/main.c index 573e1bb..d758285 100644 --- a/src/sysbin/lx/main.c +++ b/src/sysbin/lx/main.c @@ -106,6 +106,7 @@ void laction (int i) { ** (if present) */ void l_message (const char *pname, const char *msg) { + dbg_print(msg); if (pname) lua_writestringerror("%s: ", pname); lua_writestringerror("%s\n", msg); } @@ -393,6 +394,17 @@ int pmain (lua_State *L) { return 1; } +int lxtraceback (lua_State *L) { + lua_pushstring(L, "\n"); + lua_getglobal(L, "debug"); + lua_getfield(L, -1, "traceback"); + lua_remove(L, -2); + lua_call(L, 0, 1); + lua_pushstring(L, "\n"); + lua_concat(L, 4); + return 1; +} + int main (int argc, char **argv) { int status, result; @@ -401,8 +413,10 @@ int main (int argc, char **argv) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } + lua_pushcfunction(L, &lxtraceback); + int traceback_pos = lua_gettop(L); lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */ - status = lua_pcall(L, 0, 1, 0); /* do the call */ + status = lua_pcall(L, 0, 1, traceback_pos); /* do the call */ result = lua_toboolean(L, -1); /* get result */ report(L, status); lua_close(L); |