More generic crash report for unsupported archs (#9385)

Following compilation warnings on s390x.
This commit is contained in:
yoav-steinberg 2021-08-18 15:46:11 +03:00 committed by GitHub
parent fe359cbfc2
commit 0e8d469f82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 */