aboutsummaryrefslogtreecommitdiff
path: root/src/client/linux/handler
diff options
context:
space:
mode:
authorted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-10-20 15:51:38 +0000
committerted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-10-20 15:51:38 +0000
commitcfc8628092e17069d8d6c7068d4f21d9baabe077 (patch)
tree43e9d016602ec4944511a3f02981a004a6225ef5 /src/client/linux/handler
parentDouble stack scanning length in stackwalker (diff)
downloadbreakpad-cfc8628092e17069d8d6c7068d4f21d9baabe077.tar.xz
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
Diffstat (limited to 'src/client/linux/handler')
-rw-r--r--src/client/linux/handler/exception_handler.cc10
-rw-r--r--src/client/linux/handler/exception_handler.h4
-rw-r--r--src/client/linux/handler/exception_handler_unittest.cc31
3 files changed, 31 insertions, 14 deletions
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 <stdio.h>
#include <sys/mman.h>
#include <sys/prctl.h>
+#if !defined(__ANDROID__)
#include <sys/signal.h>
+#endif
#include <sys/syscall.h>
+#if !defined(__ANDROID__)
#include <sys/ucontext.h>
#include <sys/user.h>
+#endif
#include <sys/wait.h>
+#if !defined(__ANDROID__)
#include <ucontext.h>
+#endif
#include <unistd.h>
#include <algorithm>
@@ -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 <vector>
#include <string>
+#include <pthread.h>
#include <signal.h>
#include <stdio.h>
+#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 <sys/poll.h>
#include <sys/socket.h>
#include <sys/uio.h>
+#include <sys/wait.h>
#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<int*>(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));