diff options
author | Rui Paulo <rpaulo@FreeBSD.org> | 2010-08-02 12:13:33 +0000 |
---|---|---|
committer | Rui Paulo <rpaulo@FreeBSD.org> | 2010-08-02 12:13:33 +0000 |
commit | e0ea83ebb1a4b194c927cb114766e8781676380b (patch) | |
tree | 1bf8e417b1e4092355d2478f7c38c9db7e093700 /lib/libdtrace/common/dt_proc.c | |
parent | 37ddcfe2bb1d3b458470402a871a52af23e260e6 (diff) | |
download | src-e0ea83ebb1a4b194c927cb114766e8781676380b.tar.gz src-e0ea83ebb1a4b194c927cb114766e8781676380b.zip |
Notes
Diffstat (limited to 'lib/libdtrace/common/dt_proc.c')
-rw-r--r-- | lib/libdtrace/common/dt_proc.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/lib/libdtrace/common/dt_proc.c b/lib/libdtrace/common/dt_proc.c index 419f13b8474c..96e85f1bdb0f 100644 --- a/lib/libdtrace/common/dt_proc.c +++ b/lib/libdtrace/common/dt_proc.c @@ -20,12 +20,10 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * DTrace Process Control * @@ -89,9 +87,8 @@ #include <dt_pid.h> #include <dt_impl.h> -#define IS_SYS_EXEC(w) (w == SYS_exec || w == SYS_execve) -#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_fork1 || \ - w == SYS_forkall || w == SYS_forksys) +#define IS_SYS_EXEC(w) (w == SYS_execve) +#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_forksys) static dt_bkpt_t * dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data) @@ -99,7 +96,7 @@ dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data) struct ps_prochandle *P = dpr->dpr_proc; dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); if ((dbp = dt_zalloc(dpr->dpr_hdl, sizeof (dt_bkpt_t))) != NULL) { dbp->dbp_func = func; @@ -121,7 +118,7 @@ dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts) int state = Pstate(dpr->dpr_proc); dt_bkpt_t *dbp, *nbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = nbp) { if (delbkpts && dbp->dbp_active && @@ -141,7 +138,7 @@ dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr) const lwpstatus_t *psp = &Pstatus(dpr->dpr_proc)->pr_lwp; dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { @@ -167,7 +164,7 @@ dt_proc_bpenable(dt_proc_t *dpr) { dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { @@ -184,7 +181,7 @@ dt_proc_bpdisable(dt_proc_t *dpr) { dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { @@ -232,7 +229,7 @@ dt_proc_notify(dtrace_hdl_t *dtp, dt_proc_hash_t *dph, dt_proc_t *dpr, static void dt_proc_stop(dt_proc_t *dpr, uint8_t why) { - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); assert(why != DT_PROC_STOP_IDLE); if (dpr->dpr_stop & why) { @@ -333,7 +330,7 @@ dt_proc_attach(dt_proc_t *dpr, int exec) rd_err_e err; GElf_Sym sym; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); if (exec) { if (psp->pr_lwp.pr_errno != 0) @@ -399,7 +396,7 @@ dt_proc_waitrun(dt_proc_t *dpr) const long wstop = PCWSTOP; int pfd = Pctlfd(P); - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); assert(psp->pr_flags & PR_STOPPED); assert(Pstate(P) == PS_STOP); @@ -498,7 +495,6 @@ dt_proc_control(void *arg) * We must trace exit from exec() system calls so that if the exec is * successful, we can reset our breakpoints and re-initialize libproc. */ - (void) Psysexit(P, SYS_exec, B_TRUE); (void) Psysexit(P, SYS_execve, B_TRUE); /* @@ -509,10 +505,6 @@ dt_proc_control(void *arg) */ (void) Psysentry(P, SYS_vfork, B_TRUE); (void) Psysexit(P, SYS_vfork, B_TRUE); - (void) Psysentry(P, SYS_fork1, B_TRUE); - (void) Psysexit(P, SYS_fork1, B_TRUE); - (void) Psysentry(P, SYS_forkall, B_TRUE); - (void) Psysexit(P, SYS_forkall, B_TRUE); (void) Psysentry(P, SYS_forksys, B_TRUE); (void) Psysexit(P, SYS_forksys, B_TRUE); @@ -712,9 +704,12 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P) if (!(Pstatus(dpr->dpr_proc)->pr_flags & (PR_KLC | PR_RLC))) { dt_dprintf("abandoning pid %d\n", (int)dpr->dpr_pid); rflag = PRELEASE_HANG; + } else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) { + dt_dprintf("killing pid %d\n", (int)dpr->dpr_pid); + rflag = PRELEASE_KILL; /* apply kill-on-last-close */ } else { dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid); - rflag = 0; /* apply kill or run-on-last-close */ + rflag = 0; /* apply run-on-last-close */ } if (dpr->dpr_tid) { |