MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / serverLogObjectDebugInfo

Function serverLogObjectDebugInfo

src/debug.cpp:1047–1080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045}
1046
1047void serverLogObjectDebugInfo(robj_roptr o) {
1048 serverLog(LL_WARNING,"Object type: %d", o->type);
1049 serverLog(LL_WARNING,"Object encoding: %d", o->encoding);
1050 serverLog(LL_WARNING,"Object refcount: %d", static_cast<int>(o->getrefcount(std::memory_order_relaxed)));
1051#if UNSAFE_CRASH_REPORT
1052 /* This code is now disabled. o->ptr may be unreliable to print. in some
1053 * cases a ziplist could have already been freed by realloc, but not yet
1054 * updated to o->ptr. in other cases the call to ziplistLen may need to
1055 * iterate on all the items in the list (and possibly crash again).
1056 * For some cases it may be ok to crash here again, but these could cause
1057 * invalid memory access which will bother valgrind and also possibly cause
1058 * random memory portion to be "leaked" into the logfile. */
1059 if (o->type == OBJ_STRING && sdsEncodedObject(o)) {
1060 serverLog(LL_WARNING,"Object raw string len: %zu", sdslen(szFromObj(o)));
1061 if (sdslen(szFromObj(o)) < 4096) {
1062 sds repr = sdscatrepr(sdsempty(),szFromObj(o),sdslen(szFromObj(o)));
1063 serverLog(LL_WARNING,"Object raw string content: %s", repr);
1064 sdsfree(repr);
1065 }
1066 } else if (o->type == OBJ_LIST) {
1067 serverLog(LL_WARNING,"List length: %d", (int) listTypeLength(o));
1068 } else if (o->type == OBJ_SET) {
1069 serverLog(LL_WARNING,"Set size: %d", (int) setTypeSize(o));
1070 } else if (o->type == OBJ_HASH) {
1071 serverLog(LL_WARNING,"Hash size: %d", (int) hashTypeLength(o));
1072 } else if (o->type == OBJ_ZSET) {
1073 serverLog(LL_WARNING,"Sorted set size: %d", (int) zsetLength(o));
1074 if (o->encoding == OBJ_ENCODING_SKIPLIST)
1075 serverLog(LL_WARNING,"Skiplist level: %d", (int) ((const zset*)ptrFromObj(o))->zsl->level);
1076 } else if (o->type == OBJ_STREAM) {
1077 serverLog(LL_WARNING,"Stream size: %d", (int) streamLength(o));
1078 }
1079#endif
1080}
1081
1082void _serverAssertPrintObject(robj_roptr o) {
1083 bugReportStart();

Callers 2

_serverAssertPrintObjectFunction · 0.85
logCurrentClientFunction · 0.85

Calls 13

serverLogFunction · 0.85
sdslenFunction · 0.85
szFromObjFunction · 0.85
sdscatreprFunction · 0.85
sdsemptyFunction · 0.85
sdsfreeFunction · 0.85
listTypeLengthFunction · 0.85
setTypeSizeFunction · 0.85
hashTypeLengthFunction · 0.85
zsetLengthFunction · 0.85
ptrFromObjFunction · 0.85
streamLengthFunction · 0.85

Tested by

no test coverage detected