Merge pull request #2033 from mc-server/BreakIntoDebugger
Lua: Break into ZBS debugger on API errors.
This commit is contained in:
commit
4ace226dcd
@ -927,6 +927,9 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
|
|||||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
|
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
|
||||||
|
|
||||||
|
BreakIntoDebugger(m_LuaState);
|
||||||
|
|
||||||
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||||
return false;
|
return false;
|
||||||
} // for i - Param
|
} // for i - Param
|
||||||
@ -1366,6 +1369,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
|
|||||||
{
|
{
|
||||||
LOGWARNING("LUA: %s", lua_tostring(a_LuaState, -1));
|
LOGWARNING("LUA: %s", lua_tostring(a_LuaState, -1));
|
||||||
LogStackTrace(a_LuaState, 1);
|
LogStackTrace(a_LuaState, 1);
|
||||||
|
BreakIntoDebugger(a_LuaState);
|
||||||
return 1; // We left the error message on the stack as the return value
|
return 1; // We left the error message on the stack as the return value
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1373,6 +1377,28 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cLuaState::BreakIntoDebugger(lua_State * a_LuaState)
|
||||||
|
{
|
||||||
|
// Call the BreakIntoDebugger function, if available:
|
||||||
|
lua_getglobal(a_LuaState, "BreakIntoDebugger");
|
||||||
|
if (!lua_isfunction(a_LuaState, -1))
|
||||||
|
{
|
||||||
|
LOGD("LUA: BreakIntoDebugger() not found / not a function");
|
||||||
|
lua_pop(a_LuaState, 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lua_insert(a_LuaState, -2); // Copy the string that has been passed to us
|
||||||
|
LOGD("Calling BreakIntoDebugger()...");
|
||||||
|
lua_call(a_LuaState, 1, 0);
|
||||||
|
LOGD("Returned from BreakIntoDebugger().");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// cLuaState::cRef:
|
// cLuaState::cRef:
|
||||||
|
|
||||||
|
@ -389,6 +389,9 @@ protected:
|
|||||||
|
|
||||||
/** Used as the error reporting function for function calls */
|
/** Used as the error reporting function for function calls */
|
||||||
static int ReportFnCallErrors(lua_State * a_LuaState);
|
static int ReportFnCallErrors(lua_State * a_LuaState);
|
||||||
|
|
||||||
|
/** Tries to break into the MobDebug debugger, if it is installed. */
|
||||||
|
static int BreakIntoDebugger(lua_State * a_LuaState);
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user