Lua debugger: default behavior of "list" command changed.

Now it lists code around the current position by default. Can list any
other part using other arguments, but a new "whole" command was added in
order to show the whole source code easily.
This commit is contained in:
antirez 2015-11-16 12:26:02 +01:00
parent 6de2306add
commit fb53459ce8

View File

@ -2151,8 +2151,12 @@ ldbLog(sdsnew("[h]elp Show this help."));
ldbLog(sdsnew("[s]tep Run current line and stop again.")); ldbLog(sdsnew("[s]tep Run current line and stop again."));
ldbLog(sdsnew("[n]ext Alias for step.")); ldbLog(sdsnew("[n]ext Alias for step."));
ldbLog(sdsnew("[c]continue Run till next breakpoint.")); ldbLog(sdsnew("[c]continue Run till next breakpoint."));
ldbLog(sdsnew("[l]list [line] List source code, around [line] if specified")); ldbLog(sdsnew("[l]list List source code around current line."));
ldbLog(sdsnew(" you can use another arg for context size.")); ldbLog(sdsnew("[l]list [line] List source code around [line]."));
ldbLog(sdsnew(" line = 0 means: current position."));
ldbLog(sdsnew("[l]list [line] [ctx] In this form [ctx] specifies how many lines"));
ldbLog(sdsnew(" to show before/after [line]."));
ldbLog(sdsnew("[w]hole List all source code. Alias for 'list 1 1000000'."));
ldbLog(sdsnew("[p]rint <var> Show the value of the specified variable.")); ldbLog(sdsnew("[p]rint <var> Show the value of the specified variable."));
ldbLog(sdsnew("[b]reak Show all breakpoints.")); 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."));
@ -2193,11 +2197,17 @@ ldbLog(sdsnew(" in the next line of code."));
ldbPrint(lua,argv[1]); ldbPrint(lua,argv[1]);
ldbSendLogs(); ldbSendLogs();
} else if (!strcasecmp(argv[0],"l") || !strcasecmp(argv[0],"list")){ } else if (!strcasecmp(argv[0],"l") || !strcasecmp(argv[0],"list")){
int around = 0, ctx = 5; int around = ldb.currentline, ctx = 5;
if (argc > 1) around = atoi(argv[1]); if (argc > 1) {
int num = atoi(argv[1]);
if (num > 0) around = num;
}
if (argc > 2) ctx = atoi(argv[2]); if (argc > 2) ctx = atoi(argv[2]);
ldbList(around,ctx); ldbList(around,ctx);
ldbSendLogs(); ldbSendLogs();
} else if (!strcasecmp(argv[0],"w") || !strcasecmp(argv[0],"whole")){
ldbList(1,1000000);
ldbSendLogs();
} else { } else {
ldbLog(sdsnew("<error> Unknown Redis Lua debugger command or " ldbLog(sdsnew("<error> Unknown Redis Lua debugger command or "
"wrong number of arguments.")); "wrong number of arguments."));