Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
75788d6a
Commit
75788d6a
authored
Nov 13, 2015
by
antirez
Browse files
Lua debugger: better support for synchronous mode.
parent
cdb92412
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
75788d6a
...
...
@@ -112,7 +112,8 @@ static struct config {
char prompt[128];
char *eval;
int eval_ldb;
int eval_ldb_end;
int eval_ldb_sync; /* Ask for synchronous mode of the Lua debugger. */
int eval_ldb_end; /* Lua debugging session ended. */
int last_cmd_type;
} config;
...
...
@@ -890,6 +891,10 @@ static int parseOptions(int argc, char **argv) {
} else if (!strcmp(argv[i],"--ldb")) {
config.eval_ldb = 1;
config.output = OUTPUT_RAW;
} else if (!strcmp(argv[i],"--ldb-sync-mode")) {
config.eval_ldb = 1;
config.eval_ldb_sync = 1;
config.output = OUTPUT_RAW;
} else if (!strcmp(argv[i],"-c")) {
config.cluster_mode = 1;
} else if (!strcmp(argv[i],"-d") && !lastarg) {
...
...
@@ -973,6 +978,9 @@ static void usage(void) {
" The test will run for the specified amount of seconds.\n"
" --eval <file> Send an EVAL command using the Lua script at <file>.\n"
" --ldb Used with --eval enable the Redis Lua debugger.\n"
" --ldb-sync-mode Like --ldb but uses the synchronous Lua debugger, in\n"
" this mode the server is blocked and script changes are\n"
" are not rolled back from the server memory.\n"
" --help Output this help and exit.\n"
" --version Output version and exit.\n"
"\n"
...
...
@@ -1116,7 +1124,9 @@ static void repl(void) {
if (config.eval_ldb_end) {
config.eval_ldb_end = 0;
cliReadReply(0);
printf("\n(Lua debugging session ended. Dataset changes rolled back)\n\n");
printf("\n(Lua debugging session ended%s)\n\n",
config.eval_ldb_sync ? "" :
" -- dataset changes rolled back");
}
elapsed = mstime()-start_time;
...
...
@@ -1172,7 +1182,8 @@ static int evalMode(int argc, char **argv) {
/* If we are debugging a script, enable the Lua debugger. */
if (config.eval_ldb) {
redisReply *reply = redisCommand(context, "SCRIPT DEBUG yes");
redisReply *reply = redisCommand(context,
config.eval_ldb_sync ? "SCRIPT DEBUG sync": "SCRIPT DEBUG yes");
if (reply) freeReplyObject(reply);
}
...
...
@@ -2321,6 +2332,8 @@ int main(int argc, char **argv) {
config.auth = NULL;
config.eval = NULL;
config.eval_ldb = 0;
config.eval_ldb_end = 0;
config.eval_ldb_sync = 0;
config.last_cmd_type = -1;
spectrum_palette = spectrum_palette_color;
...
...
src/scripting.c
View file @
75788d6a
...
...
@@ -1581,6 +1581,9 @@ int ldbStartSession(client *c) {
freeClientAsync(c); /* Close the client in the parent side. */
return 0;
}
} else {
serverLog(LL_WARNING,
"Redis synchronous debugging eval session started");
}
/* Setup our debugging session. */
...
...
@@ -1615,6 +1618,9 @@ void ldbEndSession(client *c) {
writeToClient(c->fd, c, 0);
serverLog(LL_WARNING,"Lua debugging session child exiting");
exitFromChild(0);
} else {
serverLog(LL_WARNING,
"Redis synchronous debugging eval session ended");
}
/* Otherwise let's restore client's state. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment