|
From: <sv...@va...> - 2006-01-19 03:44:13
|
Author: sewardj
Date: 2006-01-19 03:44:10 +0000 (Thu, 19 Jan 2006)
New Revision: 5554
Log:
Deal with somewhat dubious numbers showing up from the kernel for the
r3 (syscall return) value in the ucontext for a signal interrupting a
syscall.
Modified:
trunk/coregrind/m_signals.c
Modified: trunk/coregrind/m_signals.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_signals.c 2006-01-19 03:38:19 UTC (rev 5553)
+++ trunk/coregrind/m_signals.c 2006-01-19 03:44:10 UTC (rev 5554)
@@ -212,12 +212,29 @@
# define VG_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_R1])
# define VG_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_R1])
# define VG_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_R0])
+#if 0
# define VG_UCONTEXT_SYSCALL_SYSRES(uc) \
/* Convert the values in uc_mcontext r3,cr into a SysRes. */ \
VG_(mk_SysRes_ppc64_linux)( \
(uc)->uc_mcontext.gp_regs[VKI_PT_R3], \
(((uc)->uc_mcontext.gp_regs[VKI_PT_CCR] >> 28) & 1) \
)
+#else
+ /* Dubious hack: if there is an error, only consider the lowest 8
+ bits of r3. memcheck/tests/post-syscall shows a case where an
+ interrupted syscall should have produced a ucontext with 0x4
+ (VKI_EINTR) in r3 but is in fact producing 0x204. */
+ /* Awaiting clarification from PaulM. Evidently 0x204 is
+ ERESTART_RESTARTBLOCK, which shouldn't have made it into user
+ space. */
+ static inline SysRes VG_UCONTEXT_SYSCALL_SYSRES( struct vki_ucontext*=
uc )
+ {
+ ULong err =3D (uc->uc_mcontext.gp_regs[VKI_PT_CCR] >> 28) & 1;
+ ULong r3 =3D uc->uc_mcontext.gp_regs[VKI_PT_R3];
+ if (err) r3 &=3D 0xFF;
+ return VG_(mk_SysRes_ppc64_linux)( r3, err );
+ }
+#endif
# define VG_UCONTEXT_LINK_REG(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_LNK])=20
=20
#else
|