diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc index 499be0a9..0055d27a 100644 --- a/src/client/linux/handler/exception_handler.cc +++ b/src/client/linux/handler/exception_handler.cc @@ -461,7 +461,7 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) { memcpy(&g_crash_context_.float_state, fp_ptr, sizeof(g_crash_context_.float_state)); } -#elif !defined(__ARM_EABI__) && !defined(__mips__) +#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE // FP state is not part of user ABI on ARM Linux. // In case of MIPS Linux FP state is already part of ucontext_t // and 'float_state' is not a member of CrashContext. @@ -701,7 +701,7 @@ bool ExceptionHandler::WriteMinidump() { } #endif -#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE && !defined(__aarch64__) // FPU state is not part of ARM EABI ucontext_t. memcpy(&context.float_state, context.context.uc_mcontext.fpregs, sizeof(context.float_state)); diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h index f80843ea..03b80d39 100644 --- a/src/client/linux/handler/exception_handler.h +++ b/src/client/linux/handler/exception_handler.h @@ -44,6 +44,15 @@ #include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" +#if !defined(__ARM_EABI__) && !defined(__mips__) +// FP state is not part of user ABI for Linux ARM. +// In case of MIPS and RISCV Linux FP state is already part of ucontext_t +// so 'float_state' is not required. +# define GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE 1 +#else +# define GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE 0 +#endif + namespace google_breakpad { // ExceptionHandler @@ -192,10 +201,7 @@ class ExceptionHandler { siginfo_t siginfo; pid_t tid; // the crashing thread. ucontext_t context; -#if !defined(__ARM_EABI__) && !defined(__mips__) - // #ifdef this out because FP state is not part of user ABI for Linux ARM. - // In case of MIPS Linux FP state is already part of ucontext_t so - // 'float_state' is not required. +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE fpstate_t float_state; #endif }; diff --git a/src/client/linux/microdump_writer/microdump_writer.cc b/src/client/linux/microdump_writer/microdump_writer.cc index 22edb1b8..bcd31e6b 100644 --- a/src/client/linux/microdump_writer/microdump_writer.cc +++ b/src/client/linux/microdump_writer/microdump_writer.cc @@ -138,7 +138,7 @@ class MicrodumpWriter { const MicrodumpExtraInfo& microdump_extra_info, LinuxDumper* dumper) : ucontext_(context ? &context->context : NULL), -#if !defined(__ARM_EABI__) && !defined(__mips__) +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE float_state_(context ? &context->float_state : NULL), #endif dumper_(dumper), @@ -409,7 +409,7 @@ class MicrodumpWriter { void DumpCPUState() { RawContextCPU cpu; my_memset(&cpu, 0, sizeof(RawContextCPU)); -#if !defined(__ARM_EABI__) && !defined(__mips__) +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE UContextReader::FillCPUContext(&cpu, ucontext_, float_state_); #else UContextReader::FillCPUContext(&cpu, ucontext_); @@ -605,7 +605,7 @@ class MicrodumpWriter { void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } const ucontext_t* const ucontext_; -#if !defined(__ARM_EABI__) && !defined(__mips__) +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE const google_breakpad::fpstate_t* const float_state_; #endif LinuxDumper* dumper_; diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc index 7ce9ac57..0c5ef3fb 100644 --- a/src/client/linux/minidump_writer/minidump_writer.cc +++ b/src/client/linux/minidump_writer/minidump_writer.cc @@ -141,7 +141,7 @@ class MinidumpWriter { : fd_(minidump_fd), path_(minidump_path), ucontext_(context ? &context->context : NULL), -#if !defined(__ARM_EABI__) && !defined(__mips__) +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE float_state_(context ? &context->float_state : NULL), #endif dumper_(dumper), @@ -473,7 +473,7 @@ class MinidumpWriter { if (!cpu.Allocate()) return false; my_memset(cpu.get(), 0, sizeof(RawContextCPU)); -#if !defined(__ARM_EABI__) && !defined(__mips__) +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); #else UContextReader::FillCPUContext(cpu.get(), ucontext_); @@ -1386,7 +1386,7 @@ class MinidumpWriter { const char* path_; // Path to the file where the minidum should be written. const ucontext_t* const ucontext_; // also from the signal handler -#if !defined(__ARM_EABI__) && !defined(__mips__) +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE const google_breakpad::fpstate_t* const float_state_; // ditto #endif LinuxDumper* dumper_;