summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2020-09-23 08:00:31 +0100
committerGitHub <noreply@github.com>2020-09-23 10:00:31 +0300
commitc3edaa79413bdf908abb56f088217c01f347ecff (patch)
treeb581cd093806c71860167bb5479409a96bc578cc /src
parent63cd4d4e2044059c44a65e2ce424b9ce1fcdbd39 (diff)
downloadredis-c3edaa79413bdf908abb56f088217c01f347ecff.tar.gz
Further NetBSD update and build fixes. (#7831)
mainly backtrace and register dump support.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile12
-rw-r--r--src/config.h4
-rw-r--r--src/debug.c59
3 files changed, 72 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile
index 715316a15..f6e5f3e3f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -131,12 +131,21 @@ ifeq ($(uname_S),OpenBSD)
endif
else
+ifeq ($(uname_S),NetBSD)
+ # NetBSD
+ FINAL_LIBS+= -lpthread
+ ifeq ($(USE_BACKTRACE),yes)
+ FINAL_CFLAGS+= -DUSE_BACKTRACE -I/usr/pkg/include
+ FINAL_LDFLAGS+= -L/usr/pkg/lib
+ FINAL_LIBS+= -lexecinfo
+ endif
+else
ifeq ($(uname_S),FreeBSD)
# FreeBSD
FINAL_LIBS+= -lpthread -lexecinfo
else
ifeq ($(uname_S),DragonFly)
- # FreeBSD
+ # DragonFly
FINAL_LIBS+= -lpthread -lexecinfo
else
ifeq ($(uname_S),OpenBSD)
@@ -158,6 +167,7 @@ endif
endif
endif
endif
+endif
# Include paths to dependencies
FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram
diff --git a/src/config.h b/src/config.h
index f9ec7e44a..d391508fa 100644
--- a/src/config.h
+++ b/src/config.h
@@ -64,7 +64,7 @@
/* Test for backtrace() */
#if defined(__APPLE__) || (defined(__linux__) && defined(__GLIBC__)) || \
- defined(__FreeBSD__) || (defined(__OpenBSD__) && defined(USE_BACKTRACE))\
+ defined(__FreeBSD__) || ((defined(__OpenBSD__) || defined(__NetBSD__)) && defined(USE_BACKTRACE))\
|| defined(__DragonFly__)
#define HAVE_BACKTRACE 1
#endif
@@ -236,7 +236,7 @@ void setproctitle(const char *fmt, ...);
#define redis_set_thread_title(name) pthread_set_name_np(pthread_self(), name)
#elif defined __NetBSD__
#include <pthread.h>
-#define redis_set_thread_title(name) pthread_setname_np(pthread_self(), name, NULL)
+#define redis_set_thread_title(name) pthread_setname_np(pthread_self(), "%s", name)
#else
#if (defined __APPLE__ && defined(MAC_OS_X_VERSION_10_7))
int pthread_setname_np(const char *name);
diff --git a/src/debug.c b/src/debug.c
index 13373b7c7..87b4bec71 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -984,6 +984,12 @@ static void *getMcontextEip(ucontext_t *uc) {
#elif defined(__x86_64__)
return (void*) uc->sc_rip;
#endif
+#elif defined(__NetBSD__)
+ #if defined(__i386__)
+ return (void*) uc->uc_mcontext.__gregs[_REG_EIP];
+ #elif defined(__x86_64__)
+ return (void*) uc->uc_mcontext.__gregs[_REG_RIP];
+ #endif
#elif defined(__DragonFly__)
return (void*) uc->uc_mcontext.mc_rip;
#else
@@ -1342,6 +1348,59 @@ void logRegisters(ucontext_t *uc) {
);
logStackContent((void**)uc->sc_esp);
#endif
+#elif defined(__NetBSD__)
+ #if defined(__x86_64__)
+ serverLog(LL_WARNING,
+ "\n"
+ "RAX:%016lx RBX:%016lx\nRCX:%016lx RDX:%016lx\n"
+ "RDI:%016lx RSI:%016lx\nRBP:%016lx RSP:%016lx\n"
+ "R8 :%016lx R9 :%016lx\nR10:%016lx R11:%016lx\n"
+ "R12:%016lx R13:%016lx\nR14:%016lx R15:%016lx\n"
+ "RIP:%016lx EFL:%016lx\nCSGSFS:%016lx",
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RAX],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RBX],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RCX],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RDX],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RDI],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RSI],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RBP],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RSP],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R8],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R9],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R10],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R11],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R12],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R13],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R14],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_R15],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RIP],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_RFLAGS],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_CS]
+ );
+ logStackContent((void**)uc->uc_mcontext.__gregs[_REG_RSP]);
+ #elif defined(__i386__)
+ serverLog(LL_WARNING,
+ "\n"
+ "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n"
+ "EDI:%08lx ESI:%08lx EBP:%08lx ESP:%08lx\n"
+ "SS :%08lx EFL:%08lx EIP:%08lx CS:%08lx\n"
+ "DS :%08lx ES :%08lx FS :%08lx GS:%08lx",
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_EAX],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_EBX],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_EDX],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_EDI],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_ESI],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_EBP],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_ESP],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_SS],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_EFLAGS],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_EIP],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_CS],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_ES],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_FS],
+ (unsigned long) uc->uc_mcontext.__gregs[_REG_GS]
+ );
+ #endif
#elif defined(__DragonFly__)
serverLog(LL_WARNING,
"\n"