#ifndef __CONFIG_H
#define __CONFIG_H
-/* malloc_size() */
+/* test for malloc_size() */
#ifdef __APPLE__
#include <malloc/malloc.h>
-#define HAVE_MALLOC_SIZE
+#define HAVE_MALLOC_SIZE 1
#define redis_malloc_size(p) malloc_size(p)
#endif
#define redis_stat stat
#endif
+/* test for backtrace() */
+#if defined(__APPLE__) || defined(__linux__)
+#define HAVE_BACKTRACE 1
+#endif
+
#endif
static void updateSalvesWaitingBgsave(int bgsaveerr);
static void freeMemoryIfNeeded(void);
static int processCommand(redisClient *c);
-static void segvHandler(int sig, siginfo_t *info, void *secret);
static void setupSigSegvAction(void);
static void authCommand(redisClient *c);
}
}
-#if defined(__APPLE__) || defined(__linux__)
+#ifdef HAVE_BACKTRACE
static struct redisFunctionSym symsTable[] = {
{"freeStringObject", (unsigned long)freeStringObject},
{"freeListObject", (unsigned long)freeListObject},
{"debugCommand", (unsigned long)debugCommand},
{"processCommand", (unsigned long)processCommand},
{"setupSigSegvAction", (unsigned long)setupSigSegvAction},
-{"segvHandler", (unsigned long)segvHandler},
{"readQueryFromClient", (unsigned long)readQueryFromClient},
{NULL,0}
};
trace[1] = getMcontextEip(uc);
messages = backtrace_symbols(trace, trace_size);
- for (i=0; i<trace_size; ++i) {
+ for (i=1; i<trace_size; ++i) {
char *fn = findFuncName(trace[i], &offset), *p;
p = strchr(messages[i],'+');
}
static void setupSigSegvAction(void) {
-#if defined(__APPLE__) || defined(__linux__)
struct sigaction act;
sigemptyset (&act.sa_mask);
act.sa_sigaction = segvHandler;
sigaction (SIGSEGV, &act, NULL);
sigaction (SIGBUS, &act, NULL);
-#else
return;
-#endif
}
-
-#endif /* if __APPLE__ or __linux__ */
+#else /* HAVE_BACKTRACE */
+static void setupSigSegvAction(void) {
+}
+#endif /* HAVE_BACKTRACE */
/* =================================== Main! ================================ */