From 0b7c158932d41a555ee9efe541575cced5f20a9e Mon Sep 17 00:00:00 2001 From: "vapier@chromium.org" Date: Mon, 20 Jul 2015 10:21:27 +0000 Subject: add aarch64 support to minidump-2-core The thread info expects the struct names as they expect in asm/ptrace.h, but the header doesn't include that, it includes sys/user.h. Rename the reg structs to match that header. Rename the elf_siginfo to _elf_siginfo to avoid conflicting with the one in the sys/procfs.h. It is only used locally in one place, so we don't need to update any callers. Otherwise, drop in aarch64 support into the minidump-2-core file. BUG=chromium:334368 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1474 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/linux/dump_writer_common/thread_info.h | 6 ++-- src/tools/linux/md2core/minidump-2-core.cc | 41 +++++++++++++++++++---- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/client/linux/dump_writer_common/thread_info.h b/src/client/linux/dump_writer_common/thread_info.h index a05ffea2..99093d2e 100644 --- a/src/client/linux/dump_writer_common/thread_info.h +++ b/src/client/linux/dump_writer_common/thread_info.h @@ -65,9 +65,9 @@ struct ThreadInfo { struct user_regs regs; struct user_fpregs fpregs; #elif defined(__aarch64__) - // Use the structures defined in - struct user_pt_regs regs; - struct user_fpsimd_state fpregs; + // Use the structures defined in + struct user_regs_struct regs; + struct user_fpsimd_struct fpregs; #elif defined(__mips__) // Use the structure defined in . mcontext_t mcontext; diff --git a/src/tools/linux/md2core/minidump-2-core.cc b/src/tools/linux/md2core/minidump-2-core.cc index 21d410bc..8e9cd129 100644 --- a/src/tools/linux/md2core/minidump-2-core.cc +++ b/src/tools/linux/md2core/minidump-2-core.cc @@ -74,6 +74,8 @@ #define ELF_ARCH EM_ARM #elif defined(__mips__) #define ELF_ARCH EM_MIPS +#elif defined(__aarch64__) + #define ELF_ARCH EM_AARCH64 #endif #if defined(__arm__) @@ -136,14 +138,14 @@ typedef struct elf_timeval { /* Time value with microsecond resolution */ long tv_usec; /* Microseconds */ } elf_timeval; -typedef struct elf_siginfo { /* Information about signal (unused) */ +typedef struct _elf_siginfo { /* Information about signal (unused) */ int32_t si_signo; /* Signal number */ int32_t si_code; /* Extra code */ int32_t si_errno; /* Errno */ -} elf_siginfo; +} _elf_siginfo; typedef struct prstatus { /* Information about thread; includes CPU reg*/ - elf_siginfo pr_info; /* Info associated with signal */ + _elf_siginfo pr_info; /* Info associated with signal */ uint16_t pr_cursig; /* Current signal */ unsigned long pr_sigpend; /* Set of pending signals */ unsigned long pr_sighold; /* Set of held signals */ @@ -213,15 +215,18 @@ struct CrashedProcess { pid_t tid; #if defined(__mips__) mcontext_t mcontext; -#else // __mips__ +#else user_regs_struct regs; +#endif #if defined(__i386__) || defined(__x86_64__) user_fpregs_struct fpregs; -#endif // __i386__ || __x86_64__ +#endif #if defined(__i386__) user_fpxregs_struct fpxregs; -#endif // __i386__ -#endif // __mips__ +#endif +#if defined(__aarch64__) + user_fpsimd_struct fpregs; +#endif uintptr_t stack_addr; const uint8_t* stack; size_t stack_length; @@ -371,6 +376,22 @@ ParseThreadRegisters(CrashedProcess::Thread* thread, thread->regs.uregs[16] = rawregs->cpsr; thread->regs.uregs[17] = 0; // what is ORIG_r0 exactly? } +#elif defined(__aarch64__) +static void +ParseThreadRegisters(CrashedProcess::Thread* thread, + const MinidumpMemoryRange& range) { + const MDRawContextARM64* rawregs = range.GetData(0); + + for (int i = 0; i < 31; ++i) + thread->regs.regs[i] = rawregs->iregs[i]; + thread->regs.sp = rawregs->iregs[MD_CONTEXT_ARM64_REG_SP]; + thread->regs.pc = rawregs->iregs[MD_CONTEXT_ARM64_REG_PC]; + thread->regs.pstate = rawregs->cpsr; + + memcpy(thread->fpregs.vregs, rawregs->float_save.regs, 8 * 32); + thread->fpregs.fpsr = rawregs->float_save.fpsr; + thread->fpregs.fpcr = rawregs->float_save.fpcr; +} #elif defined(__mips__) static void ParseThreadRegisters(CrashedProcess::Thread* thread, @@ -466,6 +487,12 @@ ParseSystemInfo(CrashedProcess* crashinfo, const MinidumpMemoryRange& range, "This version of minidump-2-core only supports ARM (32bit).\n"); _exit(1); } +#elif defined(__aarch64__) + if (sysinfo->processor_architecture != MD_CPU_ARCHITECTURE_ARM64) { + fprintf(stderr, + "This version of minidump-2-core only supports ARM (64bit).\n"); + _exit(1); + } #elif defined(__mips__) if (sysinfo->processor_architecture != MD_CPU_ARCHITECTURE_MIPS) { fprintf(stderr, -- cgit v1.2.1