PERFORCE change 133838 for review
John Birrell
jb at FreeBSD.org
Mon Jan 21 17:50:43 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=133838
Change 133838 by jb at jb_freebsd1 on 2008/01/22 01:50:22
Add SDT probes for process exec and exit.
Affected files ...
.. //depot/projects/dtrace/src/sys/kern/kern_exec.c#23 edit
.. //depot/projects/dtrace/src/sys/kern/kern_exit.c#16 edit
Differences ...
==== //depot/projects/dtrace/src/sys/kern/kern_exec.c#23 (text+ko) ====
@@ -28,6 +28,7 @@
__FBSDID("$FreeBSD: src/sys/kern/kern_exec.c,v 1.315 2008/01/13 14:44:08 attilio Exp $");
#include "opt_hwpmc_hooks.h"
+#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_mac.h"
#include "opt_vm.h"
@@ -54,6 +55,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>
@@ -83,6 +85,14 @@
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
+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);
@@ -348,6 +358,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.
@@ -726,6 +738,9 @@
else
crfree(newcred);
VOP_UNLOCK(imgp->vp, 0);
+
+ SDT_PROBE(proc, kernel, , exec_success, args->fname, 0, 0, 0, 0);
+
/*
* Handle deferred decrement of ref counts.
*/
@@ -788,6 +803,8 @@
p->p_flag &= ~P_INEXEC;
PROC_UNLOCK(p);
+ SDT_PROBE(proc, kernel, , exec_failure, error, 0, 0, 0, 0);
+
done2:
#ifdef MAC
mac_execve_exit(imgp);
==== //depot/projects/dtrace/src/sys/kern/kern_exit.c#16 (text+ko) ====
@@ -38,6 +38,7 @@
__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.307 2008/01/13 14:44:08 attilio Exp $");
#include "opt_compat.h"
+#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_mac.h"
@@ -65,6 +66,7 @@
#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,10 @@
#include <vm/vm_page.h>
#include <vm/uma.h>
+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");
@@ -453,6 +459,15 @@
*/
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
More information about the p4-projects
mailing list