]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - cddl/contrib/dtracetoolkit/Java/j_calls.d
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / cddl / contrib / dtracetoolkit / Java / j_calls.d
1 #!/usr/sbin/dtrace -Zs
2 /*
3  * j_calls.d - count Java calls (method/...) using DTrace.
4  *             Written for the Java hotspot DTrace provider.
5  *
6  * $Id: j_calls.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). Method calls and object allocation are only
10  * visible when using the flag "+ExtendedDTraceProbes". eg,
11  * java -XX:+ExtendedDTraceProbes classfile
12  *
13  * USAGE: j_calls.d             # hit Ctrl-C to end
14  *
15  * FIELDS:
16  *              PID             Process ID
17  *              TYPE            Type of call (see below)
18  *              NAME            Name of call
19  *              COUNT           Number of calls during sample
20  *
21  * TYPEs:
22  *              cload           class load
23  *              method          method call
24  *              mcompile        method compile
25  *              mload           compiled method load
26  *              oalloc          object alloc
27  *              thread          thread start
28  *
29  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
30  *
31  * CDDL HEADER START
32  *
33  *  The contents of this file are subject to the terms of the
34  *  Common Development and Distribution License, Version 1.0 only
35  *  (the "License").  You may not use this file except in compliance
36  *  with the License.
37  *
38  *  You can obtain a copy of the license at Docs/cddl1.txt
39  *  or http://www.opensolaris.org/os/licensing.
40  *  See the License for the specific language governing permissions
41  *  and limitations under the License.
42  *
43  * CDDL HEADER END
44  *
45  * 09-Sep-2007  Brendan Gregg   Created this.
46  */
47
48 #pragma D option quiet
49
50 dtrace:::BEGIN
51 {
52         printf("Tracing... Hit Ctrl-C to end.\n");
53 }
54
55 hotspot*:::method-entry
56 {
57         this->class = (char *)copyin(arg1, arg2 + 1);
58         this->class[arg2] = '\0';
59         this->method = (char *)copyin(arg3, arg4 + 1);
60         this->method[arg4] = '\0';
61         this->name = strjoin(strjoin(stringof(this->class), "."),
62             stringof(this->method));
63         @calls[pid, "method", this->name] = count();
64 }
65
66 hotspot*:::object-alloc
67 {
68         this->class = (char *)copyin(arg1, arg2 + 1);
69         this->class[arg2] = '\0';
70         @calls[pid, "oalloc", stringof(this->class)] = count();
71 }
72
73 hotspot*:::class-loaded
74 {
75         this->class = (char *)copyin(arg0, arg1 + 1);
76         this->class[arg1] = '\0';
77         @calls[pid, "cload", stringof(this->class)] = count();
78 }
79
80 hotspot*:::thread-start
81 {
82         this->thread = (char *)copyin(arg0, arg1 + 1);
83         this->thread[arg1] = '\0';
84         @calls[pid, "thread", stringof(this->thread)] = count();
85 }
86
87 hotspot*:::method-compile-begin
88 {
89         this->class = (char *)copyin(arg0, arg1 + 1);
90         this->class[arg1] = '\0';
91         this->method = (char *)copyin(arg2, arg3 + 1);
92         this->method[arg3] = '\0';
93         this->name = strjoin(strjoin(stringof(this->class), "."),
94             stringof(this->method));
95         @calls[pid, "mcompile", this->name] = count();
96 }
97
98 hotspot*:::compiled-method-load
99 {
100         this->class = (char *)copyin(arg0, arg1 + 1);
101         this->class[arg1] = '\0';
102         this->method = (char *)copyin(arg2, arg3 + 1);
103         this->method[arg3] = '\0';
104         this->name = strjoin(strjoin(stringof(this->class), "."),
105             stringof(this->method));
106         @calls[pid, "mload", this->name] = count();
107 }
108
109 dtrace:::END
110 {
111         printf(" %6s %-8s %-52s %8s\n", "PID", "TYPE", "NAME", "COUNT");
112         printa(" %6d %-8s %-52s %@8d\n", @calls);
113 }