[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 <Gordana.Cmiljanovic@imgtec.com>.

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1452 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
rmcilroy@chromium.org 2015-04-21 21:34:14 +00:00
parent 9c6af3e29c
commit 0f27af628f
9 changed files with 134 additions and 160 deletions

View file

@ -81,6 +81,9 @@
// containing core registers, while they use 'user_regs_struct' on other
// architectures. This file-local typedef simplifies the source code.
typedef user_regs user_regs_struct;
#elif defined (__mips__)
// This file-local typedef simplifies the source code.
typedef gregset_t user_regs_struct;
#endif
using google_breakpad::MDTypeHelper;
@ -208,13 +211,17 @@ struct CrashedProcess {
struct Thread {
pid_t tid;
#if defined(__mips__)
mcontext_t mcontext;
#else // __mips__
user_regs_struct regs;
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
#if defined(__i386__) || defined(__x86_64__)
user_fpregs_struct fpregs;
#endif
#endif // __i386__ || __x86_64__
#if defined(__i386__)
user_fpxregs_struct fpxregs;
#endif
#endif // __i386__
#endif // __mips__
uintptr_t stack_addr;
const uint8_t* stack;
size_t stack_length;
@ -371,21 +378,28 @@ ParseThreadRegisters(CrashedProcess::Thread* thread,
const MDRawContextMIPS* rawregs = range.GetData<MDRawContextMIPS>(0);
for (int i = 0; i < MD_CONTEXT_MIPS_GPR_COUNT; ++i)
thread->regs.regs[i] = rawregs->iregs[i];
thread->mcontext.gregs[i] = rawregs->iregs[i];
thread->regs.lo = rawregs->mdlo;
thread->regs.hi = rawregs->mdhi;
thread->regs.epc = rawregs->epc;
thread->regs.badvaddr = rawregs->badvaddr;
thread->regs.status = rawregs->status;
thread->regs.cause = rawregs->cause;
thread->mcontext.pc = rawregs->epc;
for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i)
thread->fpregs.regs[i] = rawregs->float_save.regs[i];
thread->mcontext.mdlo = rawregs->mdlo;
thread->mcontext.mdhi = rawregs->mdhi;
thread->fpregs.fpcsr = rawregs->float_save.fpcsr;
thread->mcontext.hi1 = rawregs->hi[0];
thread->mcontext.lo1 = rawregs->lo[0];
thread->mcontext.hi2 = rawregs->hi[1];
thread->mcontext.lo2 = rawregs->lo[1];
thread->mcontext.hi3 = rawregs->hi[2];
thread->mcontext.lo3 = rawregs->lo[2];
for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i) {
thread->mcontext.fpregs.fp_r.fp_fregs[i]._fp_fregs =
rawregs->float_save.regs[i];
}
thread->mcontext.fpc_csr = rawregs->float_save.fpcsr;
#if _MIPS_SIM == _ABIO32
thread->fpregs.fir = rawregs->float_save.fir;
thread->mcontext.fpc_eir = rawregs->float_save.fir;
#endif
}
#else
@ -751,7 +765,11 @@ WriteThread(const CrashedProcess::Thread& thread, int fatal_signal) {
pr.pr_info.si_signo = fatal_signal;
pr.pr_cursig = fatal_signal;
pr.pr_pid = thread.tid;
#if defined(__mips__)
memcpy(&pr.pr_reg, &thread.mcontext.gregs, sizeof(user_regs_struct));
#else
memcpy(&pr.pr_reg, &thread.regs, sizeof(user_regs_struct));
#endif
Nhdr nhdr;
memset(&nhdr, 0, sizeof(nhdr));