MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaL_traceback

Function luaL_traceback

lib/lua/src/lauxlib.c:132–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

msghandlerFunction · 0.85
db_tracebackFunction · 0.85

Calls 9

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

Tested by

no test coverage detected