summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_syscall.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-10-06 19:29:05 +0000
committerjhb <jhb@FreeBSD.org>2015-10-06 19:29:05 +0000
commitb86a33b09af1689e3c51798e8fd2ae64f10730ef (patch)
tree9c2fb0e83703da81c6d14a4278d5fffc07f40d49 /sys/kern/subr_syscall.c
parent2ba80c73b3b54431a6f0f93914c2125d4ef65b69 (diff)
downloadFreeBSD-src-b86a33b09af1689e3c51798e8fd2ae64f10730ef.zip
FreeBSD-src-b86a33b09af1689e3c51798e8fd2ae64f10730ef.tar.gz
Fix various edge cases related to system call tracing.
- Always set td_dbg_sc_* when P_TRACED is set on system call entry even if the debugger is not tracing system call entries. This ensures the fields are valid when reporting other stops that occur at system call boundaries such as for PT_FOLLOW_FORKS or when only tracing system call exits. - Set TDB_SCX when reporting the stop for a new child process in fork_return(). This causes the event to be reported as a system call exit. - Report a system call exit event in fork_return() for new threads in a traced process. - Copy td_dbg_sc_* to new threads instead of zeroing. This ensures that td_dbg_sc_code in particular will report the system call that created the new thread or process when it reports a system call exit event in fork_return(). - Add new ptrace tests to verify that new child processes and threads report system call exit events with a valid pl_syscall_code via PT_LWPINFO. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D3822
Diffstat (limited to 'sys/kern/subr_syscall.c')
-rw-r--r--sys/kern/subr_syscall.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c
index af09613..71f3d59 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -83,11 +83,12 @@ syscallenter(struct thread *td, struct syscall_args *sa)
if (error == 0) {
STOPEVENT(p, S_SCE, sa->narg);
- if (p->p_flag & P_TRACED && p->p_stops & S_PT_SCE) {
+ if (p->p_flag & P_TRACED) {
PROC_LOCK(p);
td->td_dbg_sc_code = sa->code;
td->td_dbg_sc_narg = sa->narg;
- ptracestop((td), SIGTRAP);
+ if (p->p_stops & S_PT_SCE)
+ ptracestop((td), SIGTRAP);
PROC_UNLOCK(p);
}
if (td->td_dbgflags & TDB_USERWR) {
OpenPOWER on IntegriCloud