From 0e8d469f82a1971d99e40cb8352116687d98c843 Mon Sep 17 00:00:00 2001 From: yoav-steinberg Date: Wed, 18 Aug 2021 15:46:11 +0300 Subject: [PATCH] More generic crash report for unsupported archs (#9385) Following compilation warnings on s390x. --- src/debug.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/debug.c b/src/debug.c index 99904cdad..817ec0894 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1024,6 +1024,10 @@ void bugReportStart(void) { #ifdef HAVE_BACKTRACE static void *getMcontextEip(ucontext_t *uc) { +#define NOT_SUPPORTED() do {\ + UNUSED(uc);\ + return NULL;\ +} while(0) #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6) /* OSX < 10.6 */ #if defined(__x86_64__) @@ -1055,6 +1059,8 @@ static void *getMcontextEip(ucontext_t *uc) { return (void*) uc->uc_mcontext.arm_pc; #elif defined(__aarch64__) /* Linux AArch64 */ return (void*) uc->uc_mcontext.pc; + #else + NOT_SUPPORTED(); #endif #elif defined(__FreeBSD__) /* FreeBSD */ @@ -1062,6 +1068,8 @@ static void *getMcontextEip(ucontext_t *uc) { return (void*) uc->uc_mcontext.mc_eip; #elif defined(__x86_64__) return (void*) uc->uc_mcontext.mc_rip; + #else + NOT_SUPPORTED(); #endif #elif defined(__OpenBSD__) /* OpenBSD */ @@ -1069,18 +1077,23 @@ static void *getMcontextEip(ucontext_t *uc) { return (void*) uc->sc_eip; #elif defined(__x86_64__) return (void*) uc->sc_rip; + #else + NOT_SUPPORTED(); #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]; + #else + NOT_SUPPORTED(); #endif #elif defined(__DragonFly__) return (void*) uc->uc_mcontext.mc_rip; #else - return NULL; + NOT_SUPPORTED(); #endif +#undef NOT_SUPPORTED } void logStackContent(void **sp) { @@ -1099,6 +1112,11 @@ void logStackContent(void **sp) { /* Log dump of processor registers */ void logRegisters(ucontext_t *uc) { serverLog(LL_WARNING|LL_RAW, "\n------ REGISTERS ------\n"); +#define NOT_SUPPORTED() do {\ + UNUSED(uc);\ + serverLog(LL_WARNING,\ + " Dumping of registers not supported for this OS/arch");\ +} while(0) /* OSX */ #if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6) @@ -1323,6 +1341,8 @@ void logRegisters(ucontext_t *uc) { (unsigned long) uc->uc_mcontext.fault_address ); logStackContent((void**)uc->uc_mcontext.arm_sp); + #else + NOT_SUPPORTED(); #endif #elif defined(__FreeBSD__) #if defined(__x86_64__) @@ -1378,6 +1398,8 @@ void logRegisters(ucontext_t *uc) { (unsigned long) uc->uc_mcontext.mc_gs ); logStackContent((void**)uc->uc_mcontext.mc_esp); + #else + NOT_SUPPORTED(); #endif #elif defined(__OpenBSD__) #if defined(__x86_64__) @@ -1433,6 +1455,8 @@ void logRegisters(ucontext_t *uc) { (unsigned long) uc->sc_gs ); logStackContent((void**)uc->sc_esp); + #else + NOT_SUPPORTED(); #endif #elif defined(__NetBSD__) #if defined(__x86_64__) @@ -1486,6 +1510,8 @@ void logRegisters(ucontext_t *uc) { (unsigned long) uc->uc_mcontext.__gregs[_REG_FS], (unsigned long) uc->uc_mcontext.__gregs[_REG_GS] ); + #else + NOT_SUPPORTED(); #endif #elif defined(__DragonFly__) serverLog(LL_WARNING, @@ -1517,9 +1543,9 @@ void logRegisters(ucontext_t *uc) { ); logStackContent((void**)uc->uc_mcontext.mc_rsp); #else - serverLog(LL_WARNING, - " Dumping of registers not supported for this OS/arch"); + NOT_SUPPORTED(); #endif +#undef NOT_SUPPORTED } #endif /* HAVE_BACKTRACE */