Module Name: src Committed By: kamil Date: Wed Feb 22 23:43:44 UTC 2017
Modified Files: src/lib/libc/sys: ptrace.2 src/sys/kern: sys_ptrace_common.c src/sys/sys: ptrace.h src/tests/kernel: t_ptrace_wait.c Log Message: Introduce new ptrace(2) API to allow/prevent exection of LWP Introduce new API for debuggers to allow/prevent execution of the specified thread. New ptrace(2) operations: PT_RESUME Allow execution of a specified thread, change its state from suspended to continued. The addr argument is unused. The data argument specifies the LWP ID. This call is equivalent to _lwp_continue(2) called by a traced process. This call does not change the general process state from stopped to continued. PT_SUSPEND Prevent execution of a specified thread, change its state from continued to suspended. The addr argument is unused. The data argument specifies the requested LWP ID. This call is equivalent to _lwp_suspend(2) called by a traced process. This call does not change the general process state from continued to stopped. This interface is modeled after FreeBSD, however with NetBSD specific arguments passed to ptrace(2) -- FreeBSD passes only thread id, NetBSD passes process and thread id. Extend PT_LWPINFO operation in ptrace(2) to report suspended threads. In the ptrace_lwpinfo structure in pl_event next to PL_EVENT_NONE and PL_EVENT_SIGNAL add new value PL_EVENT_SUSPENDED. Add new errno(2) value EDEADLK that might be returned by ptrace(2). It prevents dead-locking in a scenario of resuming a process or thread that is prevented from execution. This fixes bug that old API was vulnerable to this scenario. Kernel bump delayed till introduction of PT_GETDBREGS/PT_SETDBREGS soon. Add new ATF tests: - resume1 Verify that a thread can be suspended by a debugger and later resumed by the debugger - suspend1 Verify that a thread can be suspended by a debugger and later resumed by a tracee - suspend2 Verify that the while the only thread within a process is suspended, the whole process cannot be unstopped Sponsored by <The NetBSD Foundation> To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/lib/libc/sys/ptrace.2 cvs rdiff -u -r1.14 -r1.15 src/sys/kern/sys_ptrace_common.c cvs rdiff -u -r1.56 -r1.57 src/sys/sys/ptrace.h cvs rdiff -u -r1.70 -r1.71 src/tests/kernel/t_ptrace_wait.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.