|
1 /* |
|
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
|
3 * Copyright (c) 2009, 2012 Red Hat, Inc. |
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 * |
|
6 * This code is free software; you can redistribute it and/or modify it |
|
7 * under the terms of the GNU General Public License version 2 only, as |
|
8 * published by the Free Software Foundation. |
|
9 * |
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
|
14 * accompanied this code). |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License version |
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 * |
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 * or visit www.oracle.com if you need additional information or have any |
|
22 * questions. |
|
23 * |
|
24 */ |
|
25 |
|
26 #ifndef SHARE_VM_UTILITIES_DTRACE_HPP |
|
27 #define SHARE_VM_UTILITIES_DTRACE_HPP |
|
28 |
|
29 #if defined(DTRACE_ENABLED) |
|
30 |
|
31 #include <sys/sdt.h> |
|
32 |
|
33 #define DTRACE_ONLY(x) x |
|
34 #define NOT_DTRACE(x) |
|
35 |
|
36 #if defined(SOLARIS) |
|
37 // Work around dtrace tail call bug 6672627 until it is fixed in solaris 10. |
|
38 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \ |
|
39 do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0) |
|
40 |
|
41 #define USDT1 1 |
|
42 #elif defined(LINUX) |
|
43 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() |
|
44 #define USDT1 1 |
|
45 #elif defined(__APPLE__) |
|
46 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() |
|
47 #define USDT2 1 |
|
48 #include <sys/types.h> |
|
49 #include "dtracefiles/hotspot.h" |
|
50 #include "dtracefiles/hotspot_jni.h" |
|
51 #include "dtracefiles/hs_private.h" |
|
52 #else |
|
53 #error "dtrace enabled for unknown os" |
|
54 #endif /* defined(SOLARIS) */ |
|
55 |
|
56 #else /* defined(DTRACE_ENABLED) */ |
|
57 |
|
58 #define DTRACE_ONLY(x) |
|
59 #define NOT_DTRACE(x) x |
|
60 |
|
61 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() |
|
62 |
|
63 #ifndef USDT2 |
|
64 |
|
65 #define DTRACE_PROBE(a,b) {;} |
|
66 #define DTRACE_PROBE1(a,b,c) {;} |
|
67 #define DTRACE_PROBE2(a,b,c,d) {;} |
|
68 #define DTRACE_PROBE3(a,b,c,d,e) {;} |
|
69 #define DTRACE_PROBE4(a,b,c,d,e,f) {;} |
|
70 #define DTRACE_PROBE5(a,b,c,d,e,f,g) {;} |
|
71 #define DTRACE_PROBE6(a,b,c,d,e,f,g,h) {;} |
|
72 #define DTRACE_PROBE7(a,b,c,d,e,f,g,h,i) {;} |
|
73 #define DTRACE_PROBE8(a,b,c,d,e,f,g,h,i,j) {;} |
|
74 #define DTRACE_PROBE9(a,b,c,d,e,f,g,h,i,j,k) {;} |
|
75 #define DTRACE_PROBE10(a,b,c,d,e,f,g,h,i,j,k,l) {;} |
|
76 |
|
77 #else /* USDT2 */ |
|
78 |
|
79 #include "dtrace_usdt2_disabled.hpp" |
|
80 #endif /* USDT2 */ |
|
81 |
|
82 #endif /* defined(DTRACE_ENABLED) */ |
|
83 |
|
84 #ifndef USDT2 |
|
85 |
|
86 #define HS_DTRACE_PROBE_FN(provider,name)\ |
|
87 __dtrace_##provider##___##name |
|
88 |
|
89 #ifdef SOLARIS |
|
90 // Solaris dtrace needs actual extern function decls. |
|
91 #define HS_DTRACE_PROBE_DECL_N(provider,name,args) \ |
|
92 DTRACE_ONLY(extern "C" void HS_DTRACE_PROBE_FN(provider,name) args) |
|
93 #define HS_DTRACE_PROBE_CDECL_N(provider,name,args) \ |
|
94 DTRACE_ONLY(extern void HS_DTRACE_PROBE_FN(provider,name) args) |
|
95 #else |
|
96 // Systemtap dtrace compatible probes on GNU/Linux don't. |
|
97 // If dtrace is disabled this macro becomes NULL |
|
98 #define HS_DTRACE_PROBE_DECL_N(provider,name,args) |
|
99 #define HS_DTRACE_PROBE_CDECL_N(provider,name,args) |
|
100 #endif |
|
101 |
|
102 /* Dtrace probe declarations */ |
|
103 #define HS_DTRACE_PROBE_DECL(provider,name) \ |
|
104 HS_DTRACE_PROBE_DECL0(provider,name) |
|
105 #define HS_DTRACE_PROBE_DECL0(provider,name)\ |
|
106 HS_DTRACE_PROBE_DECL_N(provider,name,(void)) |
|
107 #define HS_DTRACE_PROBE_DECL1(provider,name,t0)\ |
|
108 HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t)) |
|
109 #define HS_DTRACE_PROBE_DECL2(provider,name,t0,t1)\ |
|
110 HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t,uintptr_t)) |
|
111 #define HS_DTRACE_PROBE_DECL3(provider,name,t0,t1,t2)\ |
|
112 HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t,uintptr_t,uintptr_t)) |
|
113 #define HS_DTRACE_PROBE_DECL4(provider,name,t0,t1,t2,t3)\ |
|
114 HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t,uintptr_t,uintptr_t,\ |
|
115 uintptr_t)) |
|
116 #define HS_DTRACE_PROBE_DECL5(provider,name,t0,t1,t2,t3,t4)\ |
|
117 HS_DTRACE_PROBE_DECL_N(provider,name,(\ |
|
118 uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t)) |
|
119 #define HS_DTRACE_PROBE_DECL6(provider,name,t0,t1,t2,t3,t4,t5)\ |
|
120 HS_DTRACE_PROBE_DECL_N(provider,name,(\ |
|
121 uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t)) |
|
122 #define HS_DTRACE_PROBE_DECL7(provider,name,t0,t1,t2,t3,t4,t5,t6)\ |
|
123 HS_DTRACE_PROBE_DECL_N(provider,name,(\ |
|
124 uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t)) |
|
125 #define HS_DTRACE_PROBE_DECL8(provider,name,t0,t1,t2,t3,t4,t5,t6,t7)\ |
|
126 HS_DTRACE_PROBE_DECL_N(provider,name,(\ |
|
127 uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\ |
|
128 uintptr_t)) |
|
129 #define HS_DTRACE_PROBE_DECL9(provider,name,t0,t1,t2,t3,t4,t5,t6,t7,t8)\ |
|
130 HS_DTRACE_PROBE_DECL_N(provider,name,(\ |
|
131 uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\ |
|
132 uintptr_t,uintptr_t)) |
|
133 #define HS_DTRACE_PROBE_DECL10(provider,name,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9)\ |
|
134 HS_DTRACE_PROBE_DECL_N(provider,name,(\ |
|
135 uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\ |
|
136 uintptr_t,uintptr_t,uintptr_t)) |
|
137 |
|
138 /* Dtrace probe definitions */ |
|
139 #if defined(SOLARIS) |
|
140 // Solaris dtrace uses actual function calls. |
|
141 #define HS_DTRACE_PROBE_N(provider,name, args) \ |
|
142 DTRACE_ONLY(HS_DTRACE_PROBE_FN(provider,name) args) |
|
143 |
|
144 #define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name) |
|
145 #define HS_DTRACE_PROBE0(provider,name)\ |
|
146 HS_DTRACE_PROBE_N(provider,name,()) |
|
147 #define HS_DTRACE_PROBE1(provider,name,a0)\ |
|
148 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0)) |
|
149 #define HS_DTRACE_PROBE2(provider,name,a0,a1)\ |
|
150 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1)) |
|
151 #define HS_DTRACE_PROBE3(provider,name,a0,a1,a2)\ |
|
152 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2)) |
|
153 #define HS_DTRACE_PROBE4(provider,name,a0,a1,a2,a3)\ |
|
154 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ |
|
155 (uintptr_t)a3)) |
|
156 #define HS_DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)\ |
|
157 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ |
|
158 (uintptr_t)a3,(uintptr_t)a4)) |
|
159 #define HS_DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)\ |
|
160 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ |
|
161 (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5)) |
|
162 #define HS_DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)\ |
|
163 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ |
|
164 (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6)) |
|
165 #define HS_DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)\ |
|
166 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ |
|
167 (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7)) |
|
168 #define HS_DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)\ |
|
169 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ |
|
170 (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\ |
|
171 (uintptr_t)a8)) |
|
172 #define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\ |
|
173 HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ |
|
174 (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\ |
|
175 (uintptr_t)a8,(uintptr_t)a9)) |
|
176 #else |
|
177 // Systemtap dtrace compatible probes on GNU/Linux use direct macros. |
|
178 // If dtrace is disabled this macro becomes NULL |
|
179 #define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name) |
|
180 #define HS_DTRACE_PROBE0(provider,name)\ |
|
181 DTRACE_PROBE(provider,name) |
|
182 #define HS_DTRACE_PROBE1(provider,name,a0)\ |
|
183 DTRACE_PROBE1(provider,name,a0) |
|
184 #define HS_DTRACE_PROBE2(provider,name,a0,a1)\ |
|
185 DTRACE_PROBE2(provider,name,a0,a1) |
|
186 #define HS_DTRACE_PROBE3(provider,name,a0,a1,a2)\ |
|
187 DTRACE_PROBE3(provider,name,a0,a1,a2) |
|
188 #define HS_DTRACE_PROBE4(provider,name,a0,a1,a2,a3)\ |
|
189 DTRACE_PROBE4(provider,name,a0,a1,a2,a3) |
|
190 #define HS_DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)\ |
|
191 DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4) |
|
192 #define HS_DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)\ |
|
193 DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5) |
|
194 #define HS_DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)\ |
|
195 DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6) |
|
196 #define HS_DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)\ |
|
197 DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7) |
|
198 #define HS_DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)\ |
|
199 DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8) |
|
200 #define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\ |
|
201 DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9) |
|
202 #endif |
|
203 |
|
204 #endif /* !USDT2 */ |
|
205 |
|
206 #endif // SHARE_VM_UTILITIES_DTRACE_HPP |