thehan
thehan

Reputation: 301

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

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

void LuaHook(lua_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.

Upvotes: 2

Views: 1208

Answers (1)

thehan
thehan

Reputation: 301

lua_getstack did the trick so never mind

Upvotes: 3

Related Questions