From cfc8628092e17069d8d6c7068d4f21d9baabe077 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek" Date: Wed, 20 Oct 2010 15:51:38 +0000 Subject: Add support for building the Linux client code using the Android NDK r=mwu at http://breakpad.appspot.com/212001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@716 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/linux/handler/exception_handler.cc | 10 +++++-- src/client/linux/handler/exception_handler.h | 4 +++ .../linux/handler/exception_handler_unittest.cc | 31 +++++++++++++--------- 3 files changed, 31 insertions(+), 14 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 57da0c56..592c9e5b 100644 --- a/src/client/linux/handler/exception_handler.cc +++ b/src/client/linux/handler/exception_handler.cc @@ -73,12 +73,18 @@ #include #include #include +#if !defined(__ANDROID__) #include +#endif #include +#if !defined(__ANDROID__) #include #include +#endif #include +#if !defined(__ANDROID__) #include +#endif #include #include @@ -186,7 +192,7 @@ bool ExceptionHandler::InstallHandlers() { stack.ss_sp = signal_stack; stack.ss_size = kSigStackSize; - if (sigaltstack(&stack, NULL) == -1) + if (sys_sigaltstack(&stack, NULL) == -1) return false; struct sigaction sa; @@ -322,7 +328,7 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) { return false; // Allow ourselves to be dumped. - prctl(PR_SET_DUMPABLE, 1); + sys_prctl(PR_SET_DUMPABLE, 1); CrashContext context; memcpy(&context.siginfo, info, sizeof(siginfo_t)); memcpy(&context.context, uc, sizeof(struct ucontext)); diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h index b450403a..82f7fb4c 100644 --- a/src/client/linux/handler/exception_handler.h +++ b/src/client/linux/handler/exception_handler.h @@ -33,9 +33,13 @@ #include #include +#include #include #include +#if defined(__ANDROID__) +#include "client/linux/android_ucontext.h" +#endif #include "client/linux/crash_generation/crash_generation_client.h" #include "processor/scoped_ptr.h" diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc index c8879fcb..e1186698 100644 --- a/src/client/linux/handler/exception_handler_unittest.cc +++ b/src/client/linux/handler/exception_handler_unittest.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include "breakpad_googletest_includes.h" #include "client/linux/handler/exception_handler.h" @@ -47,6 +48,12 @@ using namespace google_breakpad; +#if !defined(__ANDROID__) +#define TEMPDIR "/tmp" +#else +#define TEMPDIR "/data/local/tmp" +#endif + static void sigchld_handler(int signo) { } class ExceptionHandlerTest : public ::testing::Test { @@ -67,7 +74,7 @@ class ExceptionHandlerTest : public ::testing::Test { }; TEST(ExceptionHandlerTest, Simple) { - ExceptionHandler handler("/tmp", NULL, NULL, NULL, true); + ExceptionHandler handler(TEMPDIR, NULL, NULL, NULL, true); } static bool DoneCallback(const char* dump_path, @@ -93,7 +100,7 @@ TEST(ExceptionHandlerTest, ChildCrash) { const pid_t child = fork(); if (child == 0) { close(fds[0]); - ExceptionHandler handler("/tmp", NULL, DoneCallback, (void*) fds[1], + ExceptionHandler handler(TEMPDIR, NULL, DoneCallback, (void*) fds[1], true); *reinterpret_cast(NULL) = 0; } @@ -121,7 +128,7 @@ TEST(ExceptionHandlerTest, ChildCrash) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = std::string("/tmp/") + filename + + const std::string minidump_filename = std::string(TEMPDIR) + "/" + filename + ".dmp"; struct stat st; @@ -146,7 +153,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemory) { const pid_t child = fork(); if (child == 0) { close(fds[0]); - ExceptionHandler handler("/tmp", NULL, DoneCallback, (void*) fds[1], + ExceptionHandler handler(TEMPDIR, NULL, DoneCallback, (void*) fds[1], true); // Get some executable memory. char* memory = @@ -194,7 +201,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemory) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = std::string("/tmp/") + filename + + const std::string minidump_filename = std::string(TEMPDIR) + "/" + filename + ".dmp"; struct stat st; @@ -270,7 +277,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMinBound) { const pid_t child = fork(); if (child == 0) { close(fds[0]); - ExceptionHandler handler("/tmp", NULL, DoneCallback, (void*) fds[1], + ExceptionHandler handler(TEMPDIR, NULL, DoneCallback, (void*) fds[1], true); // Get some executable memory. char* memory = @@ -318,7 +325,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMinBound) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = std::string("/tmp/") + filename + + const std::string minidump_filename = std::string(TEMPDIR) + "/" + filename + ".dmp"; struct stat st; @@ -394,7 +401,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMaxBound) { const pid_t child = fork(); if (child == 0) { close(fds[0]); - ExceptionHandler handler("/tmp", NULL, DoneCallback, (void*) fds[1], + ExceptionHandler handler(TEMPDIR, NULL, DoneCallback, (void*) fds[1], true); // Get some executable memory. char* memory = @@ -442,7 +449,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMaxBound) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = std::string("/tmp/") + filename + + const std::string minidump_filename = std::string(TEMPDIR) + "/" + filename + ".dmp"; struct stat st; @@ -510,7 +517,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) { const pid_t child = fork(); if (child == 0) { close(fds[0]); - ExceptionHandler handler("/tmp", NULL, DoneCallback, (void*) fds[1], + ExceptionHandler handler(TEMPDIR, NULL, DoneCallback, (void*) fds[1], true); // Try calling a NULL pointer. typedef void (*void_function)(void); @@ -542,7 +549,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = std::string("/tmp/") + filename + + const std::string minidump_filename = std::string(TEMPDIR) + "/" + filename + ".dmp"; struct stat st; @@ -663,7 +670,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) { ASSERT_NE(crashing_pid, -1); ASSERT_NE(signal_fd, -1); - char templ[] = "/tmp/exception-handler-unittest-XXXXXX"; + char templ[] = TEMPDIR "/exception-handler-unittest-XXXXXX"; mktemp(templ); ASSERT_TRUE(WriteMinidump(templ, crashing_pid, context, kCrashContextSize)); -- cgit v1.2.1