MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaL_traceback

Function luaL_traceback

third-party/lua-5.5.0/src/lauxlib.c:127–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

msghandlerFunction · 0.70
db_tracebackFunction · 0.70

Calls 9

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

Tested by

no test coverage detected