From 7e3c538af1bdee7f5a4c04e11715488f1d4efd15 Mon Sep 17 00:00:00 2001 From: "digit@chromium.org" Date: Fri, 31 Aug 2012 18:38:29 +0000 Subject: 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 --- src/client/linux/handler/exception_handler.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/client/linux/handler') diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc index 4a5932c1..27ac1544 100644 --- a/src/client/linux/handler/exception_handler.cc +++ b/src/client/linux/handler/exception_handler.cc @@ -324,16 +324,11 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) { // This is a public interface to HandleSignal that allows the client to // generate a crash dump. This function may run in a compromised context. bool ExceptionHandler::SimulateSignalDelivery(int sig) { -#ifdef __ANDROID__ - // Android doesn't provide getcontext(). - return false; -#else siginfo_t siginfo; my_memset(&siginfo, 0, sizeof(siginfo_t)); struct ucontext context; getcontext(&context); return HandleSignal(sig, &siginfo, &context); -#endif } // This function may run in a compromised context: see the top of the file. @@ -457,7 +452,6 @@ bool ExceptionHandler::WriteMinidump(const string& dump_path, } bool ExceptionHandler::WriteMinidump() { -#if !defined(__ARM_EABI__) && !defined(__ANDROID__) if (!IsOutOfProcess() && !minidump_descriptor_.IsFD()) { // Update the path of the minidump so that this can be called multiple times // and new files are created for each minidump. This is done before the @@ -478,14 +472,14 @@ bool ExceptionHandler::WriteMinidump() { int getcontext_result = getcontext(&context.context); if (getcontext_result) return false; +#if !defined(__ARM_EABI__) + // FPU state is not part of ARM EABI ucontext_t. memcpy(&context.float_state, context.context.uc_mcontext.fpregs, sizeof(context.float_state)); +#endif context.tid = sys_gettid(); return GenerateDump(&context); -#else - return false; -#endif // !defined(__ARM_EABI__) && !defined(__ANDROID__) } void ExceptionHandler::AddMappingInfo(const string& name, -- cgit v1.2.1