[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re[3]: getting call stack in case of a run-time error
- From: Tomas <tomas@...>
- Date: Wed, 21 Apr 2004 15:30:39 -0300 (BRT)
> I created new lua thread. Then I pushed a string to run and called
> lua_resume(). btw, it'll be good to include function is_yielded() which
> is (L->ci->state & CI_YIELD) into the Lua library functions. So then I
> resume thread until it is completed. But if there is an error during
> its execution, I'd like to show the call stack. Is it possible without
> using hooks?
Yes. In C you can do the same:
/* untested code */
...
lua_pushliteral (L, "_TRACEBACK");
lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */
err_func = lua_gettop (L);
/* push function to call */
/* push arguments */
status = lua_pcall (L, <n_args>, <n_results>, err_func);
...
See the reference manual for details. And I think the standalone
interpreter is a good example. If you're calling a C function, there is
lua_cpcall. Check the manual!
Hope it will helps,
Tomas