diff options
author | digit@chromium.org <digit@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-08-31 18:38:29 +0000 |
---|---|---|
committer | digit@chromium.org <digit@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-08-31 18:38:29 +0000 |
commit | 7e3c538af1bdee7f5a4c04e11715488f1d4efd15 (patch) | |
tree | f1e36060e1fe50ce09eba0855d225478e623a8d8 /src/common/android/include | |
parent | Fix 'make check' for Android (diff) | |
download | breakpad-7e3c538af1bdee7f5a4c04e11715488f1d4efd15.tar.xz |
Add custom getcontext() implementation for Android.
This adds a minimalistic implementation of getcontext()
for Android/ARM and Android/x86. The provided code is
in assembly and only implements the bare minimum required
by Breakpad to get the current processor state.
Note that:
- The FPU state is not saved to the ucontext_t on ARM.
(that's actually the main difference with a normal
getcontext() implementation).
This is normal. On Linux/ARM, such state must be
obtained with PTRACE_GETVFPREGS instead. This will
be implemented in a future patch.
- On x86, only the 'regular' FPU state is saved, to
mimic the GLibc/i386 implementation. The state of
SSE/SSE2/etc registers is not part of the upstream
getcontext() implementation.
Review URL: https://breakpad.appspot.com/444002
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1024 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/android/include')
-rw-r--r-- | src/common/android/include/sys/ucontext.h | 14 | ||||
-rw-r--r-- | src/common/android/include/ucontext.h | 25 |
2 files changed, 33 insertions, 6 deletions
diff --git a/src/common/android/include/sys/ucontext.h b/src/common/android/include/sys/ucontext.h index 7f0eb5a3..4a4e77c1 100644 --- a/src/common/android/include/sys/ucontext.h +++ b/src/common/android/include/sys/ucontext.h @@ -50,11 +50,15 @@ extern "C" { #include <asm/sigcontext.h> typedef struct sigcontext mcontext_t; +// The ARM kernel uses a 64-bit signal mask. +typedef uint32_t kernel_sigmask_t[2]; + typedef struct ucontext { uint32_t uc_flags; struct ucontext* uc_link; stack_t uc_stack; mcontext_t uc_mcontext; + kernel_sigmask_t uc_sigmask; // Other fields are not used by Google Breakpad. Don't define them. } ucontext_t; @@ -110,12 +114,16 @@ enum { REG_SS, }; +// The i386 kernel uses a 64-bit signal mask. +typedef uint32_t kernel_sigmask_t[2]; + typedef struct ucontext { uint32_t uc_flags; struct ucontext* uc_link; stack_t uc_stack; mcontext_t uc_mcontext; - // Other fields are not used by Google Breakpad. Don't define them. + kernel_sigmask_t uc_sigmask; + struct _libc_fpstate __fpregs_mem; } ucontext_t; #elif defined(__mips__) @@ -142,11 +150,15 @@ typedef struct { uint32_t lo3; } mcontext_t; +// The MIPS kernel uses a 128-bit signal mask. +typedef uint32_t kernel_sigmask_t[4]; + typedef struct ucontext { uint32_t uc_flags; struct ucontext* uc_link; stack_t uc_stack; mcontext_t uc_mcontext; + kernel_sigmask_t uc_sigmask; // Other fields are not used by Google Breakpad. Don't define them. } ucontext_t; diff --git a/src/common/android/include/ucontext.h b/src/common/android/include/ucontext.h index 6608e063..29db8ade 100644 --- a/src/common/android/include/ucontext.h +++ b/src/common/android/include/ucontext.h @@ -30,12 +30,27 @@ #ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_UCONTEXT_H #define GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_UCONTEXT_H +#include <sys/cdefs.h> + +#ifdef __BIONIC_UCONTEXT_H +#include <ucontext.h> +#else + #include <sys/ucontext.h> -// TODO: Provide a portable implementation of getcontext() then -// update ExceptionHandler::WriteMinidump() in -// src/client/linux/handler/exception_handler.cc to use it. -// -// extern int getcontext(ucontext_t* ucp); +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Provided by src/android/common/breakpad_getcontext.S +int breakpad_getcontext(ucontext_t* ucp); + +#define getcontext(x) breakpad_getcontext(x) + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // __BIONIC_UCONTEXT_H #endif // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_UCONTEXT_H |