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
This commit is contained in:
digit@chromium.org 2012-08-31 18:38:29 +00:00
parent fa064e215b
commit 7e3c538af1
12 changed files with 1354 additions and 95 deletions
src/client/linux/handler

View file

@ -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,