From fb53459ce8053d0345fe2ef663fb681d25307855 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 16 Nov 2015 12:26:02 +0100 Subject: [PATCH] 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. --- src/scripting.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/scripting.c b/src/scripting.c index d9f40b36..5f774b71 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 Show the value of the specified variable.")); ldbLog(sdsnew("[b]reak Show all breakpoints.")); ldbLog(sdsnew("[b]reak 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(" Unknown Redis Lua debugger command or " "wrong number of arguments."));