mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Lua debugger: trace command implemented.
This commit is contained in:
parent
22959e07dc
commit
c560c645e9
@ -2145,6 +2145,26 @@ void ldbRedis(lua_State *lua, sds *argv, int argc) {
|
|||||||
lua_pop(lua,2); /* Discard the result and clean the stack. */
|
lua_pop(lua,2); /* Discard the result and clean the stack. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Implements "trace" command of the Lua debugger. It just prints a backtrace
|
||||||
|
* querying Lua starting from the current callframe back to the outer one. */
|
||||||
|
void ldbTrace(lua_State *lua) {
|
||||||
|
lua_Debug ar;
|
||||||
|
int level = 0;
|
||||||
|
|
||||||
|
while(lua_getstack(lua,level,&ar)) {
|
||||||
|
lua_getinfo(lua,"Snl",&ar);
|
||||||
|
if(strstr(ar.short_src,"user_script") == NULL) continue;
|
||||||
|
ldbLog(sdscatprintf(sdsempty(),"%s %s:",
|
||||||
|
(level == 0) ? "In" : "From",
|
||||||
|
ar.name ? ar.name : "top level"));
|
||||||
|
ldbLogSourceLine(ar.currentline);
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
if (level == 0) {
|
||||||
|
ldbLog(sdsnew("<error> Can't retrieve Lua stack."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Read debugging commands from client. */
|
/* Read debugging commands from client. */
|
||||||
void ldbRepl(lua_State *lua) {
|
void ldbRepl(lua_State *lua) {
|
||||||
sds *argv;
|
sds *argv;
|
||||||
@ -2190,6 +2210,7 @@ ldbLog(sdsnew("[b]reak Show all breakpoints."));
|
|||||||
ldbLog(sdsnew("[b]reak <line> Add a breakpoint to the specified line."));
|
ldbLog(sdsnew("[b]reak <line> Add a breakpoint to the specified line."));
|
||||||
ldbLog(sdsnew("[b]reak -<line> Remove breakpoint from the specified line."));
|
ldbLog(sdsnew("[b]reak -<line> Remove breakpoint from the specified line."));
|
||||||
ldbLog(sdsnew("[b]reak 0 Remove all breakpoints."));
|
ldbLog(sdsnew("[b]reak 0 Remove all breakpoints."));
|
||||||
|
ldbLog(sdsnew("[t]race Show a backtrace."));
|
||||||
ldbLog(sdsnew("[e]eval <code> Execute some Lua code (in a different callframe)."));
|
ldbLog(sdsnew("[e]eval <code> Execute some Lua code (in a different callframe)."));
|
||||||
ldbLog(sdsnew("[r]edis <cmd> Execute a Redis command."));
|
ldbLog(sdsnew("[r]edis <cmd> Execute a Redis command."));
|
||||||
ldbLog(sdsnew("[a]abort Stop the execution of the script. In sync"));
|
ldbLog(sdsnew("[a]abort Stop the execution of the script. In sync"));
|
||||||
@ -2206,6 +2227,9 @@ ldbLog(sdsnew(" in the next line of code."));
|
|||||||
break;
|
break;
|
||||||
} else if (!strcasecmp(argv[0],"c") || !strcasecmp(argv[0],"continue")){
|
} else if (!strcasecmp(argv[0],"c") || !strcasecmp(argv[0],"continue")){
|
||||||
break;
|
break;
|
||||||
|
} else if (!strcasecmp(argv[0],"t") || !strcasecmp(argv[0],"trace")) {
|
||||||
|
ldbTrace(lua);
|
||||||
|
ldbSendLogs();
|
||||||
} else if (!strcasecmp(argv[0],"b") || !strcasecmp(argv[0],"break")) {
|
} else if (!strcasecmp(argv[0],"b") || !strcasecmp(argv[0],"break")) {
|
||||||
ldbBreak(argv,argc);
|
ldbBreak(argv,argc);
|
||||||
ldbSendLogs();
|
ldbSendLogs();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user