lua-users home
lua-l archive

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


Hello Tomas,

>> 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?

T> Yes.  In C you can do the same:

T> /* untested code */
T> ..
T> lua_pushliteral (L, "_TRACEBACK");
T> lua_rawget(L, LUA_GLOBALSINDEX);  /* get traceback function */
T> err_func = lua_gettop (L);
T> /* push function to call */
T> /* push arguments */
T> status = lua_pcall (L, <n_args>, <n_results>, err_func);
T> ..

T> See the reference manual for details.  And I think the standalone
T> interpreter is a good example.  If you're calling a C function, there is
T> lua_cpcall.  Check the manual!

T> Hope it will helps,

I've read about lua_pcall in manual, but found that lua_resume doesn't
use it, but you mean, that if I'd use lua_cpcall for starting C
function in which start lua_resume for the lua thread, then I can get
all the stack (and thread stack too)? Thank you, i'll check this asap.

-- 
Best regards,
 Dmitriy                            mailto:iassenev@gsc-game.kiev.ua