开发者

How do I use Lua hooks to find out the name of the currently running function?

开发者 https://www.devze.com 2023-02-05 10:03 出处:网络
I am currently running a Lua script with a hook attached using LUA_MASKCALL and the hook function implemented as follows:

I am currently running a Lua script with a hook attached using LUA_MASKCALL and the hook function implemented as follows:

void LuaHook(lua_开发者_C百科State *L, lua_Debug *ar) {
    switch(ar->event) {
        case LUA_HOOKCALL:
            lua_getinfo(L, ">n", ar);
            //breakpoint here...
        } break;
        default: 
            break;
    }
}

I would like to get the name of the called function, but am not sure I am doing it correctly since it never seems to give me anything (the breakpoint is hit at the appropriate times though). The functions that are called are bound C functions that do have names so that seems weird. Overall lua_getinfo is a complete mystery to me and the documentation does not clear things up either so any help would be greatly appreciated on this one.


lua_getstack did the trick so never mind

0

精彩评论

暂无评论...
验证码 换一张
取 消