|
From: <sv...@va...> - 2006-02-15 10:34:59
|
Author: tom
Date: 2006-02-15 10:34:50 +0000 (Wed, 15 Feb 2006)
New Revision: 5651
Log:
Fix the tkill system call wrapper and enable it on x86 and amd64.
Fixes bug #121901.
Modified:
trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
trunk/coregrind/m_syswrap/syswrap-linux.c
trunk/coregrind/m_syswrap/syswrap-x86-linux.c
Modified: trunk/coregrind/m_syswrap/syswrap-amd64-linux.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_syswrap/syswrap-amd64-linux.c 2006-02-14 21:55:11 U=
TC (rev 5650)
+++ trunk/coregrind/m_syswrap/syswrap-amd64-linux.c 2006-02-15 10:34:50 U=
TC (rev 5651)
@@ -1204,7 +1204,7 @@
LINX_(__NR_lremovexattr, sys_lremovexattr), // 198=20
LINX_(__NR_fremovexattr, sys_fremovexattr), // 199=20
=20
- // (__NR_tkill, sys_tkill), // 200=20
+ LINXY(__NR_tkill, sys_tkill), // 200=20
GENXY(__NR_time, sys_time), /*was sys_time64*/ // 201=20
LINXY(__NR_futex, sys_futex), // 202=20
LINX_(__NR_sched_setaffinity, sys_sched_setaffinity), // 203=20
Modified: trunk/coregrind/m_syswrap/syswrap-linux.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_syswrap/syswrap-linux.c 2006-02-14 21:55:11 UTC (re=
v 5650)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2006-02-15 10:34:50 UTC (re=
v 5651)
@@ -867,30 +867,47 @@
PRE_REG_READ1(long, "set_tid_address", int *, tidptr);
}
=20
-//zz PRE(sys_tkill, Special)
-//zz {
-//zz /* int tkill(pid_t tid, int sig); */
-//zz PRINT("sys_tkill ( %d, %d )", ARG1,ARG2);
-//zz PRE_REG_READ2(long, "tkill", int, tid, int, sig);
-//zz if (!ML_(client_signal_OK)(ARG2)) {
-//zz SET_STATUS_( -VKI_EINVAL );
-//zz return;
-//zz }
-//zz=20
-//zz /* If we're sending SIGKILL, check to see if the target is one o=
f
-//zz our threads and handle it specially. */
-//zz if (ARG2 =3D=3D VKI_SIGKILL && ML_(do_sigkill)(ARG1, -1))
-//zz SET_STATUS_(0);
-//zz else
-//zz SET_STATUS_(VG_(do_syscall2)(SYSNO, ARG1, ARG2));
-//zz=20
-//zz if (VG_(clo_trace_signals))
-//zz VG_(message)(Vg_DebugMsg, "tkill: sent signal %d to pid %d",
-//zz ARG2, ARG1);
-//zz // Check to see if this kill gave us a pending signal
-//zz XXX FIXME VG_(poll_signals)(tid);
-//zz }
+PRE(sys_tkill)
+{
+ PRINT("sys_tgkill ( %d, %d )", ARG1,ARG2);
+ PRE_REG_READ2(long, "tkill", int, tid, int, sig);
+ if (!ML_(client_signal_OK)(ARG2)) {
+ SET_STATUS_Failure( VKI_EINVAL );
+ return;
+ }
+ =20
+ /* Check to see if this kill gave us a pending signal */
+ *flags |=3D SfPollAfter;
=20
+ if (VG_(clo_trace_signals))
+ VG_(message)(Vg_DebugMsg, "tkill: sending signal %d to pid %d",
+ ARG2, ARG1);
+
+ /* If we're sending SIGKILL, check to see if the target is one of
+ our threads and handle it specially. */
+ if (ARG2 =3D=3D VKI_SIGKILL && ML_(do_sigkill)(ARG1, -1)) {
+ SET_STATUS_Success(0);
+ return;
+ }
+
+ /* Ask to handle this syscall via the slow route, since that's the
+ only one that sets tst->status to VgTs_WaitSys. If the result
+ of doing the syscall is an immediate run of
+ async_signalhandler() in m_signals, then we need the thread to
+ be properly tidied away. I have the impression the previous
+ version of this wrapper worked on x86/amd64 only because the
+ kernel did not immediately deliver the async signal to this
+ thread (on ppc it did, which broke the assertion re tst->status
+ at the top of async_signalhandler()). */
+ *flags |=3D SfMayBlock;
+}
+POST(sys_tkill)
+{
+ if (VG_(clo_trace_signals))
+ VG_(message)(Vg_DebugMsg, "tkill: sent signal %d to pid %d",
+ ARG2, ARG1);
+}
+
PRE(sys_tgkill)
{
PRINT("sys_tgkill ( %d, %d, %d )", ARG1,ARG2,ARG3);
Modified: trunk/coregrind/m_syswrap/syswrap-x86-linux.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_syswrap/syswrap-x86-linux.c 2006-02-14 21:55:11 UTC=
(rev 5650)
+++ trunk/coregrind/m_syswrap/syswrap-x86-linux.c 2006-02-15 10:34:50 UTC=
(rev 5651)
@@ -2050,7 +2050,7 @@
LINX_(__NR_removexattr, sys_removexattr), // 235
LINX_(__NR_lremovexattr, sys_lremovexattr), // 236
LINX_(__NR_fremovexattr, sys_fremovexattr), // 237
-//zz LINX_(__NR_tkill, sys_tkill), // 238 */Linu=
x
+ LINXY(__NR_tkill, sys_tkill), // 238 */Linux
LINXY(__NR_sendfile64, sys_sendfile64), // 239
=20
LINXY(__NR_futex, sys_futex), // 240
|