MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ldbRepl

Function ldbRepl

app/redis-6.2.6/src/scripting.c:2659–2786  ·  view source on GitHub ↗

Read debugging commands from client. * Return C_OK if the debugging session is continuing, otherwise * C_ERR if the client closed the connection or is timing out. */

Source from the content-addressed store, hash-verified

2657 * Return C_OK if the debugging session is continuing, otherwise
2658 * C_ERR if the client closed the connection or is timing out. */
2659int ldbRepl(lua_State *lua) {
2660 sds *argv;
2661 int argc;
2662 char* err = NULL;
2663
2664 /* We continue processing commands until a command that should return
2665 * to the Lua interpreter is found. */
2666 while(1) {
2667 while((argv = ldbReplParseCommand(&argc, &err)) == NULL) {
2668 char buf[1024];
2669 if (err) {
2670 lua_pushstring(lua, err);
2671 lua_error(lua);
2672 }
2673 int nread = connRead(ldb.conn,buf,sizeof(buf));
2674 if (nread <= 0) {
2675 /* Make sure the script runs without user input since the
2676 * client is no longer connected. */
2677 ldb.step = 0;
2678 ldb.bpcount = 0;
2679 return C_ERR;
2680 }
2681 ldb.cbuf = sdscatlen(ldb.cbuf,buf,nread);
2682 /* after 1M we will exit with an error
2683 * so that the client will not blow the memory
2684 */
2685 if (sdslen(ldb.cbuf) > 1<<20) {
2686 sdsfree(ldb.cbuf);
2687 ldb.cbuf = sdsempty();
2688 lua_pushstring(lua, "max client buffer reached");
2689 lua_error(lua);
2690 }
2691 }
2692
2693 /* Flush the old buffer. */
2694 sdsfree(ldb.cbuf);
2695 ldb.cbuf = sdsempty();
2696
2697 /* Execute the command. */
2698 if (!strcasecmp(argv[0],"h") || !strcasecmp(argv[0],"help")) {
2699ldbLog(sdsnew("Redis Lua debugger help:"));
2700ldbLog(sdsnew("[h]elp Show this help."));
2701ldbLog(sdsnew("[s]tep Run current line and stop again."));
2702ldbLog(sdsnew("[n]ext Alias for step."));
2703ldbLog(sdsnew("[c]continue Run till next breakpoint."));
2704ldbLog(sdsnew("[l]list List source code around current line."));
2705ldbLog(sdsnew("[l]list [line] List source code around [line]."));
2706ldbLog(sdsnew(" line = 0 means: current position."));
2707ldbLog(sdsnew("[l]list [line] [ctx] In this form [ctx] specifies how many lines"));
2708ldbLog(sdsnew(" to show before/after [line]."));
2709ldbLog(sdsnew("[w]hole List all source code. Alias for 'list 1 1000000'."));
2710ldbLog(sdsnew("[p]rint Show all the local variables."));
2711ldbLog(sdsnew("[p]rint <var> Show the value of the specified variable."));
2712ldbLog(sdsnew(" Can also show global vars KEYS and ARGV."));
2713ldbLog(sdsnew("[b]reak Show all breakpoints."));
2714ldbLog(sdsnew("[b]reak <line> Add a breakpoint to the specified line."));
2715ldbLog(sdsnew("[b]reak -<line> Remove breakpoint from the specified line."));
2716ldbLog(sdsnew("[b]reak 0 Remove all breakpoints."));

Callers 1

luaLdbLineHookFunction · 0.85

Calls 15

ldbReplParseCommandFunction · 0.85
connReadFunction · 0.85
sdscatlenFunction · 0.85
sdslenFunction · 0.85
sdsfreeFunction · 0.85
sdsemptyFunction · 0.85
strcasecmpFunction · 0.85
ldbLogFunction · 0.85
sdsnewFunction · 0.85
ldbSendLogsFunction · 0.85
ldbTraceFunction · 0.85
ldbMaxlenFunction · 0.85

Tested by

no test coverage detected