tcl_proccalls.d revision 235368
1112444Sphk#!/usr/sbin/dtrace -Zs
2112444Sphk/*
3112444Sphk * tcl_methodcalls.d - count Tcl method calls DTrace.
4112444Sphk *                     Written for the Tcl DTrace provider.
5112444Sphk *
6112444Sphk * $Id: tcl_proccalls.d 63 2007-10-04 04:34:38Z brendan $
7112444Sphk *
8112444Sphk * This traces activity from all Tcl processes on the system with DTrace
9112444Sphk * provider support (tcl8.4.16).
10112444Sphk *
11112444Sphk * USAGE: tcl_methodcalls.d 	# hit Ctrl-C to end
12112444Sphk *
13112444Sphk * FIELDS:
14112444Sphk *		PID		Process ID
15112444Sphk *		COUNT		Number of calls during sample
16112444Sphk *		PROCEDURE	Tcl procedure name
17112444Sphk *
18112444Sphk * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
19112444Sphk *
20 * CDDL HEADER START
21 *
22 *  The contents of this file are subject to the terms of the
23 *  Common Development and Distribution License, Version 1.0 only
24 *  (the "License").  You may not use this file except in compliance
25 *  with the License.
26 *
27 *  You can obtain a copy of the license at Docs/cddl1.txt
28 *  or http://www.opensolaris.org/os/licensing.
29 *  See the License for the specific language governing permissions
30 *  and limitations under the License.
31 *
32 * CDDL HEADER END
33 *
34 * 09-Sep-2007	Brendan Gregg	Created this.
35 */
36
37#pragma D option quiet
38
39dtrace:::BEGIN
40{
41	printf("Tracing... Hit Ctrl-C to end.\n");
42}
43
44tcl*:::proc-entry
45{
46	@calls[pid, copyinstr(arg0)] = count();
47}
48
49dtrace:::END
50{
51	printf(" %6s %8s %s\n", "PID", "COUNT", "PROCEDURE");
52	printa(" %6d %@8d %s\n", @calls);
53}
54