From fff818514d6b3b56c4a9a49773678fdd887068f4 Mon Sep 17 00:00:00 2001 From: "rmcilroy@chromium.org" Date: Tue, 8 Apr 2014 17:36:11 +0000 Subject: [PATCH] Add Arm64 support to breakpad unittests. BUG=354405,335641 R=mark@chromium.org Review URL: https://breakpad.appspot.com/1424002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1305 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../linux_dumper_unittest_helper.cc | 2 ++ .../linux_ptrace_dumper_unittest.cc | 2 ++ .../minidump_writer/minidump_writer_unittest.cc | 17 +++++------------ src/common/android/include/sys/procfs.h | 1 + 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc index 461a6cfe..4ccb7201 100644 --- a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc +++ b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc @@ -43,6 +43,8 @@ #if defined(__ARM_EABI__) #define TID_PTR_REGISTER "r3" +#elif defined(__aarch64__) +#define TID_PTR_REGISTER "x3" #elif defined(__i386) #define TID_PTR_REGISTER "ecx" #elif defined(__x86_64) diff --git a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc index 15a66ce2..010ec67c 100644 --- a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc @@ -433,6 +433,8 @@ TEST(LinuxPtraceDumperTest, VerifyStackReadWithMultipleThreads) { // specific register. Check that we can recover its value. #if defined(__ARM_EABI__) pid_t* process_tid_location = (pid_t*)(one_thread.regs.uregs[3]); +#elif defined(__aarch64__) + pid_t* process_tid_location = (pid_t*)(one_thread.regs.regs[3]); #elif defined(__i386) pid_t* process_tid_location = (pid_t*)(one_thread.regs.ecx); #elif defined(__x86_64) diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest.cc b/src/client/linux/minidump_writer/minidump_writer_unittest.cc index 1ef064b1..e1046e12 100644 --- a/src/client/linux/minidump_writer/minidump_writer_unittest.cc +++ b/src/client/linux/minidump_writer/minidump_writer_unittest.cc @@ -525,26 +525,19 @@ TEST(MinidumpWriterTest, InvalidStackPointer) { // Fake the child's stack pointer for its crashing thread. NOTE: This must // be an invalid memory address for the child process (stack or otherwise). -#if defined(__i386) // Try 1MB below the current stack. uintptr_t invalid_stack_pointer = reinterpret_cast(&context) - 1024*1024; +#if defined(__i386) context.context.uc_mcontext.gregs[REG_ESP] = invalid_stack_pointer; #elif defined(__x86_64) - // Try 1MB below the current stack. - uintptr_t invalid_stack_pointer = - reinterpret_cast(&context) - 1024*1024; context.context.uc_mcontext.gregs[REG_RSP] = invalid_stack_pointer; #elif defined(__ARM_EABI__) - // Try 1MB below the current stack. - uintptr_t invalid_stack_pointer = - reinterpret_cast(&context) - 1024*1024; context.context.uc_mcontext.arm_sp = invalid_stack_pointer; +#elif defined(__aarch64__) + context.context.uc_mcontext.sp = invalid_stack_pointer; #elif defined(__mips__) - // Try 1MB below the current stack. - uintptr_t invalid_stack_pointer = - reinterpret_cast(&context) - 1024 * 1024; - context.context.uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP] = + context.context.uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP] = invalid_stack_pointer; #else # error "This code has not been ported to your platform yet." @@ -629,7 +622,7 @@ TEST(MinidumpWriterTest, MinidumpSizeLimit) { ASSERT_EQ(1, r); ASSERT_TRUE(pfd.revents & POLLIN); uint8_t junk; - ASSERT_EQ(read(fds[0], &junk, sizeof(junk)), + ASSERT_EQ(read(fds[0], &junk, sizeof(junk)), static_cast(sizeof(junk))); } close(fds[0]); diff --git a/src/common/android/include/sys/procfs.h b/src/common/android/include/sys/procfs.h index ec65b91c..94994147 100644 --- a/src/common/android/include/sys/procfs.h +++ b/src/common/android/include/sys/procfs.h @@ -36,6 +36,7 @@ #else +#include #include #include #include