3 * j_calls.d - count Java calls (method/...) using DTrace.
4 * Written for the Java hotspot DTrace provider.
6 * $Id: j_calls.d 19 2007-09-12 07:47:59Z brendan $
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
13 * USAGE: j_calls.d # hit Ctrl-C to end
17 * TYPE Type of call (see below)
19 * COUNT Number of calls during sample
24 * mcompile method compile
25 * mload compiled method load
29 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
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
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.
45 * 09-Sep-2007 Brendan Gregg Created this.
48 #pragma D option quiet
52 printf("Tracing... Hit Ctrl-C to end.\n");
55 hotspot*:::method-entry
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();
66 hotspot*:::object-alloc
68 this->class = (char *)copyin(arg1, arg2 + 1);
69 this->class[arg2] = '\0';
70 @calls[pid, "oalloc", stringof(this->class)] = count();
73 hotspot*:::class-loaded
75 this->class = (char *)copyin(arg0, arg1 + 1);
76 this->class[arg1] = '\0';
77 @calls[pid, "cload", stringof(this->class)] = count();
80 hotspot*:::thread-start
82 this->thread = (char *)copyin(arg0, arg1 + 1);
83 this->thread[arg1] = '\0';
84 @calls[pid, "thread", stringof(this->thread)] = count();
87 hotspot*:::method-compile-begin
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();
98 hotspot*:::compiled-method-load
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();
111 printf(" %6s %-8s %-52s %8s\n", "PID", "TYPE", "NAME", "COUNT");
112 printa(" %6d %-8s %-52s %@8d\n", @calls);