diff options
Diffstat (limited to 'sys/kern/kern_exit.c')
| -rw-r--r-- | sys/kern/kern_exit.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 4f8a70e4e5e4..1c9bf4c115eb 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" +#include "opt_kdtrace.h" #include "opt_ktrace.h" #include "opt_mac.h" @@ -65,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include <sys/ptrace.h> #include <sys/acct.h> /* for acct_process() function prototype */ #include <sys/filedesc.h> +#include <sys/sdt.h> #include <sys/shm.h> #include <sys/sem.h> #ifdef KTRACE @@ -82,6 +84,15 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_page.h> #include <vm/uma.h> +#ifdef KDTRACE_HOOKS +#include <sys/dtrace_bsd.h> +dtrace_execexit_func_t dtrace_fasttrap_exit; +#endif + +SDT_PROVIDER_DECLARE(proc); +SDT_PROBE_DEFINE(proc, kernel, , exit); +SDT_PROBE_ARGTYPE(proc, kernel, , exit, 0, "int"); + /* Required to be non-static for SysVR4 emulator */ MALLOC_DEFINE(M_ZOMBIE, "zombie", "zombie proc status"); @@ -449,11 +460,29 @@ retry: PROC_LOCK(p); p->p_xstat = rv; p->p_xthread = td; + +#ifdef KDTRACE_HOOKS + /* + * Tell the DTrace fasttrap provider about the exit if it + * has declared an interest. + */ + if (dtrace_fasttrap_exit) + dtrace_fasttrap_exit(p); +#endif + /* * Notify interested parties of our demise. */ KNOTE_LOCKED(&p->p_klist, NOTE_EXIT); +#ifdef KDTRACE_HOOKS + int reason = CLD_EXITED; + if (WCOREDUMP(rv)) + reason = CLD_DUMPED; + else if (WIFSIGNALED(rv)) + reason = CLD_KILLED; + SDT_PROBE(proc, kernel, , exit, reason, 0, 0, 0, 0); +#endif /* * Just delete all entries in the p_klist. At this point we won't * report any more events, and there are nasty race conditions that |
