From 0f27af628fd9aff70193abb140038e2d8f938165 Mon Sep 17 00:00:00 2001 From: "rmcilroy@chromium.org" Date: Tue, 21 Apr 2015 21:34:14 +0000 Subject: [MIPS]: Use mcontext_t structure for MIPS This change removes user_regs_struct and user_fpregs_struct structures for mips and uses mcontext_t instead. R=fdegans@chromium.org, mark@chromium.org, rmcilroy@chromium.org Review URL: https://breakpad.appspot.com/3744002 Patch from Gordana Cmiljanovic . git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1452 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../linux/minidump_writer/linux_core_dumper.cc | 27 ++++++++------- .../linux/minidump_writer/linux_ptrace_dumper.cc | 38 +++++++++++++--------- .../linux_ptrace_dumper_unittest.cc | 2 +- 3 files changed, 40 insertions(+), 27 deletions(-) (limited to 'src/client/linux/minidump_writer') diff --git a/src/client/linux/minidump_writer/linux_core_dumper.cc b/src/client/linux/minidump_writer/linux_core_dumper.cc index b8d90af6..d7328245 100644 --- a/src/client/linux/minidump_writer/linux_core_dumper.cc +++ b/src/client/linux/minidump_writer/linux_core_dumper.cc @@ -38,6 +38,10 @@ #include #include #include +#if defined(__mips__) && defined(__ANDROID__) +// To get register definitions. +#include +#endif #include "common/linux/linux_libc_support.h" @@ -105,7 +109,7 @@ bool LinuxCoreDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { memcpy(&stack_pointer, &info->regs.sp, sizeof(info->regs.sp)); #elif defined(__mips__) stack_pointer = - reinterpret_cast(info->regs.regs[MD_CONTEXT_MIPS_REG_SP]); + reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); #else #error "This code hasn't been ported to your platform yet." #endif @@ -191,18 +195,19 @@ bool LinuxCoreDumper::EnumerateThreads() { info.tgid = status->pr_pgrp; info.ppid = status->pr_ppid; #if defined(__mips__) +#if defined(__ANDROID__) + for (int i = EF_R0; i <= EF_R31; i++) + info.mcontext.gregs[i - EF_R0] = status->pr_reg[i]; +#else // __ANDROID__ for (int i = EF_REG0; i <= EF_REG31; i++) - info.regs.regs[i - EF_REG0] = status->pr_reg[i]; - - info.regs.lo = status->pr_reg[EF_LO]; - info.regs.hi = status->pr_reg[EF_HI]; - info.regs.epc = status->pr_reg[EF_CP0_EPC]; - info.regs.badvaddr = status->pr_reg[EF_CP0_BADVADDR]; - info.regs.status = status->pr_reg[EF_CP0_STATUS]; - info.regs.cause = status->pr_reg[EF_CP0_CAUSE]; -#else + info.mcontext.gregs[i - EF_REG0] = status->pr_reg[i]; +#endif // __ANDROID__ + info.mcontext.mdlo = status->pr_reg[EF_LO]; + info.mcontext.mdhi = status->pr_reg[EF_HI]; + info.mcontext.pc = status->pr_reg[EF_CP0_EPC]; +#else // __mips__ memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); -#endif +#endif // __mips__ if (first_thread) { crash_thread_ = pid; crash_signal_ = status->pr_info.si_signo; diff --git a/src/client/linux/minidump_writer/linux_ptrace_dumper.cc b/src/client/linux/minidump_writer/linux_ptrace_dumper.cc index 7a2cfb9f..5ea0050d 100644 --- a/src/client/linux/minidump_writer/linux_ptrace_dumper.cc +++ b/src/client/linux/minidump_writer/linux_ptrace_dumper.cc @@ -190,23 +190,25 @@ bool LinuxPtraceDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { #ifdef PTRACE_GETREGSET struct iovec io; - io.iov_base = &info->regs; - io.iov_len = sizeof(info->regs); + info->GetGeneralPurposeRegisters(&io.iov_base, &io.iov_len); if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_PRSTATUS, (void*)&io) == -1) { return false; } - io.iov_base = &info->fpregs; - io.iov_len = sizeof(info->fpregs); + info->GetFloatingPointRegisters(&io.iov_base, &io.iov_len); if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) { return false; } -#else - if (sys_ptrace(PTRACE_GETREGS, tid, NULL, &info->regs) == -1) { +#else // PTRACE_GETREGSET + void* gp_addr; + info->GetGeneralPurposeRegisters(&gp_addr, NULL); + if (sys_ptrace(PTRACE_GETREGS, tid, NULL, gp_addr) == -1) { return false; } - if (sys_ptrace(PTRACE_GETFPREGS, tid, NULL, &info->fpregs) == -1) { + void* fp_addr; + info->GetFloatingPointRegisters(&fp_addr, NULL); + if (sys_ptrace(PTRACE_GETFPREGS, tid, NULL, fp_addr) == -1) { return false; } #endif @@ -241,14 +243,20 @@ bool LinuxPtraceDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { #endif #if defined(__mips__) - for (int i = 0; i < 3; ++i) { - sys_ptrace(PTRACE_PEEKUSER, tid, - reinterpret_cast(DSP_BASE + (i * 2)), &info->hi[i]); - sys_ptrace(PTRACE_PEEKUSER, tid, - reinterpret_cast(DSP_BASE + (i * 2) + 1), &info->lo[i]); - } sys_ptrace(PTRACE_PEEKUSER, tid, - reinterpret_cast(DSP_CONTROL), &info->dsp_control); + reinterpret_cast(DSP_BASE), &info->mcontext.hi1); + sys_ptrace(PTRACE_PEEKUSER, tid, + reinterpret_cast(DSP_BASE + 1), &info->mcontext.lo1); + sys_ptrace(PTRACE_PEEKUSER, tid, + reinterpret_cast(DSP_BASE + 2), &info->mcontext.hi2); + sys_ptrace(PTRACE_PEEKUSER, tid, + reinterpret_cast(DSP_BASE + 3), &info->mcontext.lo2); + sys_ptrace(PTRACE_PEEKUSER, tid, + reinterpret_cast(DSP_BASE + 4), &info->mcontext.hi3); + sys_ptrace(PTRACE_PEEKUSER, tid, + reinterpret_cast(DSP_BASE + 5), &info->mcontext.lo3); + sys_ptrace(PTRACE_PEEKUSER, tid, + reinterpret_cast(DSP_CONTROL), &info->mcontext.dsp); #endif const uint8_t* stack_pointer; @@ -262,7 +270,7 @@ bool LinuxPtraceDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { my_memcpy(&stack_pointer, &info->regs.sp, sizeof(info->regs.sp)); #elif defined(__mips__) stack_pointer = - reinterpret_cast(info->regs.regs[MD_CONTEXT_MIPS_REG_SP]); + reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); #else #error "This code hasn't been ported to your platform yet." #endif 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 010ec67c..838ea5f6 100644 --- a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc @@ -441,7 +441,7 @@ TEST(LinuxPtraceDumperTest, VerifyStackReadWithMultipleThreads) { pid_t* process_tid_location = (pid_t*)(one_thread.regs.rcx); #elif defined(__mips__) pid_t* process_tid_location = - reinterpret_cast(one_thread.regs.regs[1]); + reinterpret_cast(one_thread.mcontext.gregs[1]); #else #error This test has not been ported to this platform. #endif -- cgit v1.2.1