1 #!/usr/sbin/dtrace -CZs
3 * j_profile.d - sample stack traces with Java translations using DTrace.
5 * USAGE: j_profile.d { -p PID | -c cmd } # hit Ctrl-C to end
6 * $Id: j_profile.d 19 2007-09-12 07:47:59Z brendan $
9 * This samples stack traces for the process specified. This stack trace
10 * will cross the JVM and system libraries, and insert translations for Java
11 * stack frames where appropriate. This is best explained with an example
17 * Func_loop.main([Ljava/lang/String;)V
19 * libjvm.so`__1cJJavaCallsLcall_helper6FpnJJavaValue_pnMmethodHan
20 * libjvm.so`__1cCosUos_exception_wrapper6FpFpnJJavaValue_pnMmetho
21 * libjvm.so`__1cJJavaCallsEcall6FpnJJavaValue_nMmethodHandle_pnRJ
22 * libjvm.so`__1cRjni_invoke_static6FpnHJNIEnv__pnJJavaValue_pnI_j
23 * libjvm.so`jni_CallStaticVoidMethod+0x15d
25 * libc.so.1`_thr_setup+0x52
26 * libc.so.1`_lwp_start
29 * The lines at the top are Java frames, followed by the JVM (libjvm.so).
30 * The JVM symbols may be translated by passing the output through c++filt.
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 #pragma D option quiet
52 #pragma D option jstackstrsize=1024
57 #define DEPTH 10 /* stack depth, frames */
58 #define RATE 101 /* sampling rate, Hertz */
59 #define TOP 25 /* number of stacks to output */
63 printf("Sampling %d-level stacks at %d Hertz... Hit Ctrl-C to end.\n",
70 @stacks[jstack(DEPTH)] = count();
76 printf("Top %d most frequently sampled stacks,\n", TOP);