MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ldbTrace

Function ldbTrace

src/scripting.cpp:2646–2663  ·  view source on GitHub ↗

Implements "trace" command of the Lua debugger. It just prints a backtrace * querying Lua starting from the current callframe back to the outer one. */

Source from the content-addressed store, hash-verified

2644/* Implements "trace" command of the Lua debugger. It just prints a backtrace
2645 * querying Lua starting from the current callframe back to the outer one. */
2646void ldbTrace(lua_State *lua) {
2647 lua_Debug ar;
2648 int level = 0;
2649
2650 while(lua_getstack(lua,level,&ar)) {
2651 lua_getinfo(lua,"Snl",&ar);
2652 if(strstr(ar.short_src,"user_script") != NULL) {
2653 ldbLog(sdscatprintf(sdsempty(),"%s %s:",
2654 (level == 0) ? "In" : "From",
2655 ar.name ? ar.name : "top level"));
2656 ldbLogSourceLine(ar.currentline);
2657 }
2658 level++;
2659 }
2660 if (level == 0) {
2661 ldbLog(sdsnew("<error> Can't retrieve Lua stack."));
2662 }
2663}
2664
2665/* Implements the debugger "maxlen" command. It just queries or sets the
2666 * ldb.maxlen variable. */

Callers 1

ldbReplFunction · 0.85

Calls 7

lua_getstackFunction · 0.85
lua_getinfoFunction · 0.85
ldbLogFunction · 0.85
sdscatprintfFunction · 0.85
sdsemptyFunction · 0.85
ldbLogSourceLineFunction · 0.85
sdsnewFunction · 0.85

Tested by

no test coverage detected