blob: ae12be328e0dcd7c7feeebd47d8561aa55740c16 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#!/usr/sbin/dtrace -Zs
2/*
3 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of Sun Microsystems nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/*
34*/
35
36/*
37 * Usage:
38 * 1. hotspot_calls_tree.d -c "java ..."
39 * 2. hotspot_calls_tree.d -p JAVA_PID
40 *
41 * This script prints calls tree of fired 'hotspot' probes.
42 *
43 * Notes:
44 * The script uses 'monitors' probes which are disabled by default since
45 * it incurs performance overhead to the application. To enable them, you
46 * need to turn on the ExtendedDTraceProbes VM option. You can either
47 * start the application with -XX:+ExtendedDTraceProbes option or use the
48 * jinfo command to enable it at runtime as follows:
49 *
50 * jinfo -flag +ExtendedDTraceProbes <java_pid>
51 *
52 */
53
54#pragma D option quiet
55#pragma D option destructive
56#pragma D option defaultargs
57#pragma D option aggrate=100ms
58
59self int indent;
60string PAUSE_AT_STARTUP_FILE;
61
62:::BEGIN
63{
64 SAMPLE_NAME = "hotspot probes tracing";
65
66 printf("BEGIN %s\n\n", SAMPLE_NAME);
67
68 self->indent = 10;
69}
70
71hotspot$target:::class-loaded,
72hotspot$target:::class-unloaded,
73hotspot$target:::compiled-method-load,
74hotspot$target:::compiled-method-unload,
75hotspot$target:::monitor-notify,
76hotspot$target:::monitor-notifyAll
77{
78 printf("%d %*s <-> %s\n", curcpu->cpu_id, self->indent, "", probename);
79}
80
81hotspot$target:::vm-init-begin,
82hotspot$target:::gc-begin,
83hotspot$target:::mem-pool-gc-begin,
84hotspot$target:::thread-start,
85hotspot$target:::method-compile-begin,
86hotspot$target:::monitor-contended-enter,
87hotspot$target:::monitor-wait
88{
89 self->indent ++;
90 printf("%d %*s -> %s\n", curcpu->cpu_id, self->indent, "", probename);
91}
92
93hotspot$target:::vm-init-end,
94hotspot$target:::vm-shutdown,
95hotspot$target:::gc-end,
96hotspot$target:::mem-pool-gc-end,
97hotspot$target:::thread-stop,
98hotspot$target:::method-compile-end,
99hotspot$target:::monitor-contended-entered,
100hotspot$target:::monitor-contended-exit,
101hotspot$target:::monitor-waited
102{
103 printf("%d %*s <- %s\n", curcpu->cpu_id, self->indent, "", probename);
104 self->indent --;
105}
106
107:::END
108{
109 printf("\nEND of %s\n", SAMPLE_NAME);
110}
111
112syscall::rexit:entry,
113syscall::exit:entry
114/pid == $target/
115{
116 exit(0);
117}