mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Lua debugger: redis-cli can restart Lua debugging sessions.
This commit is contained in:
parent
0cc19174f9
commit
58573f1dd2
@ -1106,6 +1106,12 @@ static void repl(void) {
|
|||||||
strcasecmp(argv[0],"exit") == 0)
|
strcasecmp(argv[0],"exit") == 0)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
|
} else if (strcasecmp(argv[0],"restart") == 0) {
|
||||||
|
if (config.eval_ldb) {
|
||||||
|
return; /* Return to evalMode to restart the session. */
|
||||||
|
} else {
|
||||||
|
printf("Use 'restart' only in Lua debugging mode.");
|
||||||
|
}
|
||||||
} else if (argc == 3 && !strcasecmp(argv[0],"connect")) {
|
} else if (argc == 3 && !strcasecmp(argv[0],"connect")) {
|
||||||
sdsfree(config.hostip);
|
sdsfree(config.hostip);
|
||||||
config.hostip = sdsnew(argv[1]);
|
config.hostip = sdsnew(argv[1]);
|
||||||
@ -1169,12 +1175,28 @@ static int noninteractive(int argc, char **argv) {
|
|||||||
*--------------------------------------------------------------------------- */
|
*--------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int evalMode(int argc, char **argv) {
|
static int evalMode(int argc, char **argv) {
|
||||||
sds script = sdsempty();
|
sds script = NULL;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
size_t nread;
|
size_t nread;
|
||||||
char **argv2;
|
char **argv2;
|
||||||
int j, got_comma = 0, keys = 0;
|
int j, got_comma, keys;
|
||||||
|
int retval = REDIS_OK;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
if (config.eval_ldb) {
|
||||||
|
printf(
|
||||||
|
"Lua debugging session started, please use:\n"
|
||||||
|
"quit -- End the session.\n"
|
||||||
|
"restart -- Restart the script in debug mode again.\n"
|
||||||
|
"help -- Show Lua script debugging commands.\n\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sdsfree(script);
|
||||||
|
script = sdsempty();
|
||||||
|
got_comma = 0;
|
||||||
|
keys = 0;
|
||||||
|
|
||||||
/* Load the script from the file, as an sds string. */
|
/* Load the script from the file, as an sds string. */
|
||||||
fp = fopen(config.eval,"r");
|
fp = fopen(config.eval,"r");
|
||||||
@ -1191,7 +1213,8 @@ static int evalMode(int argc, char **argv) {
|
|||||||
/* If we are debugging a script, enable the Lua debugger. */
|
/* If we are debugging a script, enable the Lua debugger. */
|
||||||
if (config.eval_ldb) {
|
if (config.eval_ldb) {
|
||||||
redisReply *reply = redisCommand(context,
|
redisReply *reply = redisCommand(context,
|
||||||
config.eval_ldb_sync ? "SCRIPT DEBUG sync": "SCRIPT DEBUG yes");
|
config.eval_ldb_sync ?
|
||||||
|
"SCRIPT DEBUG sync": "SCRIPT DEBUG yes");
|
||||||
if (reply) freeReplyObject(reply);
|
if (reply) freeReplyObject(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1211,7 +1234,7 @@ static int evalMode(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Call it */
|
/* Call it */
|
||||||
int eval_ldb = config.eval_ldb; /* Save it, may be reverteed. */
|
int eval_ldb = config.eval_ldb; /* Save it, may be reverteed. */
|
||||||
int retval = issueCommand(argc+3-got_comma, argv2);
|
retval = issueCommand(argc+3-got_comma, argv2);
|
||||||
if (eval_ldb) {
|
if (eval_ldb) {
|
||||||
if (!config.eval_ldb) {
|
if (!config.eval_ldb) {
|
||||||
/* If the debugging session ended immediately, there was an
|
/* If the debugging session ended immediately, there was an
|
||||||
@ -1219,9 +1242,16 @@ static int evalMode(int argc, char **argv) {
|
|||||||
* the REPL at all. */
|
* the REPL at all. */
|
||||||
printf("Eval debugging session can't start:\n");
|
printf("Eval debugging session can't start:\n");
|
||||||
cliReadReply(0);
|
cliReadReply(0);
|
||||||
|
break; /* Return to the caller. */
|
||||||
} else {
|
} else {
|
||||||
strncpy(config.prompt,"lua debugger> ",sizeof(config.prompt));
|
strncpy(config.prompt,"lua debugger> ",sizeof(config.prompt));
|
||||||
repl();
|
repl();
|
||||||
|
/* Restart the session if repl() returned. */
|
||||||
|
cliConnect(1);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break; /* Return to the caller. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user