From owner-p4-projects@FreeBSD.ORG Tue Nov 11 08:34:40 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BBE871065674; Tue, 11 Nov 2008 08:34:40 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65E581065672 for ; Tue, 11 Nov 2008 08:34:40 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 49C138FC12 for ; Tue, 11 Nov 2008 08:34:40 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mAB8Ydur023279 for ; Tue, 11 Nov 2008 08:34:39 GMT (envelope-from peter-gmail@wemm.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mAB8YdDv023277 for perforce@freebsd.org; Tue, 11 Nov 2008 08:34:39 GMT (envelope-from peter-gmail@wemm.org) Date: Tue, 11 Nov 2008 08:34:39 GMT Message-Id: <200811110834.mAB8YdDv023277@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter-gmail@wemm.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 152802 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2008 08:34:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=152802 Change 152802 by peter@peter_hammer on 2008/11/11 08:34:25 Add thr_kill / thr_kill2 Affected files ... .. //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#16 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#30 edit Differences ... ==== //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#16 (text+ko) ==== @@ -259,6 +259,8 @@ DECL_TEMPLATE(freebsd, sys_posix_openpt); DECL_TEMPLATE(freebsd, sys_uuidgen); DECL_TEMPLATE(freebsd, sys_thr_new); +DECL_TEMPLATE(freebsd, sys_thr_kill); +DECL_TEMPLATE(freebsd, sys_thr_kill2); #endif // __PRIV_SYSWRAP_FREEBSD_H /*--------------------------------------------------------------------*/ ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#30 (text+ko) ==== @@ -1820,6 +1820,87 @@ PRE_MEM_RASCIIZ( "sys_thr_set_name(threadname)", ARG2); } +PRE(sys_thr_kill) +{ + PRINT("sys_thr_kill ( %ld, %ld )", ARG1,ARG2); + PRE_REG_READ2(long, "thr_kill", long, id, int, sig); + if (!ML_(client_signal_OK)(ARG2)) { + SET_STATUS_Failure( VKI_EINVAL ); + return; + } + + /* Check to see if this kill gave us a pending signal */ + *flags |= SfPollAfter; + + if (VG_(clo_trace_signals)) + VG_(message)(Vg_DebugMsg, "thr_kill: sending signal %ld to tid %ld", + ARG2, ARG1); + + /* If we're sending SIGKILL, check to see if the target is one of + our threads and handle it specially. */ + if (ARG2 == 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 |= SfMayBlock; +} +POST(sys_thr_kill) +{ + if (VG_(clo_trace_signals)) + VG_(message)(Vg_DebugMsg, "thr_kill: sent signal %ld to tid %ld", + ARG2, ARG1); +} +PRE(sys_thr_kill2) +{ + PRINT("sys_thr_kill2 ( %ld, %ld, %ld )", ARG1,ARG2,ARG3); + PRE_REG_READ3(long, "tgkill", int, pid, long, tid, int, sig); + if (!ML_(client_signal_OK)(ARG3)) { + SET_STATUS_Failure( VKI_EINVAL ); + return; + } + + /* Check to see if this kill gave us a pending signal */ + *flags |= SfPollAfter; + + if (VG_(clo_trace_signals)) + VG_(message)(Vg_DebugMsg, "thr_kill2: sending signal %ld to pid %ld/%ld", + ARG3, ARG1, ARG2); + + /* If we're sending SIGKILL, check to see if the target is one of + our threads and handle it specially. */ + if (ARG3 == VKI_SIGKILL && ML_(do_sigkill)(ARG2, ARG1)) { + 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 |= SfMayBlock; +} +POST(sys_thr_kill2) +{ + if (VG_(clo_trace_signals)) + VG_(message)(Vg_DebugMsg, "thr_kill2: sent signal %ld to pid %ld/%ld", + ARG3, ARG1, ARG2); +} + /* --------------------------------------------------------------------- umtx* wrappers ------------------------------------------------------------------ */ @@ -3505,7 +3586,7 @@ BSDX_(__NR_thr_exit, sys_thr_exit), // 431 BSDXY(__NR_thr_self, sys_thr_self), // 432 - // thr_kill 433 + BSDXY(__NR_thr_kill, sys_thr_kill), // 433 BSDXY(__NR__umtx_lock, sys__umtx_lock), // 434 BSDXY(__NR__umtx_unlock, sys__umtx_unlock), // 435 @@ -3565,7 +3646,7 @@ BSDX_(__NR_truncate7, sys_truncate7), // 479 BSDX_(__NR_ftruncate7, sys_ftruncate7), // 480 - // thr_kill2 481 + BSDXY(__NR_thr_kill2, sys_thr_kill2), // 481 // shm_open 482 // shm_unlink 483