3 * j_flow.d - snoop Java execution showing method flow using DTrace.
4 * Written for the Java hotspot DTrace provider.
6 * $Id: j_flow.d 38 2007-09-16 08:17:41Z brendan $
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
12 * USAGE: j_flow.d # hit Ctrl-C to end
14 * This watches Java method entries and returns, and indents child
19 * TIME(us) Time since boot, us
21 * CLASS.METHOD Java class and method name
27 * WARNING: Watch the first column carefully, it prints the CPU-id. If it
28 * changes, then it is very likely that the output has been shuffled.
29 * Changes in TID will appear to shuffle output, as we change from one thread
30 * depth to the next. See Docs/Notes/ALLjavaflow.txt for additional notes.
32 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
36 * The contents of this file are subject to the terms of the
37 * Common Development and Distribution License, Version 1.0 only
38 * (the "License"). You may not use this file except in compliance
41 * You can obtain a copy of the license at Docs/cddl1.txt
42 * or http://www.opensolaris.org/os/licensing.
43 * See the License for the specific language governing permissions
44 * and limitations under the License.
48 * 09-Sep-2007 Brendan Gregg Created this.
51 /* increasing bufsize can reduce drops */
52 #pragma D option bufsize=16m
53 #pragma D option quiet
54 #pragma D option switchrate=10
60 printf("%3s %6s %-16s -- %s\n", "C", "PID", "TIME(us)", "CLASS.METHOD");
63 hotspot*:::method-entry
65 this->class = (char *)copyin(arg1, arg2 + 1);
66 this->class[arg2] = '\0';
67 this->method = (char *)copyin(arg3, arg4 + 1);
68 this->method[arg4] = '\0';
70 printf("%3d %6d %-16d %*s-> %s.%s\n", cpu, pid, timestamp / 1000,
71 self->depth[arg0] * 2, "", stringof(this->class),
72 stringof(this->method));
76 hotspot*:::method-return
78 this->class = (char *)copyin(arg1, arg2 + 1);
79 this->class[arg2] = '\0';
80 this->method = (char *)copyin(arg3, arg4 + 1);
81 this->method[arg4] = '\0';
83 self->depth[arg0] -= self->depth[arg0] > 0 ? 1 : 0;
84 printf("%3d %6d %-16d %*s<- %s.%s\n", cpu, pid, timestamp / 1000,
85 self->depth[arg0] * 2, "", stringof(this->class),
86 stringof(this->method));