]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Java/j_methodcalls.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Java / j_methodcalls.d
1 #!/usr/sbin/dtrace -Zs
2 /*
3  * j_methodcalls.d - count Java method calls DTrace.
4  *                   Written for the Java hotspot DTrace provider.
5  *
6  * $Id: j_methodcalls.d 19 2007-09-12 07:47:59Z brendan $
7  *
8  * This traces activity from all Java processes on the system with hotspot
9  * provider support (1.6.0) and the flag "+ExtendedDTraceProbes". eg,
10  * java -XX:+ExtendedDTraceProbes classfile
11  *
12  * USAGE: j_methodcalls.d       # hit Ctrl-C to end
13  *
14  * FIELDS:
15  *              PID             Process ID
16  *              COUNT           Number of calls during sample
17  *              CLASS.METHOD    Java class and method name
18  *
19  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
20  *
21  * CDDL HEADER START
22  *
23  *  The contents of this file are subject to the terms of the
24  *  Common Development and Distribution License, Version 1.0 only
25  *  (the "License").  You may not use this file except in compliance
26  *  with the License.
27  *
28  *  You can obtain a copy of the license at Docs/cddl1.txt
29  *  or http://www.opensolaris.org/os/licensing.
30  *  See the License for the specific language governing permissions
31  *  and limitations under the License.
32  *
33  * CDDL HEADER END
34  *
35  * 09-Sep-2007  Brendan Gregg   Created this.
36  */
37
38 #pragma D option quiet
39
40 dtrace:::BEGIN
41 {
42         printf("Tracing... Hit Ctrl-C to end.\n");
43 }
44
45 hotspot*:::method-entry
46 {
47         this->class = (char *)copyin(arg1, arg2 + 1);
48         this->class[arg2] = '\0';
49         this->method = (char *)copyin(arg3, arg4 + 1);
50         this->method[arg4] = '\0';
51         this->name = strjoin(strjoin(stringof(this->class), "."),
52             stringof(this->method));
53         @calls[pid, this->name] = count();
54 }
55
56 dtrace:::END
57 {
58         printf(" %6s %8s %s\n", "PID", "COUNT", "CLASS.METHOD");
59         printa(" %6d %@8d %s\n", @calls);
60 }