PERFORCE change 97462 for review

John Birrell jb at FreeBSD.org
Fri May 19 20:13:55 UTC 2006


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

Change 97462 by jb at jb_freebsd2 on 2006/05/19 20:12:52

	This is an example of adding a Statically Defined Tracing (SDT) probe
	to the entry and return of a function. Eventually adding probes like
	this won't be necessary because there will by the Function Boundary
	Trace (FBT) provider which will be able to do that for *any* non-leaf
	function.
	
	To show how DTrace can reference structures, here is a script which
	installs a probe on the return from linker_file_load():
	
	sdt:linker:linker_load_module:return
	{
	    plf = (struct linker_file **) arg4;
	    lf = *plf;
	    printf("filename '%s' pathname '%s' refs %d userrefs %d flags %d id %d size %lu address 0x%lx ndeps %d",
		stringof(lf->filename), stringof(lf->pathname), 
		lf->refs, lf->userrefs, lf->flags,
		lf->id, (u_long) lf->size,
		(u_long) lf->address, lf->ndeps);
	}
	
	When the 'systrace' module is loaded, this is the output:
	
	CPU     ID                    FUNCTION:NAME
	  0    927        linker_load_module:return filename 'systrace.ko' pathname '/boot/kernel/systrace.ko' refs 1 userrefs 0 flags 1 id 10 size 24576 address 0xc520b000 ndeps 2

Affected files ...

.. //depot/projects/dtrace/src/sys/kern/kern_linker.c#6 edit

Differences ...

==== //depot/projects/dtrace/src/sys/kern/kern_linker.c#6 (text+ko) ====

@@ -40,6 +40,7 @@
 #include <sys/proc.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
+#include <sys/sdt.h>
 #include <sys/sx.h>
 #include <sys/mac.h>
 #include <sys/module.h>
@@ -1816,6 +1817,8 @@
 	char *pathname;
 	int error;
 
+	SDT_PROBE(linker, linker_load_module, entry, kldname, modname, parent, verinfo, lfpp);
+
 	if (modname == NULL) {
 		/*
  		 * We have to load KLD
@@ -1872,6 +1875,9 @@
 out:
 	if (pathname)
 		free(pathname, M_LINKER);
+
+	SDT_PROBE(linker, linker_load_module, return, kldname, modname, parent, error, lfpp);
+
 	return (error);
 }
 


More information about the p4-projects mailing list