Fix breakpad on mips and x86_64 for the NDK r10c update.

This change introduces the necessary glue typedefs to deal with the
mismatch introduced by the latest Android NDK (w.r.t. desktop Linux):
- [x86_64] Rename fpregs mxcr_mask -> .mxcsr_mask
- [mips] uc_mcontext.fpregs.fp_r.fp_dregs -> uc_mcontext.fpreg
- [mips] restore the forked user.h

Submitting this on behalf of fdegans@chromium.org

TBR=mark@chromium.org

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1397 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
primiano@chromium.org 2014-10-24 10:58:38 +00:00
parent c1c257f4f6
commit e20758c298
4 changed files with 92 additions and 7 deletions

View File

@ -178,7 +178,12 @@ void ThreadInfo::FillCPUContext(RawContextCPU* out) const {
out->flt_save.data_offset = fpregs.rdp;
out->flt_save.data_selector = 0; // We don't have this.
out->flt_save.mx_csr = fpregs.mxcsr;
#if defined (__ANDROID__)
// Internal bug b/18097559
out->flt_save.mx_csr_mask = fpregs.mxcsr_mask;
#else
out->flt_save.mx_csr_mask = fpregs.mxcr_mask;
#endif
my_memcpy(&out->flt_save.float_registers, &fpregs.st_space, 8 * 16);
my_memcpy(&out->flt_save.xmm_registers, &fpregs.xmm_space, 16 * 16);
}

View File

@ -241,11 +241,7 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
out->cause = 0; // Not reported in signal context.
for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i)
#if defined (__ANDROID__)
out->float_save.regs[i] = uc->uc_mcontext.fpregs[i];
#else
out->float_save.regs[i] = uc->uc_mcontext.fpregs.fp_r.fp_dregs[i];
#endif
out->float_save.fpcsr = uc->uc_mcontext.fpc_csr;
out->float_save.fir = uc->uc_mcontext.fpc_eir; // Unused.

View File

@ -30,9 +30,91 @@
#ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_USER_H
#define GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_USER_H
// The purpose of this file is to glue the mismatching headers (Android NDK vs
// glibc) and therefore avoid doing otherwise awkward #ifdefs in the code.
// The following quirks are currently handled by this file:
// - MIPS: Keep using forked definitions of user.h structs. The definition in
// the NDK is completely different.
// Internal bug b/18097715
// - i386: Use the Android NDK but alias user_fxsr_struct > user_fpxregs_struct.
// - Other platforms: Just use the Android NDK unchanged.
#ifdef __mips__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define EF_REG0 6
#define EF_REG1 7
#define EF_REG2 8
#define EF_REG3 9
#define EF_REG4 10
#define EF_REG5 11
#define EF_REG6 12
#define EF_REG7 13
#define EF_REG8 14
#define EF_REG9 15
#define EF_REG10 16
#define EF_REG11 17
#define EF_REG12 18
#define EF_REG13 19
#define EF_REG14 20
#define EF_REG15 21
#define EF_REG16 22
#define EF_REG17 23
#define EF_REG18 24
#define EF_REG19 25
#define EF_REG20 26
#define EF_REG21 27
#define EF_REG22 28
#define EF_REG23 29
#define EF_REG24 30
#define EF_REG25 31
/*
* k0/k1 unsaved
*/
#define EF_REG26 32
#define EF_REG27 33
#define EF_REG28 34
#define EF_REG29 35
#define EF_REG30 36
#define EF_REG31 37
/*
* Saved special registers
*/
#define EF_LO 38
#define EF_HI 39
#define EF_CP0_EPC 40
#define EF_CP0_BADVADDR 41
#define EF_CP0_STATUS 42
#define EF_CP0_CAUSE 43
struct user_regs_struct {
unsigned long long regs[32];
unsigned long long lo;
unsigned long long hi;
unsigned long long epc;
unsigned long long badvaddr;
unsigned long long status;
unsigned long long cause;
};
struct user_fpregs_struct {
unsigned long long regs[32];
unsigned int fpcsr;
unsigned int fir;
};
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#else // __mips__
#include_next <sys/user.h>
// This struct is defined under a different name in the Android NDK.
#ifdef __i386__
#ifdef __cplusplus
extern "C" {
@ -41,6 +123,8 @@ typedef struct user_fxsr_struct user_fpxregs_struct;
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // __i386__
#endif // __i386__
#endif // __mips__
#endif // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_USER_H

View File

@ -126,7 +126,7 @@
#define MCONTEXT_GREGS_RSP 160
#define MCONTEXT_GREGS_RIP 168
#define MCONTEXT_FPREGS_PTR 224
#define MCONTEXT_FPREGS_MEM 448
#define MCONTEXT_FPREGS_MEM 304
#define FPREGS_OFFSET_MXCSR 24
#else