1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright (c) 2013 by Delphix. All rights reserved. 24 */ 25 26 #ifndef _SYS_SDT_H 27 #define _SYS_SDT_H 28 29 #include <sys/stdint.h> 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #ifndef _KERNEL 36 37 #define DTRACE_PROBE(provider, name) { \ 38 extern void __dtrace_##provider##___##name(void); \ 39 __dtrace_##provider##___##name(); \ 40 } 41 42 #define DTRACE_PROBE1(provider, name, arg1) { \ 43 extern void __dtrace_##provider##___##name(unsigned long); \ 44 __dtrace_##provider##___##name((unsigned long)arg1); \ 45 } 46 47 #define DTRACE_PROBE2(provider, name, arg1, arg2) { \ 48 extern void __dtrace_##provider##___##name(unsigned long, \ 49 unsigned long); \ 50 __dtrace_##provider##___##name((unsigned long)arg1, \ 51 (unsigned long)arg2); \ 52 } 53 54 #define DTRACE_PROBE3(provider, name, arg1, arg2, arg3) { \ 55 extern void __dtrace_##provider##___##name(unsigned long, \ 56 unsigned long, unsigned long); \ 57 __dtrace_##provider##___##name((unsigned long)arg1, \ 58 (unsigned long)arg2, (unsigned long)arg3); \ 59 } 60 61 #define DTRACE_PROBE4(provider, name, arg1, arg2, arg3, arg4) { \ 62 extern void __dtrace_##provider##___##name(unsigned long, \ 63 unsigned long, unsigned long, unsigned long); \ 64 __dtrace_##provider##___##name((unsigned long)arg1, \ 65 (unsigned long)arg2, (unsigned long)arg3, \ 66 (unsigned long)arg4); \ 67 } 68 69 #define DTRACE_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) { \ 70 extern void __dtrace_##provider##___##name(unsigned long, \ 71 unsigned long, unsigned long, unsigned long, unsigned long);\ 72 __dtrace_##provider##___##name((unsigned long)arg1, \ 73 (unsigned long)arg2, (unsigned long)arg3, \ 74 (unsigned long)arg4, (unsigned long)arg5); \ 75 } 76 77 #else /* _KERNEL */ 78 79 #define DTRACE_PROBE(name) { \ 80 extern void __dtrace_probe_##name(void); \ 81 __dtrace_probe_##name(); \ 82 } 83 84 #define DTRACE_PROBE1(name, type1, arg1) { \ 85 extern void __dtrace_probe_##name(uintptr_t); \ 86 __dtrace_probe_##name((uintptr_t)(arg1)); \ 87 } 88 89 #define DTRACE_PROBE2(name, type1, arg1, type2, arg2) { \ 90 extern void __dtrace_probe_##name(uintptr_t, uintptr_t); \ 91 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2)); \ 92 } 93 94 #define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) { \ 95 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, uintptr_t); \ 96 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 97 (uintptr_t)(arg3)); \ 98 } 99 100 #define DTRACE_PROBE4(name, type1, arg1, type2, arg2, \ 101 type3, arg3, type4, arg4) { \ 102 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 103 uintptr_t, uintptr_t); \ 104 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 105 (uintptr_t)(arg3), (uintptr_t)(arg4)); \ 106 } 107 108 #define DTRACE_PROBE5(name, type1, arg1, type2, arg2, \ 109 type3, arg3, type4, arg4, type5, arg5) { \ 110 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 111 uintptr_t, uintptr_t, uintptr_t); \ 112 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 113 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5)); \ 114 } 115 116 #define DTRACE_PROBE6(name, type1, arg1, type2, arg2, \ 117 type3, arg3, type4, arg4, type5, arg5, type6, arg6) { \ 118 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 119 uintptr_t, uintptr_t, uintptr_t, uintptr_t); \ 120 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 121 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ 122 (uintptr_t)(arg6)); \ 123 } 124 125 #define DTRACE_PROBE7(name, type1, arg1, type2, arg2, type3, arg3, \ 126 type4, arg4, type5, arg5, type6, arg6, type7, arg7) { \ 127 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 128 uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); \ 129 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 130 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ 131 (uintptr_t)(arg6), (uintptr_t)(arg7)); \ 132 } 133 134 #define DTRACE_PROBE8(name, type1, arg1, type2, arg2, type3, arg3, \ 135 type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) { \ 136 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 137 uintptr_t, uintptr_t, uintptr_t, uintptr_t, \ 138 uintptr_t, uintptr_t); \ 139 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 140 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ 141 (uintptr_t)(arg6), (uintptr_t)(arg7), (uintptr_t)(arg8)); \ 142 } 143 144 #define DTRACE_SCHED(name) \ 145 DTRACE_PROBE(__sched_##name); 146 147 #define DTRACE_SCHED1(name, type1, arg1) \ 148 DTRACE_PROBE1(__sched_##name, type1, arg1); 149 150 #define DTRACE_SCHED2(name, type1, arg1, type2, arg2) \ 151 DTRACE_PROBE2(__sched_##name, type1, arg1, type2, arg2); 152 153 #define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) \ 154 DTRACE_PROBE3(__sched_##name, type1, arg1, type2, arg2, type3, arg3); 155 156 #define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \ 157 type3, arg3, type4, arg4) \ 158 DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, \ 159 type3, arg3, type4, arg4); 160 161 #define DTRACE_PROC(name) \ 162 DTRACE_PROBE(__proc_##name); 163 164 #define DTRACE_PROC1(name, type1, arg1) \ 165 DTRACE_PROBE1(__proc_##name, type1, arg1); 166 167 #define DTRACE_PROC2(name, type1, arg1, type2, arg2) \ 168 DTRACE_PROBE2(__proc_##name, type1, arg1, type2, arg2); 169 170 #define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) \ 171 DTRACE_PROBE3(__proc_##name, type1, arg1, type2, arg2, type3, arg3); 172 173 #define DTRACE_PROC4(name, type1, arg1, type2, arg2, \ 174 type3, arg3, type4, arg4) \ 175 DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, \ 176 type3, arg3, type4, arg4); 177 178 #define DTRACE_IO(name) \ 179 DTRACE_PROBE(__io_##name); 180 181 #define DTRACE_IO1(name, type1, arg1) \ 182 DTRACE_PROBE1(__io_##name, type1, arg1); 183 184 #define DTRACE_IO2(name, type1, arg1, type2, arg2) \ 185 DTRACE_PROBE2(__io_##name, type1, arg1, type2, arg2); 186 187 #define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) \ 188 DTRACE_PROBE3(__io_##name, type1, arg1, type2, arg2, type3, arg3); 189 190 #define DTRACE_IO4(name, type1, arg1, type2, arg2, \ 191 type3, arg3, type4, arg4) \ 192 DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, \ 193 type3, arg3, type4, arg4); 194 195 #define DTRACE_ISCSI_2(name, type1, arg1, type2, arg2) \ 196 DTRACE_PROBE2(__iscsi_##name, type1, arg1, type2, arg2); 197 198 #define DTRACE_ISCSI_3(name, type1, arg1, type2, arg2, type3, arg3) \ 199 DTRACE_PROBE3(__iscsi_##name, type1, arg1, type2, arg2, type3, arg3); 200 201 #define DTRACE_ISCSI_4(name, type1, arg1, type2, arg2, \ 202 type3, arg3, type4, arg4) \ 203 DTRACE_PROBE4(__iscsi_##name, type1, arg1, type2, arg2, \ 204 type3, arg3, type4, arg4); 205 206 #define DTRACE_ISCSI_5(name, type1, arg1, type2, arg2, \ 207 type3, arg3, type4, arg4, type5, arg5) \ 208 DTRACE_PROBE5(__iscsi_##name, type1, arg1, type2, arg2, \ 209 type3, arg3, type4, arg4, type5, arg5); 210 211 #define DTRACE_ISCSI_6(name, type1, arg1, type2, arg2, \ 212 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 213 DTRACE_PROBE6(__iscsi_##name, type1, arg1, type2, arg2, \ 214 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 215 216 #define DTRACE_ISCSI_7(name, type1, arg1, type2, arg2, \ 217 type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 218 DTRACE_PROBE7(__iscsi_##name, type1, arg1, type2, arg2, \ 219 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 220 type7, arg7); 221 222 #define DTRACE_ISCSI_8(name, type1, arg1, type2, arg2, \ 223 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 224 type7, arg7, type8, arg8) \ 225 DTRACE_PROBE8(__iscsi_##name, type1, arg1, type2, arg2, \ 226 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 227 type7, arg7, type8, arg8); 228 229 #define DTRACE_NFSV3_3(name, type1, arg1, type2, arg2, \ 230 type3, arg3) \ 231 DTRACE_PROBE3(__nfsv3_##name, type1, arg1, type2, arg2, \ 232 type3, arg3); 233 #define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \ 234 type3, arg3, type4, arg4) \ 235 DTRACE_PROBE4(__nfsv3_##name, type1, arg1, type2, arg2, \ 236 type3, arg3, type4, arg4); 237 238 #define DTRACE_NFSV4_1(name, type1, arg1) \ 239 DTRACE_PROBE1(__nfsv4_##name, type1, arg1); 240 241 #define DTRACE_NFSV4_2(name, type1, arg1, type2, arg2) \ 242 DTRACE_PROBE2(__nfsv4_##name, type1, arg1, type2, arg2); 243 244 #define DTRACE_NFSV4_3(name, type1, arg1, type2, arg2, type3, arg3) \ 245 DTRACE_PROBE3(__nfsv4_##name, type1, arg1, type2, arg2, type3, arg3); 246 247 #define DTRACE_SMB_1(name, type1, arg1) \ 248 DTRACE_PROBE1(__smb_##name, type1, arg1); 249 250 #define DTRACE_SMB_2(name, type1, arg1, type2, arg2) \ 251 DTRACE_PROBE2(__smb_##name, type1, arg1, type2, arg2); 252 253 #define DTRACE_SMB2_1(name, type1, arg1) \ 254 DTRACE_PROBE1(__smb2_##name, type1, arg1); 255 256 #define DTRACE_SMB2_2(name, type1, arg1, type2, arg2) \ 257 DTRACE_PROBE2(__smb2_##name, type1, arg1, type2, arg2); 258 259 #define DTRACE_IP(name) \ 260 DTRACE_PROBE(__ip_##name); 261 262 #define DTRACE_IP1(name, type1, arg1) \ 263 DTRACE_PROBE1(__ip_##name, type1, arg1); 264 265 #define DTRACE_IP2(name, type1, arg1, type2, arg2) \ 266 DTRACE_PROBE2(__ip_##name, type1, arg1, type2, arg2); 267 268 #define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \ 269 DTRACE_PROBE3(__ip_##name, type1, arg1, type2, arg2, type3, arg3); 270 271 #define DTRACE_IP4(name, type1, arg1, type2, arg2, \ 272 type3, arg3, type4, arg4) \ 273 DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \ 274 type3, arg3, type4, arg4); 275 276 #define DTRACE_IP5(name, type1, arg1, type2, arg2, \ 277 type3, arg3, type4, arg4, type5, arg5) \ 278 DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \ 279 type3, arg3, type4, arg4, type5, arg5); 280 281 #define DTRACE_IP6(name, type1, arg1, type2, arg2, \ 282 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 283 DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \ 284 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 285 286 #define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \ 287 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 288 DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \ 289 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 290 type7, arg7); 291 292 #define DTRACE_TCP(name) \ 293 DTRACE_PROBE(__tcp_##name); 294 295 #define DTRACE_TCP1(name, type1, arg1) \ 296 DTRACE_PROBE1(__tcp_##name, type1, arg1); 297 298 #define DTRACE_TCP2(name, type1, arg1, type2, arg2) \ 299 DTRACE_PROBE2(__tcp_##name, type1, arg1, type2, arg2); 300 301 #define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) \ 302 DTRACE_PROBE3(__tcp_##name, type1, arg1, type2, arg2, type3, arg3); 303 304 #define DTRACE_TCP4(name, type1, arg1, type2, arg2, \ 305 type3, arg3, type4, arg4) \ 306 DTRACE_PROBE4(__tcp_##name, type1, arg1, type2, arg2, \ 307 type3, arg3, type4, arg4); 308 309 #define DTRACE_TCP5(name, type1, arg1, type2, arg2, \ 310 type3, arg3, type4, arg4, type5, arg5) \ 311 DTRACE_PROBE5(__tcp_##name, type1, arg1, type2, arg2, \ 312 type3, arg3, type4, arg4, type5, arg5); 313 314 #define DTRACE_TCP6(name, type1, arg1, type2, arg2, \ 315 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 316 DTRACE_PROBE6(__tcp_##name, type1, arg1, type2, arg2, \ 317 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 318 319 #define DTRACE_UDP(name) \ 320 DTRACE_PROBE(__udp_##name); 321 322 #define DTRACE_UDP1(name, type1, arg1) \ 323 DTRACE_PROBE1(__udp_##name, type1, arg1); 324 325 #define DTRACE_UDP2(name, type1, arg1, type2, arg2) \ 326 DTRACE_PROBE2(__udp_##name, type1, arg1, type2, arg2); 327 328 #define DTRACE_UDP3(name, type1, arg1, type2, arg2, type3, arg3) \ 329 DTRACE_PROBE3(__udp_##name, type1, arg1, type2, arg2, type3, arg3); 330 331 #define DTRACE_UDP4(name, type1, arg1, type2, arg2, \ 332 type3, arg3, type4, arg4) \ 333 DTRACE_PROBE4(__udp_##name, type1, arg1, type2, arg2, \ 334 type3, arg3, type4, arg4); 335 336 #define DTRACE_UDP5(name, type1, arg1, type2, arg2, \ 337 type3, arg3, type4, arg4, type5, arg5) \ 338 DTRACE_PROBE5(__udp_##name, type1, arg1, type2, arg2, \ 339 type3, arg3, type4, arg4, type5, arg5); 340 341 342 #define DTRACE_SYSEVENT2(name, type1, arg1, type2, arg2) \ 343 DTRACE_PROBE2(__sysevent_##name, type1, arg1, type2, arg2); 344 345 #define DTRACE_XPV(name) \ 346 DTRACE_PROBE(__xpv_##name); 347 348 #define DTRACE_XPV1(name, type1, arg1) \ 349 DTRACE_PROBE1(__xpv_##name, type1, arg1); 350 351 #define DTRACE_XPV2(name, type1, arg1, type2, arg2) \ 352 DTRACE_PROBE2(__xpv_##name, type1, arg1, type2, arg2); 353 354 #define DTRACE_XPV3(name, type1, arg1, type2, arg2, type3, arg3) \ 355 DTRACE_PROBE3(__xpv_##name, type1, arg1, type2, arg2, type3, arg3); 356 357 #define DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3, \ 358 type4, arg4) \ 359 DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \ 360 type3, arg3, type4, arg4); 361 362 #define DTRACE_FC_1(name, type1, arg1) \ 363 DTRACE_PROBE1(__fc_##name, type1, arg1); 364 365 #define DTRACE_FC_2(name, type1, arg1, type2, arg2) \ 366 DTRACE_PROBE2(__fc_##name, type1, arg1, type2, arg2); 367 368 #define DTRACE_FC_3(name, type1, arg1, type2, arg2, type3, arg3) \ 369 DTRACE_PROBE3(__fc_##name, type1, arg1, type2, arg2, type3, arg3); 370 371 #define DTRACE_FC_4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ 372 DTRACE_PROBE4(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ 373 type4, arg4); 374 375 #define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \ 376 type4, arg4, type5, arg5) \ 377 DTRACE_PROBE5(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ 378 type4, arg4, type5, arg5); 379 380 #define DTRACE_SRP_1(name, type1, arg1) \ 381 DTRACE_PROBE1(__srp_##name, type1, arg1); 382 383 #define DTRACE_SRP_2(name, type1, arg1, type2, arg2) \ 384 DTRACE_PROBE2(__srp_##name, type1, arg1, type2, arg2); 385 386 #define DTRACE_SRP_3(name, type1, arg1, type2, arg2, type3, arg3) \ 387 DTRACE_PROBE3(__srp_##name, type1, arg1, type2, arg2, type3, arg3); 388 389 #define DTRACE_SRP_4(name, type1, arg1, type2, arg2, type3, arg3, \ 390 type4, arg4) \ 391 DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \ 392 type3, arg3, type4, arg4); 393 394 #define DTRACE_SRP_5(name, type1, arg1, type2, arg2, type3, arg3, \ 395 type4, arg4, type5, arg5) \ 396 DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \ 397 type3, arg3, type4, arg4, type5, arg5); 398 399 #define DTRACE_SRP_6(name, type1, arg1, type2, arg2, type3, arg3, \ 400 type4, arg4, type5, arg5, type6, arg6) \ 401 DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \ 402 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 403 404 #define DTRACE_SRP_7(name, type1, arg1, type2, arg2, type3, arg3, \ 405 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 406 DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \ 407 type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7); 408 409 #define DTRACE_SRP_8(name, type1, arg1, type2, arg2, type3, arg3, \ 410 type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \ 411 DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \ 412 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 413 type7, arg7, type8, arg8); 414 415 /* 416 * The set-error SDT probe is extra static, in that we declare its fake 417 * function literally, rather than with the DTRACE_PROBE1() macro. This is 418 * necessary so that SET_ERROR() can evaluate to a value, which wouldn't 419 * be possible if it required multiple statements (to declare the function 420 * and then call it). 421 * 422 * SET_ERROR() uses the comma operator so that it can be used without much 423 * additional code. For example, "return (EINVAL);" becomes 424 * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated 425 * twice, so it should not have side effects (e.g. something like: 426 * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). 427 */ 428 extern void __dtrace_probe_set__error(uintptr_t); 429 #define SET_ERROR(err) (__dtrace_probe_set__error(err), err) 430 431 #endif /* _KERNEL */ 432 433 extern const char *sdt_prefix; 434 435 typedef struct sdt_probedesc { 436 char *sdpd_name; /* name of this probe */ 437 unsigned long sdpd_offset; /* offset of call in text */ 438 struct sdt_probedesc *sdpd_next; /* next static probe */ 439 } sdt_probedesc_t; 440 441 #ifdef __cplusplus 442 } 443 #endif 444 445 #endif /* _SYS_SDT_H */