Added crash context float state flag

Instead of listing everywhere the set of architectures that do not
require/support explicit float state in their crash context, a new
GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE preprocessor macro has
been defined.

Adding novel architectures will only require to manage the
macro definition in a single place.

Change-Id: I2732982f2cdfc9fcd2f71d6e5e122617faff9e82
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3876345
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
GlassOfWhiskey 2022-09-07 14:22:20 +02:00 committed by Mike Frysinger
parent 30c7f3cfc1
commit e69677e93d
4 changed files with 18 additions and 12 deletions

View file

@ -461,7 +461,7 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) {
memcpy(&g_crash_context_.float_state, fp_ptr, memcpy(&g_crash_context_.float_state, fp_ptr,
sizeof(g_crash_context_.float_state)); 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. // FP state is not part of user ABI on ARM Linux.
// In case of MIPS Linux FP state is already part of ucontext_t // In case of MIPS Linux FP state is already part of ucontext_t
// and 'float_state' is not a member of CrashContext. // and 'float_state' is not a member of CrashContext.
@ -701,7 +701,7 @@ bool ExceptionHandler::WriteMinidump() {
} }
#endif #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. // FPU state is not part of ARM EABI ucontext_t.
memcpy(&context.float_state, context.context.uc_mcontext.fpregs, memcpy(&context.float_state, context.context.uc_mcontext.fpregs,
sizeof(context.float_state)); sizeof(context.float_state));

View file

@ -44,6 +44,15 @@
#include "common/using_std_string.h" #include "common/using_std_string.h"
#include "google_breakpad/common/minidump_format.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 { namespace google_breakpad {
// ExceptionHandler // ExceptionHandler
@ -192,10 +201,7 @@ class ExceptionHandler {
siginfo_t siginfo; siginfo_t siginfo;
pid_t tid; // the crashing thread. pid_t tid; // the crashing thread.
ucontext_t context; ucontext_t context;
#if !defined(__ARM_EABI__) && !defined(__mips__) #if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
// #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.
fpstate_t float_state; fpstate_t float_state;
#endif #endif
}; };

View file

@ -138,7 +138,7 @@ class MicrodumpWriter {
const MicrodumpExtraInfo& microdump_extra_info, const MicrodumpExtraInfo& microdump_extra_info,
LinuxDumper* dumper) LinuxDumper* dumper)
: ucontext_(context ? &context->context : NULL), : 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), float_state_(context ? &context->float_state : NULL),
#endif #endif
dumper_(dumper), dumper_(dumper),
@ -409,7 +409,7 @@ class MicrodumpWriter {
void DumpCPUState() { void DumpCPUState() {
RawContextCPU cpu; RawContextCPU cpu;
my_memset(&cpu, 0, sizeof(RawContextCPU)); 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_); UContextReader::FillCPUContext(&cpu, ucontext_, float_state_);
#else #else
UContextReader::FillCPUContext(&cpu, ucontext_); UContextReader::FillCPUContext(&cpu, ucontext_);
@ -605,7 +605,7 @@ class MicrodumpWriter {
void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); }
const ucontext_t* const ucontext_; 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_; const google_breakpad::fpstate_t* const float_state_;
#endif #endif
LinuxDumper* dumper_; LinuxDumper* dumper_;

View file

@ -141,7 +141,7 @@ class MinidumpWriter {
: fd_(minidump_fd), : fd_(minidump_fd),
path_(minidump_path), path_(minidump_path),
ucontext_(context ? &context->context : NULL), 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), float_state_(context ? &context->float_state : NULL),
#endif #endif
dumper_(dumper), dumper_(dumper),
@ -473,7 +473,7 @@ class MinidumpWriter {
if (!cpu.Allocate()) if (!cpu.Allocate())
return false; return false;
my_memset(cpu.get(), 0, sizeof(RawContextCPU)); 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_); UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_);
#else #else
UContextReader::FillCPUContext(cpu.get(), ucontext_); 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 char* path_; // Path to the file where the minidum should be written.
const ucontext_t* const ucontext_; // also from the signal handler 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 const google_breakpad::fpstate_t* const float_state_; // ditto
#endif #endif
LinuxDumper* dumper_; LinuxDumper* dumper_;