xref: /netbsd-src/external/cddl/dtracetoolkit/dist/Python/py_funccalls.d (revision c29d51755812ace2e87aeefdb06cb2b4dac7087a)
1*c29d5175Schristos #!/usr/sbin/dtrace -Zs
2*c29d5175Schristos /*
3*c29d5175Schristos  * py_funccalls.d - measure Python function calls using DTrace.
4*c29d5175Schristos  *                  Written for the Python DTrace provider.
5*c29d5175Schristos  *
6*c29d5175Schristos  * $Id: py_funccalls.d,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $
7*c29d5175Schristos  *
8*c29d5175Schristos  * This traces Python activity from all running programs on the system
9*c29d5175Schristos  * which support the Python DTrace provider.
10*c29d5175Schristos  *
11*c29d5175Schristos  * USAGE: py_funccalls.d 		# hit Ctrl-C to end
12*c29d5175Schristos  *
13*c29d5175Schristos  * FIELDS:
14*c29d5175Schristos  *              FILE		Filename that contained the function
15*c29d5175Schristos  *		FUNC		Python function name
16*c29d5175Schristos  *		CALLS		Function calls during this sample
17*c29d5175Schristos  *
18*c29d5175Schristos  * Filename and function names are printed if available.
19*c29d5175Schristos  *
20*c29d5175Schristos  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
21*c29d5175Schristos  *
22*c29d5175Schristos  * CDDL HEADER START
23*c29d5175Schristos  *
24*c29d5175Schristos  *  The contents of this file are subject to the terms of the
25*c29d5175Schristos  *  Common Development and Distribution License, Version 1.0 only
26*c29d5175Schristos  *  (the "License").  You may not use this file except in compliance
27*c29d5175Schristos  *  with the License.
28*c29d5175Schristos  *
29*c29d5175Schristos  *  You can obtain a copy of the license at Docs/cddl1.txt
30*c29d5175Schristos  *  or http://www.opensolaris.org/os/licensing.
31*c29d5175Schristos  *  See the License for the specific language governing permissions
32*c29d5175Schristos  *  and limitations under the License.
33*c29d5175Schristos  *
34*c29d5175Schristos  * CDDL HEADER END
35*c29d5175Schristos  *
36*c29d5175Schristos  * 09-Sep-2007	Brendan Gregg	Created this.
37*c29d5175Schristos  */
38*c29d5175Schristos 
39*c29d5175Schristos #pragma D option quiet
40*c29d5175Schristos 
41*c29d5175Schristos dtrace:::BEGIN
42*c29d5175Schristos {
43*c29d5175Schristos 	printf("Tracing... Hit Ctrl-C to end.\n");
44*c29d5175Schristos }
45*c29d5175Schristos 
46*c29d5175Schristos python*:::function-entry
47*c29d5175Schristos {
48*c29d5175Schristos 	@funcs[basename(copyinstr(arg0)), copyinstr(arg1)] = count();
49*c29d5175Schristos }
50*c29d5175Schristos 
51*c29d5175Schristos dtrace:::END
52*c29d5175Schristos {
53*c29d5175Schristos 	printf(" %-32s %-32s %8s\n", "FILE", "FUNC", "CALLS");
54*c29d5175Schristos 	printa(" %-32s %-32s %@8d\n", @funcs);
55*c29d5175Schristos }
56