summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-11-16 12:26:02 +0100
committerantirez <antirez@gmail.com>2015-11-17 15:43:23 +0100
commitfb53459ce8053d0345fe2ef663fb681d25307855 (patch)
tree56debd1e299a6fab0e838a9ae67d94f1a9553163
parent6de2306add95460a488d76e57b5cf2b5db17d5da (diff)
downloadredis-fb53459ce8053d0345fe2ef663fb681d25307855.tar.gz
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.
-rw-r--r--src/scripting.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/scripting.c b/src/scripting.c
index d9f40b364..5f774b712 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -2151,8 +2151,12 @@ ldbLog(sdsnew("[h]elp Show this help."));
ldbLog(sdsnew("[s]tep Run current line and stop again."));
ldbLog(sdsnew("[n]ext Alias for step."));
ldbLog(sdsnew("[c]continue Run till next breakpoint."));
-ldbLog(sdsnew("[l]list [line] List source code, around [line] if specified"));
-ldbLog(sdsnew(" you can use another arg for context size."));
+ldbLog(sdsnew("[l]list List source code around current line."));
+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("[b]reak Show all breakpoints."));
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]);
ldbSendLogs();
} else if (!strcasecmp(argv[0],"l") || !strcasecmp(argv[0],"list")){
- int around = 0, ctx = 5;
- if (argc > 1) around = atoi(argv[1]);
+ int around = ldb.currentline, ctx = 5;
+ if (argc > 1) {
+ int num = atoi(argv[1]);
+ if (num > 0) around = num;
+ }
if (argc > 2) ctx = atoi(argv[2]);
ldbList(around,ctx);
ldbSendLogs();
+ } else if (!strcasecmp(argv[0],"w") || !strcasecmp(argv[0],"whole")){
+ ldbList(1,1000000);
+ ldbSendLogs();
} else {
ldbLog(sdsnew("<error> Unknown Redis Lua debugger command or "
"wrong number of arguments."));