From 4cc9f52f78db4ae6e9187b784b39692e7560f2f5 Mon Sep 17 00:00:00 2001 From: Robert Drehmel Date: Fri, 26 Sep 2003 15:09:46 +0000 Subject: [PATCH] Move some tracing related code into its own function as it will be needed for system call related ptrace functionality I plan to commit soon. --- sys/kern/kern_sig.c | 39 ++++++++++++++++++++++++--------------- sys/sys/signalvar.h | 1 + 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index e24be92726ad..03697dc8a18e 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2021,6 +2021,29 @@ tdsigwakeup(struct thread *td, int sig, sig_t action) #endif } +void +ptracestop(struct thread *td, int sig) +{ + struct proc *p = td->td_proc; + + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, + &p->p_mtx.mtx_object, "Stopping for traced signal"); + + p->p_xstat = sig; + PROC_LOCK(p->p_pptr); + psignal(p->p_pptr, SIGCHLD); + PROC_UNLOCK(p->p_pptr); + mtx_lock_spin(&sched_lock); + stop(p); /* uses schedlock too eventually */ + thread_suspend_one(td); + PROC_UNLOCK(p); + DROP_GIANT(); + p->p_stats->p_ru.ru_nivcsw++; + mi_switch(); + mtx_unlock_spin(&sched_lock); + PICKUP_GIANT(); +} + /* * If the current process has received a signal (should be caught or cause * termination, should interrupt current syscall), return the signal number. @@ -2074,21 +2097,7 @@ issignal(td) * If traced, always stop. */ mtx_unlock(&ps->ps_mtx); - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, - &p->p_mtx.mtx_object, "Stopping for traced signal"); - p->p_xstat = sig; - PROC_LOCK(p->p_pptr); - psignal(p->p_pptr, SIGCHLD); - PROC_UNLOCK(p->p_pptr); - mtx_lock_spin(&sched_lock); - stop(p); /* uses schedlock too eventually */ - thread_suspend_one(td); - PROC_UNLOCK(p); - DROP_GIANT(); - p->p_stats->p_ru.ru_nivcsw++; - mi_switch(); - mtx_unlock_spin(&sched_lock); - PICKUP_GIANT(); + ptracestop(td, sig); PROC_LOCK(p); mtx_lock(&ps->ps_mtx); diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 70b7904f2e0b..a67c3ce7c035 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -276,6 +276,7 @@ void siginit(struct proc *p); void signotify(struct thread *td); void tdsignal(struct thread *td, int sig, sigtarget_t target); void trapsignal(struct thread *td, int sig, u_long code); +void ptracestop(struct thread *td, int sig); /* * Machine-dependent functions: