diff options
Diffstat (limited to 'examples/redis-unstable/src/redisassert.h')
| -rw-r--r-- | examples/redis-unstable/src/redisassert.h | 35 |
1 files changed, 35 insertions, 0 deletions
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 @@ | |||
| 1 | /* redisassert.h -- Drop in replacements assert.h that prints the stack trace | ||
| 2 | * in the Redis logs. | ||
| 3 | * | ||
| 4 | * This file should be included instead of "assert.h" inside libraries used by | ||
| 5 | * Redis that are using assertions, so instead of Redis disappearing with | ||
| 6 | * SIGABORT, we get the details and stack trace inside the log file. | ||
| 7 | * | ||
| 8 | * ---------------------------------------------------------------------------- | ||
| 9 | * | ||
| 10 | * Copyright (c) 2006-Present, Redis Ltd. | ||
| 11 | * All rights reserved. | ||
| 12 | * | ||
| 13 | * Licensed under your choice of (a) the Redis Source Available License 2.0 | ||
| 14 | * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the | ||
| 15 | * GNU Affero General Public License v3 (AGPLv3). | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef __REDIS_ASSERT_H__ | ||
| 19 | #define __REDIS_ASSERT_H__ | ||
| 20 | |||
| 21 | #include "config.h" | ||
| 22 | |||
| 23 | #define assert(_e) (likely((_e))?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),redis_unreachable())) | ||
| 24 | #define panic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),redis_unreachable() | ||
| 25 | |||
| 26 | void _serverAssert(const char *estr, const char *file, int line); | ||
| 27 | void _serverPanic(const char *file, int line, const char *msg, ...); | ||
| 28 | |||
| 29 | #ifdef DEBUG_ASSERTIONS | ||
| 30 | #define debugAssert(_e) assert(_e) | ||
| 31 | #else | ||
| 32 | #define debugAssert(_e) ((void)0) | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #endif | ||
