3 * j_classflow.d - trace a Java class method flow using DTrace.
4 * Written for the Java hotspot DTrace provider.
6 * $Id: j_classflow.d 63 2007-10-04 04:34:38Z 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_classflow.d classname # 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 defaultargs
55 #pragma D option switchrate=10
62 printf("USAGE: j_classflow.d classname\n");
68 printf("%3s %6s %-16s -- %s\n", "C", "PID", "TIME(us)", "CLASS.METHOD");
71 hotspot*:::method-entry,
72 hotspot*:::method-return
74 this->class = stringof((char *)copyin(arg1, arg2 + 1));
75 this->class[arg2] = '\0';
78 hotspot*:::method-entry
81 this->method = (char *)copyin(arg3, arg4 + 1);
82 this->method[arg4] = '\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));
90 hotspot*:::method-return
93 this->method = (char *)copyin(arg3, arg4 + 1);
94 this->method[arg4] = '\0';
96 self->depth[arg0] -= self->depth[arg0] > 0 ? 1 : 0;
97 printf("%3d %6d %-16d %*s<- %s.%s\n", cpu, pid, timestamp / 1000,
98 self->depth[arg0] * 2, "", stringof(this->class),
99 stringof(this->method));