First cut at adding arm64 Linux / Android support to Breakpad.

This is an initial attempt to add Arm64 (aarch64) support to Breakpad for
Linux / Android platforms.  This CL adds the Arm64 data structures, but does
not yet implement the Android getcontext support or CPUFillFromThreadInfo /
CPUFillFromUContext.

BUG=354405,335641
R=mark@chromium.org

Review URL: https://breakpad.appspot.com/1354002

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1301 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
rmcilroy@chromium.org
2014-04-02 23:12:40 +00:00
parent 46aba5a43a
commit 83b9a28cf9
16 changed files with 118 additions and 19 deletions

View File

@@ -140,6 +140,10 @@ breakpad_getcontext:
.size breakpad_getcontext, . - breakpad_getcontext
#elif defined(__aarch64__)
// TODO(rmcilroy): Implement for arm64.
#elif defined(__mips__)
#if _MIPS_SIM != _ABIO32

View File

@@ -38,7 +38,7 @@ extern "C" {
#endif // __cplusplus
// The Android <elf.h> provides BSD-based definitions for the ElfXX_Nhdr
// types
// types
// always source-compatible with the GLibc/kernel ones. To overcome this
// issue without modifying a lot of code in Breakpad, use an ugly macro
// renaming trick with #include_next
@@ -110,9 +110,14 @@ typedef struct {
// __WORDSIZE is GLibc-specific and used by Google Breakpad on Linux.
// All Android platforms are 32-bit for now.
#ifndef __WORDSIZE
#if defined(__i386__) || defined(__ARM_EABI__) || defined(__mips__)
#define __WORDSIZE 32
#elif defined(__x86_64__) || defined(__aarch64__)
#define __WORDSIZE 64
#else
#error "Unsupported Android CPU ABI"
#endif
#endif
// The Android headers don't always define this constant.

View File

@@ -34,6 +34,10 @@
Provide custom version here. */
#include_next <link.h>
// TODO(rmcilroy): Remove this file once the ndk is updated for other
// architectures - crbug.com/358831
#if !defined(__aarch64__) && !defined(__x86_64__)
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@@ -61,4 +65,6 @@ struct link_map {
} // extern "C"
#endif // __cplusplus
#endif // !defined(__aarch64__) && !defined(__x86_64__)
#endif /* GOOGLE_BREAKPAD_ANDROID_INCLUDE_LINK_H */

View File

@@ -44,7 +44,7 @@
extern "C" {
#endif // __cplusplus
#ifdef __x86_64__
#if defined(__x86_64__) || defined(__aarch64__)
typedef unsigned long long elf_greg_t;
#else
typedef unsigned long elf_greg_t;
@@ -52,6 +52,8 @@ typedef unsigned long elf_greg_t;
#ifdef __arm__
#define ELF_NGREG (sizeof(struct user_regs) / sizeof(elf_greg_t))
#elif defined(__aarch64__)
#define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(elf_greg_t))
#else
#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
#endif

View File

@@ -62,6 +62,19 @@ typedef struct ucontext {
// Other fields are not used by Google Breakpad. Don't define them.
} ucontext_t;
#elif defined(__aarch64__)
#include <asm/sigcontext.h>
typedef struct sigcontext mcontext_t;
typedef struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
sigset_t uc_sigmask;
mcontext_t uc_mcontext;
} ucontext_t;
#elif defined(__i386__)
/* 80-bit floating-point register */

View File

@@ -75,6 +75,11 @@ struct user_vfpregs {
unsigned long fpscr;
};
#elif defined(__aarch64__)
// aarch64 does not have user_regs definitions in <asm/user.h>, instead
// use the definitions in <asm/ptrace.h>, which we don't need to redefine here.
#elif defined(__i386__)
#define _I386_USER_H 1 // Prevent <asm/user.h> conflicts

View File

@@ -45,6 +45,11 @@
#define MCONTEXT_GREGS_OFFSET 32
#define UCONTEXT_SIGMASK_OFFSET 104
#elif defined(__aarch64__)
#define MCONTEXT_GREGS_OFFSET 56
#define UCONTEXT_SIGMASK_OFFSET 40
#elif defined(__i386__)
#define MCONTEXT_GREGS_OFFSET 20

View File

@@ -62,7 +62,7 @@ bool MemoryMappedFile::Map(const char* path) {
return false;
}
#if defined(__x86_64__)
#if defined(__x86_64__) || defined(__aarch64__)
struct kernel_stat st;
if (sys_fstat(fd, &st) == -1 || st.st_size < 0) {
#else
@@ -81,7 +81,7 @@ bool MemoryMappedFile::Map(const char* path) {
return true;
}
#if defined(__x86_64__)
#if defined(__x86_64__) || defined(__aarch64__)
void* data = sys_mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
#else
void* data = sys_mmap2(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);

View File

@@ -110,7 +110,7 @@ class PageAllocator {
private:
uint8_t *GetNPages(size_t num_pages) {
#ifdef __x86_64
#if defined(__x86_64__) || defined(__aarch64__)
void *a = sys_mmap(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#else