On crash print information about the current client (if any), command vector, and object associated to first argument assuming it is a key.

This commit is contained in:
antirez
2012-01-12 16:02:57 +01:00
parent d8bd12f984
commit 00010fa96f
4 changed files with 64 additions and 4 deletions

View File

@ -336,9 +336,7 @@ void _redisAssertPrintClientInfo(redisClient *c) {
}
}
void _redisAssertPrintObject(robj *o) {
bugReportStart();
redisLog(REDIS_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ===");
void redisLogObjectDebugInfo(robj *o) {
redisLog(REDIS_WARNING,"Object type: %d", o->type);
redisLog(REDIS_WARNING,"Object encoding: %d", o->encoding);
redisLog(REDIS_WARNING,"Object refcount: %d", o->refcount);
@ -346,9 +344,25 @@ void _redisAssertPrintObject(robj *o) {
redisLog(REDIS_WARNING,"Object raw string len: %d", sdslen(o->ptr));
if (sdslen(o->ptr) < 4096)
redisLog(REDIS_WARNING,"Object raw string content: \"%s\"", (char*)o->ptr);
} else if (o->type == REDIS_LIST) {
redisLog(REDIS_WARNING,"List length: %d", (int) listTypeLength(o));
} else if (o->type == REDIS_SET) {
redisLog(REDIS_WARNING,"Set size: %d", (int) setTypeSize(o));
} else if (o->type == REDIS_HASH) {
redisLog(REDIS_WARNING,"Hash size: %d", (int) hashTypeLength(o));
} else if (o->type == REDIS_ZSET) {
redisLog(REDIS_WARNING,"Sorted set size: %d", (int) zsetLength(o));
if (o->encoding == REDIS_ENCODING_SKIPLIST)
redisLog(REDIS_WARNING,"Skiplist level: %d", (int) ((zset*)o->ptr)->zsl->level);
}
}
void _redisAssertPrintObject(robj *o) {
bugReportStart();
redisLog(REDIS_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ===");
redisLogObjectDebugInfo(o);
}
void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int line) {
if (c) _redisAssertPrintClientInfo(c);
if (o) _redisAssertPrintObject(o);