In Lua, I have a function called utils.debug() , and I would like to use it in my Lua code as follows:
function Foo:doSomething if (/* something */) then print("Success!") else utils.debug() end end function Foo:doSomethingElse if (/* something else */) then print("Awesome!") else utils.debug() end end
I would like to use it in all my Lua code to help me debug. As a result, I would like my C ++ code to know where utils.debug() is called in the Lua code. I looked at lua_Debug and lua_getinfo , and they seem pretty close to what I want, but I miss the part:
int MyLua::debug(lua_State* L) { lua_Debug ar; lua_getstack(L, 1, &ar); lua_getinfo(L, ??????, &ar); // print out relevant info from 'ar' // such as in what function it was called, line number, etc }
Is this a lua_Debug structure for or is there another tool or method that I should use for this?
source share