PERFORCE change 134445 for review

John Birrell jb at FreeBSD.org
Tue Jan 29 21:46:44 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=134445

Change 134445 by jb at jb_freebsd1 on 2008/01/30 05:46:13

	IFdtrace

Affected files ...

.. //depot/projects/dtrace7/src/sys/kern/kern_exec.c#4 edit

Differences ...

==== //depot/projects/dtrace7/src/sys/kern/kern_exec.c#4 (text+ko) ====

@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD: src/sys/kern/kern_exec.c,v 1.308.2.2 2008/01/18 10:02:51 kib Exp $");
 
 #include "opt_hwpmc_hooks.h"
+#include "opt_kdtrace.h"
 #include "opt_ktrace.h"
 #include "opt_mac.h"
 
@@ -53,6 +54,7 @@
 #include <sys/pioctl.h>
 #include <sys/namei.h>
 #include <sys/resourcevar.h>
+#include <sys/sdt.h>
 #include <sys/sf_buf.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysent.h>
@@ -82,6 +84,19 @@
 #include <security/audit/audit.h>
 #include <security/mac/mac_framework.h>
 
+#ifdef KDTRACE_HOOKS
+#include <sys/dtrace_bsd.h>
+dtrace_execexit_func_t	dtrace_fasttrap_exec;
+#endif
+
+SDT_PROVIDER_DECLARE(proc);
+SDT_PROBE_DEFINE(proc, kernel, , exec);
+SDT_PROBE_ARGTYPE(proc, kernel, , exec, 0, "char *");
+SDT_PROBE_DEFINE(proc, kernel, , exec_failure);
+SDT_PROBE_ARGTYPE(proc, kernel, , exec_failure, 0, "int");
+SDT_PROBE_DEFINE(proc, kernel, , exec_success);
+SDT_PROBE_ARGTYPE(proc, kernel, , exec_success, 0, "char *");
+
 MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments");
 
 static int sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS);
@@ -347,6 +362,8 @@
 
 	imgp->image_header = NULL;
 
+	SDT_PROBE(proc, kernel, , exec, args->fname, 0, 0, 0, 0 );
+
 	/*
 	 * Translate the file name. namei() returns a vnode pointer
 	 *	in ni_vp amoung other things.
@@ -653,6 +670,15 @@
 	textvp = p->p_textvp;
 	p->p_textvp = ndp->ni_vp;
 
+#ifdef KDTRACE_HOOKS
+	/*
+	 * Tell the DTrace fasttrap provider about the exec if it
+	 * has declared an interest.
+	 */
+	if (dtrace_fasttrap_exec)
+		dtrace_fasttrap_exec(p);
+#endif
+
 	/*
 	 * Notify others that we exec'd, and clear the P_INEXEC flag
 	 * as we're now a bona fide freshly-execed process.
@@ -724,6 +750,9 @@
 	else
 		crfree(newcred);
 	VOP_UNLOCK(imgp->vp, 0, td);
+
+	SDT_PROBE(proc, kernel, , exec_success, args->fname, 0, 0, 0, 0);
+
 	/*
 	 * Handle deferred decrement of ref counts.
 	 */


More information about the p4-projects mailing list