From 5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 21 Jan 2026 22:40:55 +0100 Subject: Add Redis source code for testing --- examples/redis-unstable/src/redisassert.h | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/redis-unstable/src/redisassert.h (limited to 'examples/redis-unstable/src/redisassert.h') diff --git a/examples/redis-unstable/src/redisassert.h b/examples/redis-unstable/src/redisassert.h new file mode 100644 index 0000000..4de8d5c --- /dev/null +++ b/examples/redis-unstable/src/redisassert.h @@ -0,0 +1,35 @@ +/* redisassert.h -- Drop in replacements assert.h that prints the stack trace + * in the Redis logs. + * + * This file should be included instead of "assert.h" inside libraries used by + * Redis that are using assertions, so instead of Redis disappearing with + * SIGABORT, we get the details and stack trace inside the log file. + * + * ---------------------------------------------------------------------------- + * + * Copyright (c) 2006-Present, Redis Ltd. + * All rights reserved. + * + * Licensed under your choice of (a) the Redis Source Available License 2.0 + * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the + * GNU Affero General Public License v3 (AGPLv3). + */ + +#ifndef __REDIS_ASSERT_H__ +#define __REDIS_ASSERT_H__ + +#include "config.h" + +#define assert(_e) (likely((_e))?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),redis_unreachable())) +#define panic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),redis_unreachable() + +void _serverAssert(const char *estr, const char *file, int line); +void _serverPanic(const char *file, int line, const char *msg, ...); + +#ifdef DEBUG_ASSERTIONS +#define debugAssert(_e) assert(_e) +#else +#define debugAssert(_e) ((void)0) +#endif + +#endif -- cgit v1.2.3