From owner-p4-projects@FreeBSD.ORG Fri May 19 20:13:54 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BB50916A424; Fri, 19 May 2006 20:13:54 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6405D16A420 for ; Fri, 19 May 2006 20:13:54 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2DA3043D48 for ; Fri, 19 May 2006 20:13:54 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k4JKDN9o042940 for ; Fri, 19 May 2006 20:13:23 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k4JKDNsI042937 for perforce@freebsd.org; Fri, 19 May 2006 20:13:23 GMT (envelope-from jb@freebsd.org) Date: Fri, 19 May 2006 20:13:23 GMT Message-Id: <200605192013.k4JKDNsI042937@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 97462 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 May 2006 20:13:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=97462 Change 97462 by jb@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 #include #include +#include #include #include #include @@ -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); }