]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Tcl/tcl_calls.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Tcl / tcl_calls.d
1 #!/usr/sbin/dtrace -ZCs
2 /*
3  * tcl_calls.d - count Tcl calls (proc/cmd) using DTrace.
4  *               Written for the Tcl DTrace provider.
5  *
6  * $Id: tcl_calls.d 63 2007-10-04 04:34:38Z brendan $
7  *
8  * This traces activity from all Tcl processes on the system with DTrace
9  * provider support (tcl8.4.16).
10  *
11  * USAGE: tcl_calls.d           # hit Ctrl-C to end
12  *
13  * FIELDS:
14  *              PID             Process ID
15  *              TYPE            Type of call (see below)
16  *              NAME            Name of proc or cmd call
17  *              COUNT           Number of calls during sample
18  *
19  * TYPEs:
20  *              proc            procedure
21  *              cmd             command
22  *
23  * PORTIONS: Copyright (c) 2007 Brendan Gregg.
24  *
25  * CDDL HEADER START
26  *
27  *  The contents of this file are subject to the terms of the
28  *  Common Development and Distribution License, Version 1.0 only
29  *  (the "License").  You may not use this file except in compliance
30  *  with the License.
31  *
32  *  You can obtain a copy of the license at Docs/cddl1.txt
33  *  or http://www.opensolaris.org/os/licensing.
34  *  See the License for the specific language governing permissions
35  *  and limitations under the License.
36  *
37  * CDDL HEADER END
38  *
39  * 09-Sep-2007  Brendan Gregg   Created this.
40  */
41
42 #pragma D option quiet
43
44 dtrace:::BEGIN
45 {
46         printf("Tracing... Hit Ctrl-C to end.\n");
47 }
48
49 tcl*:::proc-entry
50 {
51         @calls[pid, "proc", copyinstr(arg0)] = count();
52 }
53
54 tcl*:::cmd-entry
55 {
56         @calls[pid, "cmd", copyinstr(arg0)] = count();
57 }
58
59 dtrace:::END
60 {
61         printf(" %6s %-8s %-52s %8s\n", "PID", "TYPE", "NAME", "COUNT");
62         printa(" %6d %-8s %-52s %@8d\n", @calls);
63 }