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

Function ldbPrintAll

src/scripting.cpp:2512–2534  ·  view source on GitHub ↗

Implements the "print" command (without arguments) of the Lua debugger. * Prints all the variables in the current stack frame. */

Source from the content-addressed store, hash-verified

2510/* Implements the "print" command (without arguments) of the Lua debugger.
2511 * Prints all the variables in the current stack frame. */
2512void ldbPrintAll(lua_State *lua) {
2513 lua_Debug ar;
2514 int vars = 0;
2515
2516 if (lua_getstack(lua,0,&ar) != 0) {
2517 const char *name;
2518 int i = 1; /* Variable index. */
2519 while((name = lua_getlocal(lua,&ar,i)) != NULL) {
2520 i++;
2521 if (!strstr(name,"(*temporary)")) {
2522 sds prefix = sdscatprintf(sdsempty(),"<value> %s = ",name);
2523 ldbLogStackValue(lua,prefix);
2524 sdsfree(prefix);
2525 vars++;
2526 }
2527 lua_pop(lua,1);
2528 }
2529 }
2530
2531 if (vars == 0) {
2532 ldbLog(sdsnew("No local variables in the current context."));
2533 }
2534}
2535
2536/* Implements the break command to list, add and remove breakpoints. */
2537void ldbBreak(sds *argv, int argc) {

Callers 1

ldbReplFunction · 0.85

Calls 8

lua_getstackFunction · 0.85
lua_getlocalFunction · 0.85
sdscatprintfFunction · 0.85
sdsemptyFunction · 0.85
ldbLogStackValueFunction · 0.85
sdsfreeFunction · 0.85
ldbLogFunction · 0.85
sdsnewFunction · 0.85

Tested by

no test coverage detected