diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-02 15:15:28 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-02 15:15:28 +0200 |
commit | 20b64e18e49550e7a105899045fd51be192e86bc (patch) | |
tree | c261c71ea2feb99bc5d4b058da5811c6b80db70c /source/LuaState.cpp | |
parent | Minecart enhancements [SEE DESC] (diff) | |
parent | Exported BroadcastSoundEffect and BroadcastSoundParticleEffect to the Lua API (diff) | |
download | cuberite-20b64e18e49550e7a105899045fd51be192e86bc.tar cuberite-20b64e18e49550e7a105899045fd51be192e86bc.tar.gz cuberite-20b64e18e49550e7a105899045fd51be192e86bc.tar.bz2 cuberite-20b64e18e49550e7a105899045fd51be192e86bc.tar.lz cuberite-20b64e18e49550e7a105899045fd51be192e86bc.tar.xz cuberite-20b64e18e49550e7a105899045fd51be192e86bc.tar.zst cuberite-20b64e18e49550e7a105899045fd51be192e86bc.zip |
Diffstat (limited to '')
-rw-r--r-- | source/LuaState.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/LuaState.cpp b/source/LuaState.cpp index bbf47fb27..8d2fa8eca 100644 --- a/source/LuaState.cpp +++ b/source/LuaState.cpp @@ -884,6 +884,49 @@ bool cLuaState::ReportErrors(lua_State * a_LuaState, int a_Status) +void cLuaState::LogStackTrace(void) +{ + LOGWARNING("Stack trace:"); + lua_Debug entry; + int depth = 0; + while (lua_getstack(m_LuaState, depth, &entry)) + { + int status = lua_getinfo(m_LuaState, "Sln", &entry); + assert(status); + + LOGWARNING(" %s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "?"); + depth++; + } + LOGWARNING("Stack trace end"); +} + + + + + +AString cLuaState::GetTypeText(int a_StackPos) +{ + int Type = lua_type(m_LuaState, a_StackPos); + switch (Type) + { + case LUA_TNONE: return "TNONE"; + case LUA_TNIL: return "TNIL"; + case LUA_TBOOLEAN: return "TBOOLEAN"; + case LUA_TLIGHTUSERDATA: return "TLIGHTUSERDATA"; + case LUA_TNUMBER: return "TNUMBER"; + case LUA_TSTRING: return "TSTRING"; + case LUA_TTABLE: return "TTABLE"; + case LUA_TFUNCTION: return "TFUNCTION"; + case LUA_TUSERDATA: return "TUSERDATA"; + case LUA_TTHREAD: return "TTHREAD"; + } + return Printf("Unknown (%d)", Type); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cLuaState::cRef: |