MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaL_traceback

Function luaL_traceback

depends/lua/src/lauxlib.c:125–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124
125LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1,
126 const char *msg, int level) {
127 lua_Debug ar;
128 int top = lua_gettop(L);
129 int last = lastlevel(L1);
130 int n1 = (last - level > LEVELS1 + LEVELS2) ? LEVELS1 : -1;
131 if (msg)
132 lua_pushfstring(L, "%s\n", msg);
133 luaL_checkstack(L, 10, NULL);
134 lua_pushliteral(L, "stack traceback:");
135 while (lua_getstack(L1, level++, &ar)) {
136 if (n1-- == 0) { /* too many levels? */
137 lua_pushliteral(L, "\n\t..."); /* add a '...' */
138 level = last - LEVELS2 + 1; /* and skip to last ones */
139 }
140 else {
141 lua_getinfo(L1, "Slnt", &ar);
142 lua_pushfstring(L, "\n\t%s:", ar.short_src);
143 if (ar.currentline > 0)
144 lua_pushfstring(L, "%d:", ar.currentline);
145 lua_pushliteral(L, " in ");
146 pushfuncname(L, &ar);
147 if (ar.istailcall)
148 lua_pushliteral(L, "\n\t(...tail calls...)");
149 lua_concat(L, lua_gettop(L) - top);
150 }
151 }
152 lua_concat(L, lua_gettop(L) - top);
153}
154
155/* }====================================================== */
156

Callers 3

convert_to_exceptionFunction · 0.85
msghandlerFunction · 0.85
db_tracebackFunction · 0.85

Calls 8

lua_gettopFunction · 0.85
lastlevelFunction · 0.85
lua_pushfstringFunction · 0.85
luaL_checkstackFunction · 0.85
lua_getstackFunction · 0.85
lua_getinfoFunction · 0.85
pushfuncnameFunction · 0.85
lua_concatFunction · 0.85

Tested by

no test coverage detected