MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaL_traceback

Function luaL_traceback

extlibs/lua/src/lauxlib.c:131–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129
130
131LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1,
132 const char *msg, int level) {
133 luaL_Buffer b;
134 lua_Debug ar;
135 int last = lastlevel(L1);
136 int limit2show = (last - level > LEVELS1 + LEVELS2) ? LEVELS1 : -1;
137 luaL_buffinit(L, &b);
138 if (msg) {
139 luaL_addstring(&b, msg);
140 luaL_addchar(&b, '\n');
141 }
142 luaL_addstring(&b, "stack traceback:");
143 while (lua_getstack(L1, level++, &ar)) {
144 if (limit2show-- == 0) { /* too many levels? */
145 int n = last - level - LEVELS2 + 1; /* number of levels to skip */
146 lua_pushfstring(L, "\n\t...\t(skipping %d levels)", n);
147 luaL_addvalue(&b); /* add warning about skip */
148 level += n; /* and skip to last levels */
149 }
150 else {
151 lua_getinfo(L1, "Slnt", &ar);
152 if (ar.currentline <= 0)
153 lua_pushfstring(L, "\n\t%s: in ", ar.short_src);
154 else
155 lua_pushfstring(L, "\n\t%s:%d: in ", ar.short_src, ar.currentline);
156 luaL_addvalue(&b);
157 pushfuncname(L, &ar);
158 luaL_addvalue(&b);
159 if (ar.istailcall)
160 luaL_addstring(&b, "\n\t(...tail calls...)");
161 }
162 }
163 luaL_pushresult(&b);
164}
165
166/* }====================================================== */
167

Callers 2

msghandlerFunction · 0.70
db_tracebackFunction · 0.70

Calls 9

lastlevelFunction · 0.85
luaL_addstringFunction · 0.85
lua_getstackFunction · 0.85
lua_pushfstringFunction · 0.85
lua_getinfoFunction · 0.85
pushfuncnameFunction · 0.85
luaL_buffinitFunction · 0.70
luaL_addvalueFunction · 0.70
luaL_pushresultFunction · 0.70

Tested by

no test coverage detected