- factor out differences in ucontext types across different archs.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2751
back into the proxy's main loop, so it doesn't return. */
__attribute__ ((__noreturn__))
extern void VG_(proxy_handlesig)( const vki_ksiginfo_t *siginfo,
- const struct vki_sigcontext *sigcontext );
+ Addr ip, Int sysnum );
/* ---------------------------------------------------------------------
Exports of vg_syscalls.c
handler is being run with all signals blocked; the longjmp is
there to make sure they stay masked until the application thread is
ready to run its signal handler. */
-void VG_(proxy_handlesig)(const vki_ksiginfo_t *siginfo,
- const struct vki_sigcontext *sigcontext)
+void VG_(proxy_handlesig)(const vki_ksiginfo_t *siginfo, Addr ip, Int sysnum)
{
UChar local;
ProxyLWP *px = LWP_TSD(&local);
- Addr eip = sigcontext->eip;
- Int eax = sigcontext->eax;
vg_assert(siginfo->si_signo != 0);
if (px->siginfo.si_signo != 0) {
/* First look to see if the EIP is within our interesting ranges
near a syscall to work out what should happen. */
- if (sys_before <= eip && eip <= sys_restarted) {
+ if (sys_before <= ip && ip <= sys_restarted) {
/* We are before the syscall actually ran, or it did run and
wants to be restarted. Either way, set the return code to
indicate a restart. This is not really any different from
the proxy and machine state here. */
vg_assert(px->state == PXS_RunSyscall);
vg_assert(PLATFORM_SYSCALL_RET(px->tst->arch) == -VKI_ERESTARTSYS);
- } else if (sys_after <= eip && eip <= sys_done) {
+ } else if (sys_after <= ip && ip <= sys_done) {
/* We're after the syscall. Either it was interrupted by the
signal, or the syscall completed normally. In either case
- eax contains the correct syscall return value, and the new
- state is effectively PXS_SysDone. */
+ the usual register contains the correct syscall return value, and
+ the new state is effectively PXS_SysDone. */
vg_assert(px->state == PXS_RunSyscall ||
px->state == PXS_SysDone);
px->state = PXS_SysDone;
- PLATFORM_SYSCALL_RET(px->tst->arch) = eax;
+ PLATFORM_SYSCALL_RET(px->tst->arch) = sysnum;
}
px_printf(" signalled in state %s\n", pxs_name(px->state));
vg_assert(VG_(gettid)() != VG_(main_pid));
- VG_(proxy_handlesig)(info, &uc->uc_mcontext);
+ VG_(proxy_handlesig)(info, UCONTEXT_INSTR_PTR(uc),
+ UCONTEXT_SYSCALL_NUM(uc));
}
/*
proxy LWP code has a bug) */
vg_assert(info->si_code <= VKI_SI_USER);
- VG_(proxy_handlesig)(info, &uc->uc_mcontext);
+ VG_(proxy_handlesig)(info, UCONTEXT_INSTR_PTR(uc),
+ UCONTEXT_SYSCALL_NUM(uc));
return;
}
if (0)
VG_(kill_self)(sigNo); /* generate a core dump */
VG_(core_panic_at)("Killed by fatal signal",
- VG_(get_ExeContext2)(uc->uc_mcontext.eip,
- uc->uc_mcontext.ebp,
- uc->uc_mcontext.esp,
+ VG_(get_ExeContext2)(UCONTEXT_INSTR_PTR(uc),
+ UCONTEXT_FRAME_PTR(uc),
+ UCONTEXT_STACK_PTR(uc),
VG_(valgrind_last)));
}
}
vg_assert(si->si_code == VKI_SI_TKILL);
vg_assert(si->_sifields._kill._pid == VG_(main_pid));
- VG_(proxy_handlesig)(si, &uc->uc_mcontext);
+ VG_(proxy_handlesig)(si, UCONTEXT_INSTR_PTR(uc),
+ UCONTEXT_SYSCALL_NUM(uc));
}
}
address, return a linear address, and do limit checks too. */
extern Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr );
+/* ---------------------------------------------------------------------
+ ucontext stuff
+ ------------------------------------------------------------------ */
+#define UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.eip)
+#define UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.esp)
+#define UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.ebp)
+#define UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.eax)
/*--------------------------------------------------------------------*/
/*--- end ---*/