mirror of https://mirror.osredm.com/root/redis.git
Add debug script command (#13289)
Add two new debug commands for outputing script. 1. `DEBUG SCRIPT LIST` Output all scripts. 2. `DEBUG SCRIPT <sha1>` Output a specific script. Close #3846
This commit is contained in:
parent
a03b6e29a9
commit
811c5d7aeb
24
src/debug.c
24
src/debug.c
|
@ -15,6 +15,7 @@
|
||||||
#include "fpconv_dtoa.h"
|
#include "fpconv_dtoa.h"
|
||||||
#include "cluster.h"
|
#include "cluster.h"
|
||||||
#include "threads_mngr.h"
|
#include "threads_mngr.h"
|
||||||
|
#include "script.h"
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
@ -1013,6 +1014,29 @@ NULL
|
||||||
} else if (!strcasecmp(c->argv[1]->ptr, "dict-resizing") && c->argc == 3) {
|
} else if (!strcasecmp(c->argv[1]->ptr, "dict-resizing") && c->argc == 3) {
|
||||||
server.dict_resizing = atoi(c->argv[2]->ptr);
|
server.dict_resizing = atoi(c->argv[2]->ptr);
|
||||||
addReply(c, shared.ok);
|
addReply(c, shared.ok);
|
||||||
|
} else if (!strcasecmp(c->argv[1]->ptr,"script") && c->argc == 3) {
|
||||||
|
if (!strcasecmp(c->argv[2]->ptr,"list")) {
|
||||||
|
dictIterator *di = dictGetIterator(getLuaScripts());
|
||||||
|
dictEntry *de;
|
||||||
|
while ((de = dictNext(di)) != NULL) {
|
||||||
|
luaScript *script = dictGetVal(de);
|
||||||
|
sds *sha = dictGetKey(de);
|
||||||
|
serverLog(LL_WARNING, "SCRIPT SHA: %s\n%s", (char*)sha, (char*)script->body->ptr);
|
||||||
|
}
|
||||||
|
dictReleaseIterator(di);
|
||||||
|
} else if (sdslen(c->argv[2]->ptr) == 40) {
|
||||||
|
dictEntry *de;
|
||||||
|
if ((de = dictFind(getLuaScripts(), c->argv[2]->ptr)) == NULL) {
|
||||||
|
addReplyErrorObject(c, shared.noscripterr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
luaScript *script = dictGetVal(de);
|
||||||
|
serverLog(LL_WARNING, "SCRIPT SHA: %s\n%s", (char*)c->argv[2]->ptr, (char*)script->body->ptr);
|
||||||
|
} else {
|
||||||
|
addReplySubcommandSyntaxError(c);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addReply(c,shared.ok);
|
||||||
} else if(!handleDebugClusterCommand(c)) {
|
} else if(!handleDebugClusterCommand(c)) {
|
||||||
addReplySubcommandSyntaxError(c);
|
addReplySubcommandSyntaxError(c);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1737,3 +1737,7 @@ void luaLdbLineHook(lua_State *lua, lua_Debug *ar) {
|
||||||
rctx->start_time = getMonotonicUs();
|
rctx->start_time = getMonotonicUs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dict *getLuaScripts(void) {
|
||||||
|
return lctx.lua_scripts;
|
||||||
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ extern scriptFlag scripts_flags_def[];
|
||||||
|
|
||||||
void luaEnvInit(void);
|
void luaEnvInit(void);
|
||||||
lua_State *createLuaState(void);
|
lua_State *createLuaState(void);
|
||||||
|
dict *getLuaScripts(void);
|
||||||
uint64_t scriptFlagsToCmdFlags(uint64_t cmd_flags, uint64_t script_flags);
|
uint64_t scriptFlagsToCmdFlags(uint64_t cmd_flags, uint64_t script_flags);
|
||||||
int scriptPrepareForRun(scriptRunCtx *r_ctx, client *engine_client, client *caller, const char *funcname, uint64_t script_flags, int ro);
|
int scriptPrepareForRun(scriptRunCtx *r_ctx, client *engine_client, client *caller, const char *funcname, uint64_t script_flags, int ro);
|
||||||
void scriptResetRun(scriptRunCtx *r_ctx);
|
void scriptResetRun(scriptRunCtx *r_ctx);
|
||||||
|
|
Loading…
Reference in New Issue