1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 1464 ahl * Common Development and Distribution License (the "License"). 6 1464 ahl * You may not use this file except in compliance with the License. 7 0 stevel * 8 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 0 stevel * or http://www.opensolaris.org/os/licensing. 10 0 stevel * See the License for the specific language governing permissions 11 0 stevel * and limitations under the License. 12 0 stevel * 13 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 14 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 0 stevel * If applicable, add the following below this CDDL HEADER, with the 16 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 17 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 18 0 stevel * 19 0 stevel * CDDL HEADER END 20 0 stevel */ 21 1464 ahl 22 0 stevel /* 23 5984 jhaslam * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 0 stevel * Use is subject to license terms. 25 0 stevel */ 26 0 stevel 27 0 stevel #pragma ident "%Z%%M% %I% %E% SMI" 28 0 stevel 29 0 stevel #include <sys/types.h> 30 0 stevel #include <sys/modctl.h> 31 0 stevel #include <sys/systeminfo.h> 32 1739 bmc #include <sys/resource.h> 33 0 stevel 34 0 stevel #include <libelf.h> 35 0 stevel #include <strings.h> 36 0 stevel #include <alloca.h> 37 0 stevel #include <limits.h> 38 0 stevel #include <unistd.h> 39 0 stevel #include <stdlib.h> 40 0 stevel #include <stdio.h> 41 0 stevel #include <fcntl.h> 42 0 stevel #include <errno.h> 43 0 stevel #include <assert.h> 44 0 stevel 45 0 stevel #define _POSIX_PTHREAD_SEMANTICS 46 0 stevel #include <dirent.h> 47 0 stevel #undef _POSIX_PTHREAD_SEMANTICS 48 0 stevel 49 0 stevel #include <dt_impl.h> 50 265 mws #include <dt_program.h> 51 0 stevel #include <dt_module.h> 52 0 stevel #include <dt_printf.h> 53 0 stevel #include <dt_string.h> 54 0 stevel #include <dt_provider.h> 55 0 stevel 56 0 stevel /* 57 0 stevel * Stability and versioning definitions. These #defines are used in the tables 58 0 stevel * of identifiers below to fill in the attribute and version fields associated 59 0 stevel * with each identifier. The DT_ATTR_* macros are a convenience to permit more 60 0 stevel * concise declarations of common attributes such as Stable/Stable/Common. The 61 0 stevel * DT_VERS_* macros declare the encoded integer values of all versions used so 62 0 stevel * far. DT_VERS_LATEST must correspond to the latest version value among all 63 0 stevel * versions exported by the D compiler. DT_VERS_STRING must be an ASCII string 64 0 stevel * that contains DT_VERS_LATEST within it along with any suffixes (e.g. Beta). 65 0 stevel * You must update DT_VERS_LATEST and DT_VERS_STRING when adding a new version, 66 0 stevel * and then add the new version to the _dtrace_versions[] array declared below. 67 0 stevel * Refer to the Solaris Dynamic Tracing Guide Stability and Versioning chapters 68 0 stevel * respectively for an explanation of these DTrace features and their values. 69 0 stevel * 70 0 stevel * NOTE: Although the DTrace versioning scheme supports the labeling and 71 0 stevel * introduction of incompatible changes (e.g. dropping an interface in a 72 0 stevel * major release), the libdtrace code does not currently support this. 73 0 stevel * All versions are assumed to strictly inherit from one another. If 74 0 stevel * we ever need to provide divergent interfaces, this will need work. 75 0 stevel */ 76 0 stevel #define DT_ATTR_STABCMN { DTRACE_STABILITY_STABLE, \ 77 0 stevel DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON } 78 0 stevel 79 0 stevel #define DT_ATTR_EVOLCMN { DTRACE_STABILITY_EVOLVING, \ 80 0 stevel DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON \ 81 0 stevel } 82 0 stevel 83 1464 ahl /* 84 1464 ahl * The version number should be increased for every customer visible release 85 1464 ahl * of Solaris. The major number should be incremented when a fundamental 86 1464 ahl * change has been made that would affect all consumers, and would reflect 87 1464 ahl * sweeping changes to DTrace or the D language. The minor number should be 88 1464 ahl * incremented when a change is introduced that could break scripts that had 89 1464 ahl * previously worked; for example, adding a new built-in variable could break 90 1464 ahl * a script which was already using that identifier. The micro number should 91 1464 ahl * be changed when introducing functionality changes or major bug fixes that 92 1464 ahl * do not affect backward compatibility -- this is merely to make capabilities 93 1464 ahl * easily determined from the version number. Minor bugs do not require any 94 1464 ahl * modification to the version number. 95 1464 ahl */ 96 0 stevel #define DT_VERS_1_0 DT_VERSION_NUMBER(1, 0, 0) 97 0 stevel #define DT_VERS_1_1 DT_VERSION_NUMBER(1, 1, 0) 98 191 ahl #define DT_VERS_1_2 DT_VERSION_NUMBER(1, 2, 0) 99 1464 ahl #define DT_VERS_1_2_1 DT_VERSION_NUMBER(1, 2, 1) 100 1710 ahl #define DT_VERS_1_2_2 DT_VERSION_NUMBER(1, 2, 2) 101 2769 ahl #define DT_VERS_1_3 DT_VERSION_NUMBER(1, 3, 0) 102 3235 raf #define DT_VERS_1_4 DT_VERSION_NUMBER(1, 4, 0) 103 3682 jhaslam #define DT_VERS_1_4_1 DT_VERSION_NUMBER(1, 4, 1) 104 4308 brendan #define DT_VERS_1_5 DT_VERSION_NUMBER(1, 5, 0) 105 5984 jhaslam #define DT_VERS_1_6 DT_VERSION_NUMBER(1, 6, 0) 106 6390 ahl #define DT_VERS_1_6_1 DT_VERSION_NUMBER(1, 6, 1) 107 6554 ahl #define DT_VERS_1_6_2 DT_VERSION_NUMBER(1, 6, 2) 108 6554 ahl #define DT_VERS_LATEST DT_VERS_1_6_2 109 6554 ahl #define DT_VERS_STRING "Sun D 1.6.2" 110 0 stevel 111 0 stevel const dt_version_t _dtrace_versions[] = { 112 0 stevel DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */ 113 191 ahl DT_VERS_1_1, /* D API 1.1.0 Solaris Express 6/05 */ 114 191 ahl DT_VERS_1_2, /* D API 1.2.0 Solaris 10 Update 1 */ 115 1464 ahl DT_VERS_1_2_1, /* D API 1.2.1 Solaris Express 4/06 */ 116 1710 ahl DT_VERS_1_2_2, /* D API 1.2.2 Solaris Express 6/06 */ 117 2769 ahl DT_VERS_1_3, /* D API 1.3 Solaris Express 10/06 */ 118 3235 raf DT_VERS_1_4, /* D API 1.4 Solaris Express 2/07 */ 119 3682 jhaslam DT_VERS_1_4_1, /* D API 1.4.1 Solaris Express 4/07 */ 120 4308 brendan DT_VERS_1_5, /* D API 1.5 Solaris Express 7/07 */ 121 5984 jhaslam DT_VERS_1_6, /* D API 1.6 */ 122 6390 ahl DT_VERS_1_6_1, /* D API 1.6.1 */ 123 6554 ahl DT_VERS_1_6_2, /* D API 1.6.2 */ 124 0 stevel 0 125 0 stevel }; 126 0 stevel 127 0 stevel /* 128 0 stevel * Table of global identifiers. This is used to populate the global identifier 129 0 stevel * hash when a new dtrace client open occurs. For more info see dt_ident.h. 130 0 stevel * The global identifiers that represent functions use the dt_idops_func ops 131 0 stevel * and specify the private data pointer as a prototype string which is parsed 132 0 stevel * when the identifier is first encountered. These prototypes look like ANSI 133 0 stevel * C function prototypes except that the special symbol "@" can be used as a 134 0 stevel * wildcard to represent a single parameter of any type (i.e. any dt_node_t). 135 0 stevel * The standard "..." notation can also be used to represent varargs. An empty 136 0 stevel * parameter list is taken to mean void (that is, no arguments are permitted). 137 0 stevel * A parameter enclosed in square brackets (e.g. "[int]") denotes an optional 138 0 stevel * argument. 139 0 stevel */ 140 0 stevel static const dt_ident_t _dtrace_globals[] = { 141 0 stevel { "alloca", DT_IDENT_FUNC, 0, DIF_SUBR_ALLOCA, DT_ATTR_STABCMN, DT_VERS_1_0, 142 0 stevel &dt_idops_func, "void *(size_t)" }, 143 0 stevel { "arg0", DT_IDENT_SCALAR, 0, DIF_VAR_ARG0, DT_ATTR_STABCMN, DT_VERS_1_0, 144 0 stevel &dt_idops_type, "int64_t" }, 145 0 stevel { "arg1", DT_IDENT_SCALAR, 0, DIF_VAR_ARG1, DT_ATTR_STABCMN, DT_VERS_1_0, 146 0 stevel &dt_idops_type, "int64_t" }, 147 0 stevel { "arg2", DT_IDENT_SCALAR, 0, DIF_VAR_ARG2, DT_ATTR_STABCMN, DT_VERS_1_0, 148 0 stevel &dt_idops_type, "int64_t" }, 149 0 stevel { "arg3", DT_IDENT_SCALAR, 0, DIF_VAR_ARG3, DT_ATTR_STABCMN, DT_VERS_1_0, 150 0 stevel &dt_idops_type, "int64_t" }, 151 0 stevel { "arg4", DT_IDENT_SCALAR, 0, DIF_VAR_ARG4, DT_ATTR_STABCMN, DT_VERS_1_0, 152 0 stevel &dt_idops_type, "int64_t" }, 153 0 stevel { "arg5", DT_IDENT_SCALAR, 0, DIF_VAR_ARG5, DT_ATTR_STABCMN, DT_VERS_1_0, 154 0 stevel &dt_idops_type, "int64_t" }, 155 0 stevel { "arg6", DT_IDENT_SCALAR, 0, DIF_VAR_ARG6, DT_ATTR_STABCMN, DT_VERS_1_0, 156 0 stevel &dt_idops_type, "int64_t" }, 157 0 stevel { "arg7", DT_IDENT_SCALAR, 0, DIF_VAR_ARG7, DT_ATTR_STABCMN, DT_VERS_1_0, 158 0 stevel &dt_idops_type, "int64_t" }, 159 0 stevel { "arg8", DT_IDENT_SCALAR, 0, DIF_VAR_ARG8, DT_ATTR_STABCMN, DT_VERS_1_0, 160 0 stevel &dt_idops_type, "int64_t" }, 161 0 stevel { "arg9", DT_IDENT_SCALAR, 0, DIF_VAR_ARG9, DT_ATTR_STABCMN, DT_VERS_1_0, 162 0 stevel &dt_idops_type, "int64_t" }, 163 0 stevel { "args", DT_IDENT_ARRAY, 0, DIF_VAR_ARGS, DT_ATTR_STABCMN, DT_VERS_1_0, 164 0 stevel &dt_idops_args, NULL }, 165 0 stevel { "avg", DT_IDENT_AGGFUNC, 0, DTRACEAGG_AVG, DT_ATTR_STABCMN, DT_VERS_1_0, 166 0 stevel &dt_idops_func, "void(@)" }, 167 0 stevel { "basename", DT_IDENT_FUNC, 0, DIF_SUBR_BASENAME, DT_ATTR_STABCMN, DT_VERS_1_0, 168 0 stevel &dt_idops_func, "string(const char *)" }, 169 0 stevel { "bcopy", DT_IDENT_FUNC, 0, DIF_SUBR_BCOPY, DT_ATTR_STABCMN, DT_VERS_1_0, 170 0 stevel &dt_idops_func, "void(void *, void *, size_t)" }, 171 0 stevel { "breakpoint", DT_IDENT_ACTFUNC, 0, DT_ACT_BREAKPOINT, 172 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 173 0 stevel &dt_idops_func, "void()" }, 174 0 stevel { "caller", DT_IDENT_SCALAR, 0, DIF_VAR_CALLER, DT_ATTR_STABCMN, DT_VERS_1_0, 175 0 stevel &dt_idops_type, "uintptr_t" }, 176 0 stevel { "chill", DT_IDENT_ACTFUNC, 0, DT_ACT_CHILL, DT_ATTR_STABCMN, DT_VERS_1_0, 177 0 stevel &dt_idops_func, "void(int)" }, 178 0 stevel { "cleanpath", DT_IDENT_FUNC, 0, DIF_SUBR_CLEANPATH, DT_ATTR_STABCMN, 179 0 stevel DT_VERS_1_0, &dt_idops_func, "string(const char *)" }, 180 0 stevel { "clear", DT_IDENT_ACTFUNC, 0, DT_ACT_CLEAR, DT_ATTR_STABCMN, DT_VERS_1_0, 181 0 stevel &dt_idops_func, "void(...)" }, 182 0 stevel { "commit", DT_IDENT_ACTFUNC, 0, DT_ACT_COMMIT, DT_ATTR_STABCMN, DT_VERS_1_0, 183 0 stevel &dt_idops_func, "void(int)" }, 184 0 stevel { "copyin", DT_IDENT_FUNC, 0, DIF_SUBR_COPYIN, DT_ATTR_STABCMN, DT_VERS_1_0, 185 0 stevel &dt_idops_func, "void *(uintptr_t, size_t)" }, 186 0 stevel { "copyinstr", DT_IDENT_FUNC, 0, DIF_SUBR_COPYINSTR, 187 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 188 0 stevel &dt_idops_func, "string(uintptr_t, [size_t])" }, 189 0 stevel { "copyinto", DT_IDENT_FUNC, 0, DIF_SUBR_COPYINTO, DT_ATTR_STABCMN, 190 0 stevel DT_VERS_1_0, &dt_idops_func, "void(uintptr_t, size_t, void *)" }, 191 0 stevel { "copyout", DT_IDENT_FUNC, 0, DIF_SUBR_COPYOUT, DT_ATTR_STABCMN, DT_VERS_1_0, 192 0 stevel &dt_idops_func, "void(void *, uintptr_t, size_t)" }, 193 0 stevel { "copyoutstr", DT_IDENT_FUNC, 0, DIF_SUBR_COPYOUTSTR, 194 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 195 0 stevel &dt_idops_func, "void(char *, uintptr_t, size_t)" }, 196 0 stevel { "count", DT_IDENT_AGGFUNC, 0, DTRACEAGG_COUNT, DT_ATTR_STABCMN, DT_VERS_1_0, 197 0 stevel &dt_idops_func, "void()" }, 198 0 stevel { "curthread", DT_IDENT_SCALAR, 0, DIF_VAR_CURTHREAD, 199 0 stevel { DTRACE_STABILITY_STABLE, DTRACE_STABILITY_PRIVATE, 200 0 stevel DTRACE_CLASS_COMMON }, DT_VERS_1_0, 201 0 stevel &dt_idops_type, "genunix`kthread_t *" }, 202 0 stevel { "ddi_pathname", DT_IDENT_FUNC, 0, DIF_SUBR_DDI_PATHNAME, 203 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 204 0 stevel &dt_idops_func, "string(void *, int64_t)" }, 205 0 stevel { "denormalize", DT_IDENT_ACTFUNC, 0, DT_ACT_DENORMALIZE, DT_ATTR_STABCMN, 206 0 stevel DT_VERS_1_0, &dt_idops_func, "void(...)" }, 207 0 stevel { "dirname", DT_IDENT_FUNC, 0, DIF_SUBR_DIRNAME, DT_ATTR_STABCMN, DT_VERS_1_0, 208 0 stevel &dt_idops_func, "string(const char *)" }, 209 0 stevel { "discard", DT_IDENT_ACTFUNC, 0, DT_ACT_DISCARD, DT_ATTR_STABCMN, DT_VERS_1_0, 210 0 stevel &dt_idops_func, "void(int)" }, 211 0 stevel { "epid", DT_IDENT_SCALAR, 0, DIF_VAR_EPID, DT_ATTR_STABCMN, DT_VERS_1_0, 212 0 stevel &dt_idops_type, "uint_t" }, 213 2525 dp { "errno", DT_IDENT_SCALAR, 0, DIF_VAR_ERRNO, DT_ATTR_STABCMN, DT_VERS_1_0, 214 2525 dp &dt_idops_type, "int" }, 215 0 stevel { "execname", DT_IDENT_SCALAR, 0, DIF_VAR_EXECNAME, 216 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, 217 0 stevel { "exit", DT_IDENT_ACTFUNC, 0, DT_ACT_EXIT, DT_ATTR_STABCMN, DT_VERS_1_0, 218 0 stevel &dt_idops_func, "void(int)" }, 219 0 stevel { "freopen", DT_IDENT_ACTFUNC, 0, DT_ACT_FREOPEN, DT_ATTR_STABCMN, 220 0 stevel DT_VERS_1_1, &dt_idops_func, "void(@, ...)" }, 221 0 stevel { "ftruncate", DT_IDENT_ACTFUNC, 0, DT_ACT_FTRUNCATE, DT_ATTR_STABCMN, 222 0 stevel DT_VERS_1_0, &dt_idops_func, "void()" }, 223 457 bmc { "func", DT_IDENT_ACTFUNC, 0, DT_ACT_SYM, DT_ATTR_STABCMN, 224 457 bmc DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" }, 225 0 stevel { "getmajor", DT_IDENT_FUNC, 0, DIF_SUBR_GETMAJOR, 226 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 227 0 stevel &dt_idops_func, "genunix`major_t(genunix`dev_t)" }, 228 0 stevel { "getminor", DT_IDENT_FUNC, 0, DIF_SUBR_GETMINOR, 229 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 230 0 stevel &dt_idops_func, "genunix`minor_t(genunix`dev_t)" }, 231 2769 ahl { "htonl", DT_IDENT_FUNC, 0, DIF_SUBR_HTONL, DT_ATTR_EVOLCMN, DT_VERS_1_3, 232 2769 ahl &dt_idops_func, "uint32_t(uint32_t)" }, 233 2769 ahl { "htonll", DT_IDENT_FUNC, 0, DIF_SUBR_HTONLL, DT_ATTR_EVOLCMN, DT_VERS_1_3, 234 2769 ahl &dt_idops_func, "uint64_t(uint64_t)" }, 235 2769 ahl { "htons", DT_IDENT_FUNC, 0, DIF_SUBR_HTONS, DT_ATTR_EVOLCMN, DT_VERS_1_3, 236 2769 ahl &dt_idops_func, "uint16_t(uint16_t)" }, 237 2525 dp { "gid", DT_IDENT_SCALAR, 0, DIF_VAR_GID, DT_ATTR_STABCMN, DT_VERS_1_0, 238 2525 dp &dt_idops_type, "gid_t" }, 239 0 stevel { "id", DT_IDENT_SCALAR, 0, DIF_VAR_ID, DT_ATTR_STABCMN, DT_VERS_1_0, 240 0 stevel &dt_idops_type, "uint_t" }, 241 0 stevel { "index", DT_IDENT_FUNC, 0, DIF_SUBR_INDEX, DT_ATTR_STABCMN, DT_VERS_1_1, 242 0 stevel &dt_idops_func, "int(const char *, const char *, [int])" }, 243 4291 brendan { "inet_ntoa", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA, DT_ATTR_STABCMN, 244 4308 brendan DT_VERS_1_5, &dt_idops_func, "string(ipaddr_t *)" }, 245 4291 brendan { "inet_ntoa6", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA6, DT_ATTR_STABCMN, 246 4308 brendan DT_VERS_1_5, &dt_idops_func, "string(in6_addr_t *)" }, 247 4291 brendan { "inet_ntop", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOP, DT_ATTR_STABCMN, 248 4308 brendan DT_VERS_1_5, &dt_idops_func, "string(int, void *)" }, 249 0 stevel { "ipl", DT_IDENT_SCALAR, 0, DIF_VAR_IPL, DT_ATTR_STABCMN, DT_VERS_1_0, 250 0 stevel &dt_idops_type, "uint_t" }, 251 0 stevel { "jstack", DT_IDENT_ACTFUNC, 0, DT_ACT_JSTACK, DT_ATTR_STABCMN, DT_VERS_1_0, 252 0 stevel &dt_idops_func, "stack(...)" }, 253 0 stevel { "lltostr", DT_IDENT_FUNC, 0, DIF_SUBR_LLTOSTR, DT_ATTR_STABCMN, DT_VERS_1_0, 254 0 stevel &dt_idops_func, "string(int64_t)" }, 255 0 stevel { "lquantize", DT_IDENT_AGGFUNC, 0, DTRACEAGG_LQUANTIZE, 256 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 257 0 stevel &dt_idops_func, "void(@, int32_t, int32_t, ...)" }, 258 0 stevel { "max", DT_IDENT_AGGFUNC, 0, DTRACEAGG_MAX, DT_ATTR_STABCMN, DT_VERS_1_0, 259 0 stevel &dt_idops_func, "void(@)" }, 260 0 stevel { "min", DT_IDENT_AGGFUNC, 0, DTRACEAGG_MIN, DT_ATTR_STABCMN, DT_VERS_1_0, 261 0 stevel &dt_idops_func, "void(@)" }, 262 457 bmc { "mod", DT_IDENT_ACTFUNC, 0, DT_ACT_MOD, DT_ATTR_STABCMN, 263 457 bmc DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" }, 264 0 stevel { "msgdsize", DT_IDENT_FUNC, 0, DIF_SUBR_MSGDSIZE, 265 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 266 0 stevel &dt_idops_func, "size_t(mblk_t *)" }, 267 0 stevel { "msgsize", DT_IDENT_FUNC, 0, DIF_SUBR_MSGSIZE, 268 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 269 0 stevel &dt_idops_func, "size_t(mblk_t *)" }, 270 0 stevel { "mutex_owned", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNED, 271 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 272 0 stevel &dt_idops_func, "int(genunix`kmutex_t *)" }, 273 0 stevel { "mutex_owner", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNER, 274 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 275 0 stevel &dt_idops_func, "genunix`kthread_t *(genunix`kmutex_t *)" }, 276 0 stevel { "mutex_type_adaptive", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_ADAPTIVE, 277 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 278 0 stevel &dt_idops_func, "int(genunix`kmutex_t *)" }, 279 0 stevel { "mutex_type_spin", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_SPIN, 280 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 281 0 stevel &dt_idops_func, "int(genunix`kmutex_t *)" }, 282 2769 ahl { "ntohl", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHL, DT_ATTR_EVOLCMN, DT_VERS_1_3, 283 2769 ahl &dt_idops_func, "uint32_t(uint32_t)" }, 284 2769 ahl { "ntohll", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHLL, DT_ATTR_EVOLCMN, DT_VERS_1_3, 285 2769 ahl &dt_idops_func, "uint64_t(uint64_t)" }, 286 2769 ahl { "ntohs", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHS, DT_ATTR_EVOLCMN, DT_VERS_1_3, 287 2769 ahl &dt_idops_func, "uint16_t(uint16_t)" }, 288 0 stevel { "normalize", DT_IDENT_ACTFUNC, 0, DT_ACT_NORMALIZE, DT_ATTR_STABCMN, 289 0 stevel DT_VERS_1_0, &dt_idops_func, "void(...)" }, 290 0 stevel { "panic", DT_IDENT_ACTFUNC, 0, DT_ACT_PANIC, DT_ATTR_STABCMN, DT_VERS_1_0, 291 0 stevel &dt_idops_func, "void()" }, 292 0 stevel { "pid", DT_IDENT_SCALAR, 0, DIF_VAR_PID, DT_ATTR_STABCMN, DT_VERS_1_0, 293 2525 dp &dt_idops_type, "pid_t" }, 294 2525 dp { "ppid", DT_IDENT_SCALAR, 0, DIF_VAR_PPID, DT_ATTR_STABCMN, DT_VERS_1_0, 295 0 stevel &dt_idops_type, "pid_t" }, 296 0 stevel { "printa", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTA, DT_ATTR_STABCMN, DT_VERS_1_0, 297 0 stevel &dt_idops_func, "void(@, ...)" }, 298 0 stevel { "printf", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTF, DT_ATTR_STABCMN, DT_VERS_1_0, 299 0 stevel &dt_idops_func, "void(@, ...)" }, 300 0 stevel { "probefunc", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEFUNC, 301 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, 302 0 stevel { "probemod", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEMOD, 303 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, 304 0 stevel { "probename", DT_IDENT_SCALAR, 0, DIF_VAR_PROBENAME, 305 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, 306 0 stevel { "probeprov", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEPROV, 307 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, 308 0 stevel { "progenyof", DT_IDENT_FUNC, 0, DIF_SUBR_PROGENYOF, 309 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 310 0 stevel &dt_idops_func, "int(pid_t)" }, 311 0 stevel { "quantize", DT_IDENT_AGGFUNC, 0, DTRACEAGG_QUANTIZE, 312 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 313 457 bmc &dt_idops_func, "void(@, ...)" }, 314 0 stevel { "raise", DT_IDENT_ACTFUNC, 0, DT_ACT_RAISE, DT_ATTR_STABCMN, DT_VERS_1_0, 315 0 stevel &dt_idops_func, "void(int)" }, 316 0 stevel { "rand", DT_IDENT_FUNC, 0, DIF_SUBR_RAND, DT_ATTR_STABCMN, DT_VERS_1_0, 317 0 stevel &dt_idops_func, "int()" }, 318 0 stevel { "rindex", DT_IDENT_FUNC, 0, DIF_SUBR_RINDEX, DT_ATTR_STABCMN, DT_VERS_1_1, 319 0 stevel &dt_idops_func, "int(const char *, const char *, [int])" }, 320 0 stevel { "rw_iswriter", DT_IDENT_FUNC, 0, DIF_SUBR_RW_ISWRITER, 321 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 322 0 stevel &dt_idops_func, "int(genunix`krwlock_t *)" }, 323 0 stevel { "rw_read_held", DT_IDENT_FUNC, 0, DIF_SUBR_RW_READ_HELD, 324 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 325 0 stevel &dt_idops_func, "int(genunix`krwlock_t *)" }, 326 0 stevel { "rw_write_held", DT_IDENT_FUNC, 0, DIF_SUBR_RW_WRITE_HELD, 327 0 stevel DT_ATTR_EVOLCMN, DT_VERS_1_0, 328 0 stevel &dt_idops_func, "int(genunix`krwlock_t *)" }, 329 0 stevel { "self", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0, 330 0 stevel &dt_idops_type, "void" }, 331 457 bmc { "setopt", DT_IDENT_ACTFUNC, 0, DT_ACT_SETOPT, DT_ATTR_STABCMN, 332 457 bmc DT_VERS_1_2, &dt_idops_func, "void(const char *, [const char *])" }, 333 0 stevel { "speculate", DT_IDENT_ACTFUNC, 0, DT_ACT_SPECULATE, 334 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 335 0 stevel &dt_idops_func, "void(int)" }, 336 0 stevel { "speculation", DT_IDENT_FUNC, 0, DIF_SUBR_SPECULATION, 337 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 338 0 stevel &dt_idops_func, "int()" }, 339 0 stevel { "stack", DT_IDENT_ACTFUNC, 0, DT_ACT_STACK, DT_ATTR_STABCMN, DT_VERS_1_0, 340 0 stevel &dt_idops_func, "stack(...)" }, 341 0 stevel { "stackdepth", DT_IDENT_SCALAR, 0, DIF_VAR_STACKDEPTH, 342 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 343 0 stevel &dt_idops_type, "uint32_t" }, 344 5984 jhaslam { "stddev", DT_IDENT_AGGFUNC, 0, DTRACEAGG_STDDEV, DT_ATTR_STABCMN, 345 5984 jhaslam DT_VERS_1_6, &dt_idops_func, "void(@)" }, 346 0 stevel { "stop", DT_IDENT_ACTFUNC, 0, DT_ACT_STOP, DT_ATTR_STABCMN, DT_VERS_1_0, 347 0 stevel &dt_idops_func, "void()" }, 348 0 stevel { "strchr", DT_IDENT_FUNC, 0, DIF_SUBR_STRCHR, DT_ATTR_STABCMN, DT_VERS_1_1, 349 0 stevel &dt_idops_func, "string(const char *, char)" }, 350 0 stevel { "strlen", DT_IDENT_FUNC, 0, DIF_SUBR_STRLEN, DT_ATTR_STABCMN, DT_VERS_1_0, 351 0 stevel &dt_idops_func, "size_t(const char *)" }, 352 0 stevel { "strjoin", DT_IDENT_FUNC, 0, DIF_SUBR_STRJOIN, DT_ATTR_STABCMN, DT_VERS_1_0, 353 0 stevel &dt_idops_func, "string(const char *, const char *)" }, 354 0 stevel { "strrchr", DT_IDENT_FUNC, 0, DIF_SUBR_STRRCHR, DT_ATTR_STABCMN, DT_VERS_1_1, 355 0 stevel &dt_idops_func, "string(const char *, char)" }, 356 0 stevel { "strstr", DT_IDENT_FUNC, 0, DIF_SUBR_STRSTR, DT_ATTR_STABCMN, DT_VERS_1_1, 357 0 stevel &dt_idops_func, "string(const char *, const char *)" }, 358 0 stevel { "strtok", DT_IDENT_FUNC, 0, DIF_SUBR_STRTOK, DT_ATTR_STABCMN, DT_VERS_1_1, 359 0 stevel &dt_idops_func, "string(const char *, const char *)" }, 360 0 stevel { "substr", DT_IDENT_FUNC, 0, DIF_SUBR_SUBSTR, DT_ATTR_STABCMN, DT_VERS_1_1, 361 0 stevel &dt_idops_func, "string(const char *, int, [int])" }, 362 0 stevel { "sum", DT_IDENT_AGGFUNC, 0, DTRACEAGG_SUM, DT_ATTR_STABCMN, DT_VERS_1_0, 363 0 stevel &dt_idops_func, "void(@)" }, 364 457 bmc { "sym", DT_IDENT_ACTFUNC, 0, DT_ACT_SYM, DT_ATTR_STABCMN, 365 457 bmc DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" }, 366 0 stevel { "system", DT_IDENT_ACTFUNC, 0, DT_ACT_SYSTEM, DT_ATTR_STABCMN, DT_VERS_1_0, 367 0 stevel &dt_idops_func, "void(@, ...)" }, 368 0 stevel { "this", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0, 369 0 stevel &dt_idops_type, "void" }, 370 0 stevel { "tid", DT_IDENT_SCALAR, 0, DIF_VAR_TID, DT_ATTR_STABCMN, DT_VERS_1_0, 371 0 stevel &dt_idops_type, "id_t" }, 372 0 stevel { "timestamp", DT_IDENT_SCALAR, 0, DIF_VAR_TIMESTAMP, 373 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 374 0 stevel &dt_idops_type, "uint64_t" }, 375 0 stevel { "trace", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACE, DT_ATTR_STABCMN, DT_VERS_1_0, 376 0 stevel &dt_idops_func, "void(@)" }, 377 0 stevel { "tracemem", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACEMEM, 378 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 379 0 stevel &dt_idops_func, "void(@, size_t)" }, 380 0 stevel { "trunc", DT_IDENT_ACTFUNC, 0, DT_ACT_TRUNC, DT_ATTR_STABCMN, 381 0 stevel DT_VERS_1_0, &dt_idops_func, "void(...)" }, 382 457 bmc { "uaddr", DT_IDENT_ACTFUNC, 0, DT_ACT_UADDR, DT_ATTR_STABCMN, 383 457 bmc DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, 384 457 bmc { "ucaller", DT_IDENT_SCALAR, 0, DIF_VAR_UCALLER, DT_ATTR_STABCMN, 385 457 bmc DT_VERS_1_2, &dt_idops_type, "uint64_t" }, 386 457 bmc { "ufunc", DT_IDENT_ACTFUNC, 0, DT_ACT_USYM, DT_ATTR_STABCMN, 387 457 bmc DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, 388 2525 dp { "uid", DT_IDENT_SCALAR, 0, DIF_VAR_UID, DT_ATTR_STABCMN, DT_VERS_1_0, 389 2525 dp &dt_idops_type, "uid_t" }, 390 457 bmc { "umod", DT_IDENT_ACTFUNC, 0, DT_ACT_UMOD, DT_ATTR_STABCMN, 391 457 bmc DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, 392 0 stevel { "uregs", DT_IDENT_ARRAY, 0, DIF_VAR_UREGS, DT_ATTR_STABCMN, DT_VERS_1_0, 393 0 stevel &dt_idops_regs, NULL }, 394 0 stevel { "ustack", DT_IDENT_ACTFUNC, 0, DT_ACT_USTACK, DT_ATTR_STABCMN, DT_VERS_1_0, 395 0 stevel &dt_idops_func, "stack(...)" }, 396 191 ahl { "ustackdepth", DT_IDENT_SCALAR, 0, DIF_VAR_USTACKDEPTH, 397 191 ahl DT_ATTR_STABCMN, DT_VERS_1_2, 398 191 ahl &dt_idops_type, "uint32_t" }, 399 457 bmc { "usym", DT_IDENT_ACTFUNC, 0, DT_ACT_USYM, DT_ATTR_STABCMN, 400 457 bmc DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, 401 0 stevel { "vtimestamp", DT_IDENT_SCALAR, 0, DIF_VAR_VTIMESTAMP, 402 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 403 0 stevel &dt_idops_type, "uint64_t" }, 404 0 stevel { "walltimestamp", DT_IDENT_SCALAR, 0, DIF_VAR_WALLTIMESTAMP, 405 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, 406 1017 bmc &dt_idops_type, "int64_t" }, 407 0 stevel { "zonename", DT_IDENT_SCALAR, 0, DIF_VAR_ZONENAME, 408 0 stevel DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, 409 0 stevel { NULL, 0, 0, 0, { 0, 0, 0 }, 0, NULL, NULL } 410 0 stevel }; 411 0 stevel 412 0 stevel /* 413 0 stevel * Tables of ILP32 intrinsic integer and floating-point type templates to use 414 0 stevel * to populate the dynamic "C" CTF type container. 415 0 stevel */ 416 0 stevel static const dt_intrinsic_t _dtrace_intrinsics_32[] = { 417 0 stevel { "void", { CTF_INT_SIGNED, 0, 0 }, CTF_K_INTEGER }, 418 0 stevel { "signed", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 419 0 stevel { "unsigned", { 0, 0, 32 }, CTF_K_INTEGER }, 420 0 stevel { "char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER }, 421 0 stevel { "short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER }, 422 0 stevel { "int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 423 0 stevel { "long", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 424 0 stevel { "long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER }, 425 0 stevel { "signed char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER }, 426 0 stevel { "signed short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER }, 427 0 stevel { "signed int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 428 0 stevel { "signed long", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 429 0 stevel { "signed long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER }, 430 0 stevel { "unsigned char", { CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER }, 431 0 stevel { "unsigned short", { 0, 0, 16 }, CTF_K_INTEGER }, 432 0 stevel { "unsigned int", { 0, 0, 32 }, CTF_K_INTEGER }, 433 0 stevel { "unsigned long", { 0, 0, 32 }, CTF_K_INTEGER }, 434 0 stevel { "unsigned long long", { 0, 0, 64 }, CTF_K_INTEGER }, 435 0 stevel { "_Bool", { CTF_INT_BOOL, 0, 8 }, CTF_K_INTEGER }, 436 0 stevel { "float", { CTF_FP_SINGLE, 0, 32 }, CTF_K_FLOAT }, 437 0 stevel { "double", { CTF_FP_DOUBLE, 0, 64 }, CTF_K_FLOAT }, 438 0 stevel { "long double", { CTF_FP_LDOUBLE, 0, 128 }, CTF_K_FLOAT }, 439 0 stevel { "float imaginary", { CTF_FP_IMAGRY, 0, 32 }, CTF_K_FLOAT }, 440 0 stevel { "double imaginary", { CTF_FP_DIMAGRY, 0, 64 }, CTF_K_FLOAT }, 441 0 stevel { "long double imaginary", { CTF_FP_LDIMAGRY, 0, 128 }, CTF_K_FLOAT }, 442 0 stevel { "float complex", { CTF_FP_CPLX, 0, 64 }, CTF_K_FLOAT }, 443 0 stevel { "double complex", { CTF_FP_DCPLX, 0, 128 }, CTF_K_FLOAT }, 444 0 stevel { "long double complex", { CTF_FP_LDCPLX, 0, 256 }, CTF_K_FLOAT }, 445 0 stevel { NULL, { 0, 0, 0 }, 0 } 446 0 stevel }; 447 0 stevel 448 0 stevel /* 449 0 stevel * Tables of LP64 intrinsic integer and floating-point type templates to use 450 0 stevel * to populate the dynamic "C" CTF type container. 451 0 stevel */ 452 0 stevel static const dt_intrinsic_t _dtrace_intrinsics_64[] = { 453 0 stevel { "void", { CTF_INT_SIGNED, 0, 0 }, CTF_K_INTEGER }, 454 0 stevel { "signed", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 455 0 stevel { "unsigned", { 0, 0, 32 }, CTF_K_INTEGER }, 456 0 stevel { "char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER }, 457 0 stevel { "short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER }, 458 0 stevel { "int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 459 0 stevel { "long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER }, 460 0 stevel { "long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER }, 461 0 stevel { "signed char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER }, 462 0 stevel { "signed short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER }, 463 0 stevel { "signed int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER }, 464 0 stevel { "signed long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER }, 465 0 stevel { "signed long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER }, 466 0 stevel { "unsigned char", { CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER }, 467 0 stevel { "unsigned short", { 0, 0, 16 }, CTF_K_INTEGER }, 468 0 stevel { "unsigned int", { 0, 0, 32 }, CTF_K_INTEGER }, 469 0 stevel { "unsigned long", { 0, 0, 64 }, CTF_K_INTEGER }, 470 0 stevel { "unsigned long long", { 0, 0, 64 }, CTF_K_INTEGER }, 471 0 stevel { "_Bool", { CTF_INT_BOOL, 0, 8 }, CTF_K_INTEGER }, 472 0 stevel { "float", { CTF_FP_SINGLE, 0, 32 }, CTF_K_FLOAT }, 473 0 stevel { "double", { CTF_FP_DOUBLE, 0, 64 }, CTF_K_FLOAT }, 474 0 stevel { "long double", { CTF_FP_LDOUBLE, 0, 128 }, CTF_K_FLOAT }, 475 0 stevel { "float imaginary", { CTF_FP_IMAGRY, 0, 32 }, CTF_K_FLOAT }, 476 0 stevel { "double imaginary", { CTF_FP_DIMAGRY, 0, 64 }, CTF_K_FLOAT }, 477 0 stevel { "long double imaginary", { CTF_FP_LDIMAGRY, 0, 128 }, CTF_K_FLOAT }, 478 0 stevel { "float complex", { CTF_FP_CPLX, 0, 64 }, CTF_K_FLOAT }, 479 0 stevel { "double complex", { CTF_FP_DCPLX, 0, 128 }, CTF_K_FLOAT }, 480 0 stevel { "long double complex", { CTF_FP_LDCPLX, 0, 256 }, CTF_K_FLOAT }, 481 0 stevel { NULL, { 0, 0, 0 }, 0 } 482 0 stevel }; 483 0 stevel 484 0 stevel /* 485 0 stevel * Tables of ILP32 typedefs to use to populate the dynamic "D" CTF container. 486 0 stevel * These aliases ensure that D definitions can use typical <sys/types.h> names. 487 0 stevel */ 488 0 stevel static const dt_typedef_t _dtrace_typedefs_32[] = { 489 0 stevel { "char", "int8_t" }, 490 0 stevel { "short", "int16_t" }, 491 0 stevel { "int", "int32_t" }, 492 0 stevel { "long long", "int64_t" }, 493 0 stevel { "int", "intptr_t" }, 494 0 stevel { "int", "ssize_t" }, 495 0 stevel { "unsigned char", "uint8_t" }, 496 0 stevel { "unsigned short", "uint16_t" }, 497 0 stevel { "unsigned", "uint32_t" }, 498 0 stevel { "unsigned long long", "uint64_t" }, 499 0 stevel { "unsigned char", "uchar_t" }, 500 0 stevel { "unsigned short", "ushort_t" }, 501 0 stevel { "unsigned", "uint_t" }, 502 0 stevel { "unsigned long", "ulong_t" }, 503 0 stevel { "unsigned long long", "u_longlong_t" }, 504 0 stevel { "int", "ptrdiff_t" }, 505 0 stevel { "unsigned", "uintptr_t" }, 506 0 stevel { "unsigned", "size_t" }, 507 0 stevel { "long", "id_t" }, 508 0 stevel { "long", "pid_t" }, 509 0 stevel { NULL, NULL } 510 0 stevel }; 511 0 stevel 512 0 stevel /* 513 0 stevel * Tables of LP64 typedefs to use to populate the dynamic "D" CTF container. 514 0 stevel * These aliases ensure that D definitions can use typical <sys/types.h> names. 515 0 stevel */ 516 0 stevel static const dt_typedef_t _dtrace_typedefs_64[] = { 517 0 stevel { "char", "int8_t" }, 518 0 stevel { "short", "int16_t" }, 519 0 stevel { "int", "int32_t" }, 520 0 stevel { "long", "int64_t" }, 521 0 stevel { "long", "intptr_t" }, 522 0 stevel { "long", "ssize_t" }, 523 0 stevel { "unsigned char", "uint8_t" }, 524 0 stevel { "unsigned short", "uint16_t" }, 525 0 stevel { "unsigned", "uint32_t" }, 526 0 stevel { "unsigned long", "uint64_t" }, 527 0 stevel { "unsigned char", "uchar_t" }, 528 0 stevel { "unsigned short", "ushort_t" }, 529 0 stevel { "unsigned", "uint_t" }, 530 0 stevel { "unsigned long", "ulong_t" }, 531 0 stevel { "unsigned long long", "u_longlong_t" }, 532 0 stevel { "long", "ptrdiff_t" }, 533 0 stevel { "unsigned long", "uintptr_t" }, 534 0 stevel { "unsigned long", "size_t" }, 535 0 stevel { "int", "id_t" }, 536 0 stevel { "int", "pid_t" }, 537 0 stevel { NULL, NULL } 538 0 stevel }; 539 0 stevel 540 0 stevel /* 541 0 stevel * Tables of ILP32 integer type templates used to populate the dtp->dt_ints[] 542 0 stevel * cache when a new dtrace client open occurs. Values are set by dtrace_open(). 543 0 stevel */ 544 0 stevel static const dt_intdesc_t _dtrace_ints_32[] = { 545 0 stevel { "int", NULL, CTF_ERR, 0x7fffffffULL }, 546 0 stevel { "unsigned int", NULL, CTF_ERR, 0xffffffffULL }, 547 0 stevel { "long", NULL, CTF_ERR, 0x7fffffffULL }, 548 0 stevel { "unsigned long", NULL, CTF_ERR, 0xffffffffULL }, 549 0 stevel { "long long", NULL, CTF_ERR, 0x7fffffffffffffffULL }, 550 0 stevel { "unsigned long long", NULL, CTF_ERR, 0xffffffffffffffffULL } 551 0 stevel }; 552 0 stevel 553 0 stevel /* 554 0 stevel * Tables of LP64 integer type templates used to populate the dtp->dt_ints[] 555 0 stevel * cache when a new dtrace client open occurs. Values are set by dtrace_open(). 556 0 stevel */ 557 0 stevel static const dt_intdesc_t _dtrace_ints_64[] = { 558 0 stevel { "int", NULL, CTF_ERR, 0x7fffffffULL }, 559 0 stevel { "unsigned int", NULL, CTF_ERR, 0xffffffffULL }, 560 0 stevel { "long", NULL, CTF_ERR, 0x7fffffffffffffffULL }, 561 0 stevel { "unsigned long", NULL, CTF_ERR, 0xffffffffffffffffULL }, 562 0 stevel { "long long", NULL, CTF_ERR, 0x7fffffffffffffffULL }, 563 0 stevel { "unsigned long long", NULL, CTF_ERR, 0xffffffffffffffffULL } 564 0 stevel }; 565 0 stevel 566 0 stevel /* 567 0 stevel * Table of macro variable templates used to populate the macro identifier hash 568 0 stevel * when a new dtrace client open occurs. Values are set by dtrace_update(). 569 0 stevel */ 570 0 stevel static const dt_ident_t _dtrace_macros[] = { 571 0 stevel { "egid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 572 0 stevel { "euid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 573 0 stevel { "gid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 574 0 stevel { "pid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 575 0 stevel { "pgid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 576 0 stevel { "ppid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 577 0 stevel { "projid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 578 0 stevel { "sid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 579 0 stevel { "taskid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 580 0 stevel { "target", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 581 0 stevel { "uid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 }, 582 0 stevel { NULL, 0, 0, 0, { 0, 0, 0 }, 0 } 583 0 stevel }; 584 0 stevel 585 0 stevel /* 586 0 stevel * Hard-wired definition string to be compiled and cached every time a new 587 0 stevel * DTrace library handle is initialized. This string should only be used to 588 0 stevel * contain definitions that should be present regardless of DTRACE_O_NOLIBS. 589 0 stevel */ 590 0 stevel static const char _dtrace_hardwire[] = "\ 591 0 stevel inline long NULL = 0; \n\ 592 0 stevel #pragma D binding \"1.0\" NULL\n\ 593 0 stevel "; 594 0 stevel 595 0 stevel /* 596 0 stevel * Default DTrace configuration to use when opening libdtrace DTRACE_O_NODEV. 597 0 stevel * If DTRACE_O_NODEV is not set, we load the configuration from the kernel. 598 0 stevel * The use of CTF_MODEL_NATIVE is more subtle than it might appear: we are 599 0 stevel * relying on the fact that when running dtrace(1M), isaexec will invoke the 600 0 stevel * binary with the same bitness as the kernel, which is what we want by default 601 0 stevel * when generating our DIF. The user can override the choice using oflags. 602 0 stevel */ 603 0 stevel static const dtrace_conf_t _dtrace_conf = { 604 0 stevel DIF_VERSION, /* dtc_difversion */ 605 0 stevel DIF_DIR_NREGS, /* dtc_difintregs */ 606 0 stevel DIF_DTR_NREGS, /* dtc_diftupregs */ 607 0 stevel CTF_MODEL_NATIVE /* dtc_ctfmodel */ 608 0 stevel }; 609 0 stevel 610 0 stevel const dtrace_attribute_t _dtrace_maxattr = { 611 0 stevel DTRACE_STABILITY_MAX, 612 0 stevel DTRACE_STABILITY_MAX, 613 0 stevel DTRACE_CLASS_MAX 614 0 stevel }; 615 0 stevel 616 0 stevel const dtrace_attribute_t _dtrace_defattr = { 617 0 stevel DTRACE_STABILITY_STABLE, 618 0 stevel DTRACE_STABILITY_STABLE, 619 0 stevel DTRACE_CLASS_COMMON 620 0 stevel }; 621 0 stevel 622 0 stevel const dtrace_attribute_t _dtrace_symattr = { 623 0 stevel DTRACE_STABILITY_PRIVATE, 624 0 stevel DTRACE_STABILITY_PRIVATE, 625 0 stevel DTRACE_CLASS_UNKNOWN 626 0 stevel }; 627 0 stevel 628 0 stevel const dtrace_attribute_t _dtrace_typattr = { 629 0 stevel DTRACE_STABILITY_PRIVATE, 630 0 stevel DTRACE_STABILITY_PRIVATE, 631 0 stevel DTRACE_CLASS_UNKNOWN 632 0 stevel }; 633 0 stevel 634 0 stevel const dtrace_attribute_t _dtrace_prvattr = { 635 0 stevel DTRACE_STABILITY_PRIVATE, 636 0 stevel DTRACE_STABILITY_PRIVATE, 637 0 stevel DTRACE_CLASS_UNKNOWN 638 0 stevel }; 639 0 stevel 640 0 stevel const dtrace_pattr_t _dtrace_prvdesc = { 641 0 stevel { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON }, 642 0 stevel { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON }, 643 0 stevel { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON }, 644 0 stevel { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON }, 645 0 stevel { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON }, 646 0 stevel }; 647 0 stevel 648 0 stevel const char *_dtrace_defcpp = "/usr/ccs/lib/cpp"; /* default cpp(1) to invoke */ 649 0 stevel const char *_dtrace_defld = "/usr/ccs/bin/ld"; /* default ld(1) to invoke */ 650 0 stevel 651 0 stevel const char *_dtrace_libdir = "/usr/lib/dtrace"; /* default library directory */ 652 1149 dp const char *_dtrace_provdir = "/dev/dtrace/provider"; /* provider directory */ 653 0 stevel 654 0 stevel int _dtrace_strbuckets = 211; /* default number of hash buckets (prime) */ 655 0 stevel int _dtrace_intbuckets = 256; /* default number of integer buckets (Pof2) */ 656 0 stevel uint_t _dtrace_strsize = 256; /* default size of string intrinsic type */ 657 0 stevel uint_t _dtrace_stkindent = 14; /* default whitespace indent for stack/ustack */ 658 0 stevel uint_t _dtrace_pidbuckets = 64; /* default number of pid hash buckets */ 659 0 stevel uint_t _dtrace_pidlrulim = 8; /* default number of pid handles to cache */ 660 0 stevel size_t _dtrace_bufsize = 512; /* default dt_buf_create() size */ 661 0 stevel int _dtrace_argmax = 32; /* default maximum number of probe arguments */ 662 0 stevel 663 0 stevel int _dtrace_debug = 0; /* debug messages enabled (off) */ 664 0 stevel const char *const _dtrace_version = DT_VERS_STRING; /* API version string */ 665 0 stevel int _dtrace_rdvers = RD_VERSION; /* rtld_db feature version */ 666 0 stevel 667 0 stevel typedef struct dt_fdlist { 668 0 stevel int *df_fds; /* array of provider driver file descriptors */ 669 0 stevel uint_t df_ents; /* number of valid elements in df_fds[] */ 670 0 stevel uint_t df_size; /* size of df_fds[] */ 671 0 stevel } dt_fdlist_t; 672 0 stevel 673 0 stevel #pragma init(_dtrace_init) 674 0 stevel void 675 0 stevel _dtrace_init(void) 676 0 stevel { 677 0 stevel _dtrace_debug = getenv("DTRACE_DEBUG") != NULL; 678 0 stevel 679 0 stevel for (; _dtrace_rdvers > 0; _dtrace_rdvers--) { 680 0 stevel if (rd_init(_dtrace_rdvers) == RD_OK) 681 0 stevel break; 682 0 stevel } 683 0 stevel } 684 0 stevel 685 0 stevel static dtrace_hdl_t * 686 0 stevel set_open_errno(dtrace_hdl_t *dtp, int *errp, int err) 687 0 stevel { 688 0 stevel if (dtp != NULL) 689 0 stevel dtrace_close(dtp); 690 0 stevel if (errp != NULL) 691 0 stevel *errp = err; 692 0 stevel return (NULL); 693 0 stevel } 694 0 stevel 695 0 stevel static void 696 1149 dp dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp) 697 0 stevel { 698 0 stevel dt_provmod_t *prov; 699 0 stevel char path[PATH_MAX]; 700 0 stevel struct dirent *dp, *ep; 701 0 stevel DIR *dirp; 702 0 stevel int fd; 703 0 stevel 704 1149 dp if ((dirp = opendir(_dtrace_provdir)) == NULL) 705 0 stevel return; /* failed to open directory; just skip it */ 706 0 stevel 707 0 stevel ep = alloca(sizeof (struct dirent) + PATH_MAX + 1); 708 0 stevel bzero(ep, sizeof (struct dirent) + PATH_MAX + 1); 709 0 stevel 710 0 stevel while (readdir_r(dirp, ep, &dp) == 0 && dp != NULL) { 711 0 stevel if (dp->d_name[0] == '.') 712 0 stevel continue; /* skip "." and ".." */ 713 0 stevel 714 0 stevel if (dfp->df_ents == dfp->df_size) { 715 0 stevel uint_t size = dfp->df_size ? dfp->df_size * 2 : 16; 716 0 stevel int *fds = realloc(dfp->df_fds, size * sizeof (int)); 717 0 stevel 718 0 stevel if (fds == NULL) 719 0 stevel break; /* skip the rest of this directory */ 720 0 stevel 721 0 stevel dfp->df_fds = fds; 722 0 stevel dfp->df_size = size; 723 0 stevel } 724 0 stevel 725 1149 dp (void) snprintf(path, sizeof (path), "%s/%s", 726 1149 dp _dtrace_provdir, dp->d_name); 727 0 stevel 728 0 stevel if ((fd = open(path, O_RDONLY)) == -1) 729 0 stevel continue; /* failed to open driver; just skip it */ 730 0 stevel 731 0 stevel if (((prov = malloc(sizeof (dt_provmod_t))) == NULL) || 732 0 stevel (prov->dp_name = malloc(strlen(dp->d_name) + 1)) == NULL) { 733 0 stevel free(prov); 734 0 stevel (void) close(fd); 735 0 stevel break; 736 0 stevel } 737 0 stevel 738 0 stevel (void) strcpy(prov->dp_name, dp->d_name); 739 0 stevel prov->dp_next = *provmod; 740 0 stevel *provmod = prov; 741 0 stevel 742 0 stevel dt_dprintf("opened provider %s\n", dp->d_name); 743 0 stevel dfp->df_fds[dfp->df_ents++] = fd; 744 0 stevel } 745 0 stevel 746 0 stevel (void) closedir(dirp); 747 0 stevel } 748 0 stevel 749 0 stevel static void 750 0 stevel dt_provmod_destroy(dt_provmod_t **provmod) 751 0 stevel { 752 0 stevel dt_provmod_t *next, *current; 753 0 stevel 754 0 stevel for (current = *provmod; current != NULL; current = next) { 755 0 stevel next = current->dp_next; 756 0 stevel free(current->dp_name); 757 0 stevel free(current); 758 0 stevel } 759 0 stevel 760 0 stevel *provmod = NULL; 761 0 stevel } 762 0 stevel 763 0 stevel static const char * 764 0 stevel dt_get_sysinfo(int cmd, char *buf, size_t len) 765 0 stevel { 766 0 stevel ssize_t rv = sysinfo(cmd, buf, len); 767 0 stevel char *p = buf; 768 0 stevel 769 0 stevel if (rv < 0 || rv > len) 770 0 stevel (void) snprintf(buf, len, "%s", "Unknown"); 771 0 stevel 772 0 stevel while ((p = strchr(p, '.')) != NULL) 773 0 stevel *p++ = '_'; 774 0 stevel 775 0 stevel return (buf); 776 0 stevel } 777 0 stevel 778 0 stevel static dtrace_hdl_t * 779 0 stevel dt_vopen(int version, int flags, int *errp, 780 0 stevel const dtrace_vector_t *vector, void *arg) 781 0 stevel { 782 0 stevel dtrace_hdl_t *dtp = NULL; 783 0 stevel int dtfd = -1, ftfd = -1, fterr = 0; 784 0 stevel dtrace_prog_t *pgp; 785 0 stevel dt_module_t *dmp; 786 0 stevel dt_provmod_t *provmod = NULL; 787 0 stevel int i, err; 788 1739 bmc struct rlimit rl; 789 0 stevel 790 0 stevel const dt_intrinsic_t *dinp; 791 0 stevel const dt_typedef_t *dtyp; 792 0 stevel const dt_ident_t *idp; 793 0 stevel 794 0 stevel dtrace_typeinfo_t dtt; 795 0 stevel ctf_funcinfo_t ctc; 796 0 stevel ctf_arinfo_t ctr; 797 0 stevel 798 0 stevel dt_fdlist_t df = { NULL, 0, 0 }; 799 0 stevel 800 0 stevel char isadef[32], utsdef[32]; 801 0 stevel char s1[64], s2[64]; 802 0 stevel 803 0 stevel if (version <= 0) 804 0 stevel return (set_open_errno(dtp, errp, EINVAL)); 805 0 stevel 806 0 stevel if (version > DTRACE_VERSION) 807 0 stevel return (set_open_errno(dtp, errp, EDT_VERSION)); 808 0 stevel 809 1017 bmc if (version < DTRACE_VERSION) { 810 1017 bmc /* 811 1017 bmc * Currently, increasing the library version number is used to 812 1017 bmc * denote a binary incompatible change. That is, a consumer 813 1017 bmc * of the library cannot run on a version of the library with 814 1017 bmc * a higher DTRACE_VERSION number than the consumer compiled 815 1017 bmc * against. Once the library API has been committed to, 816 1017 bmc * backwards binary compatibility will be required; at that 817 1017 bmc * time, this check should change to return EDT_OVERSION only 818 1017 bmc * if the specified version number is less than the version 819 1017 bmc * number at the time of interface commitment. 820 1017 bmc */ 821 1017 bmc return (set_open_errno(dtp, errp, EDT_OVERSION)); 822 1017 bmc } 823 1017 bmc 824 0 stevel if (flags & ~DTRACE_O_MASK) 825 0 stevel return (set_open_errno(dtp, errp, EINVAL)); 826 0 stevel 827 0 stevel if ((flags & DTRACE_O_LP64) && (flags & DTRACE_O_ILP32)) 828 0 stevel return (set_open_errno(dtp, errp, EINVAL)); 829 0 stevel 830 0 stevel if (vector == NULL && arg != NULL) 831 0 stevel return (set_open_errno(dtp, errp, EINVAL)); 832 0 stevel 833 0 stevel if (elf_version(EV_CURRENT) == EV_NONE) 834 0 stevel return (set_open_errno(dtp, errp, EDT_ELFVERSION)); 835 0 stevel 836 0 stevel if (vector != NULL || (flags & DTRACE_O_NODEV)) 837 0 stevel goto alloc; /* do not attempt to open dtrace device */ 838 1739 bmc 839 1739 bmc /* 840 1739 bmc * Before we get going, crank our limit on file descriptors up to the 841 1739 bmc * hard limit. This is to allow for the fact that libproc keeps file 842 1739 bmc * descriptors to objects open for the lifetime of the proc handle; 843 1739 bmc * without raising our hard limit, we would have an acceptably small 844 1739 bmc * bound on the number of processes that we could concurrently 845 1739 bmc * instrument with the pid provider. 846 1739 bmc */ 847 1739 bmc if (getrlimit(RLIMIT_NOFILE, &rl) == 0) { 848 1739 bmc rl.rlim_cur = rl.rlim_max; 849 1739 bmc (void) setrlimit(RLIMIT_NOFILE, &rl); 850 1739 bmc } 851 0 stevel 852 0 stevel /* 853 1149 dp * Get the device path of each of the providers. We hold them open 854 1149 dp * in the df.df_fds list until we open the DTrace driver itself, 855 1149 dp * allowing us to see all of the probes provided on this system. Once 856 1149 dp * we have the DTrace driver open, we can safely close all the providers 857 1149 dp * now that they have registered with the framework. 858 0 stevel */ 859 1149 dp dt_provmod_open(&provmod, &df); 860 0 stevel 861 1149 dp dtfd = open("/dev/dtrace/dtrace", O_RDWR); 862 0 stevel err = errno; /* save errno from opening dtfd */ 863 0 stevel 864 1149 dp ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR); 865 0 stevel fterr = ftfd == -1 ? errno : 0; /* save errno from open ftfd */ 866 0 stevel 867 0 stevel while (df.df_ents-- != 0) 868 0 stevel (void) close(df.df_fds[df.df_ents]); 869 0 stevel 870 0 stevel free(df.df_fds); 871 0 stevel 872 0 stevel /* 873 0 stevel * If we failed to open the dtrace device, fail dtrace_open(). 874 0 stevel * We convert some kernel errnos to custom libdtrace errnos to 875 0 stevel * improve the resulting message from the usual strerror(). 876 0 stevel */ 877 0 stevel if (dtfd == -1) { 878 0 stevel dt_provmod_destroy(&provmod); 879 0 stevel switch (err) { 880 0 stevel case ENOENT: 881 1677 dp err = EDT_NOENT; 882 0 stevel break; 883 0 stevel case EBUSY: 884 0 stevel err = EDT_BUSY; 885 0 stevel break; 886 0 stevel case EACCES: 887 0 stevel err = EDT_ACCESS; 888 0 stevel break; 889 0 stevel } 890 0 stevel return (set_open_errno(dtp, errp, err)); 891 0 stevel } 892 0 stevel 893 0 stevel (void) fcntl(dtfd, F_SETFD, FD_CLOEXEC); 894 0 stevel (void) fcntl(ftfd, F_SETFD, FD_CLOEXEC); 895 0 stevel 896 0 stevel alloc: 897 0 stevel if ((dtp = malloc(sizeof (dtrace_hdl_t))) == NULL) 898 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 899 0 stevel 900 0 stevel bzero(dtp, sizeof (dtrace_hdl_t)); 901 0 stevel dtp->dt_oflags = flags; 902 0 stevel dtp->dt_prcmode = DT_PROC_STOP_PREINIT; 903 0 stevel dtp->dt_linkmode = DT_LINK_KERNEL; 904 0 stevel dtp->dt_linktype = DT_LTYP_ELF; 905 265 mws dtp->dt_xlatemode = DT_XL_STATIC; 906 0 stevel dtp->dt_stdcmode = DT_STDC_XA; 907 0 stevel dtp->dt_version = version; 908 0 stevel dtp->dt_fd = dtfd; 909 0 stevel dtp->dt_ftfd = ftfd; 910 0 stevel dtp->dt_fterr = fterr; 911 0 stevel dtp->dt_cdefs_fd = -1; 912 0 stevel dtp->dt_ddefs_fd = -1; 913 0 stevel dtp->dt_stdout_fd = -1; 914 0 stevel dtp->dt_modbuckets = _dtrace_strbuckets; 915 0 stevel dtp->dt_mods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *)); 916 0 stevel dtp->dt_provbuckets = _dtrace_strbuckets; 917 0 stevel dtp->dt_provs = calloc(dtp->dt_provbuckets, sizeof (dt_provider_t *)); 918 0 stevel dt_proc_hash_create(dtp); 919 0 stevel dtp->dt_vmax = DT_VERS_LATEST; 920 0 stevel dtp->dt_cpp_path = strdup(_dtrace_defcpp); 921 0 stevel dtp->dt_cpp_argv = malloc(sizeof (char *)); 922 0 stevel dtp->dt_cpp_argc = 1; 923 0 stevel dtp->dt_cpp_args = 1; 924 0 stevel dtp->dt_ld_path = strdup(_dtrace_defld); 925 0 stevel dtp->dt_provmod = provmod; 926 0 stevel dtp->dt_vector = vector; 927 0 stevel dtp->dt_varg = arg; 928 0 stevel dt_dof_init(dtp); 929 0 stevel (void) uname(&dtp->dt_uts); 930 0 stevel 931 0 stevel if (dtp->dt_mods == NULL || dtp->dt_provs == NULL || 932 0 stevel dtp->dt_procs == NULL || dtp->dt_ld_path == NULL || 933 0 stevel dtp->dt_cpp_path == NULL || dtp->dt_cpp_argv == NULL) 934 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 935 0 stevel 936 0 stevel for (i = 0; i < DTRACEOPT_MAX; i++) 937 0 stevel dtp->dt_options[i] = DTRACEOPT_UNSET; 938 0 stevel 939 0 stevel dtp->dt_cpp_argv[0] = (char *)strbasename(dtp->dt_cpp_path); 940 0 stevel 941 0 stevel (void) snprintf(isadef, sizeof (isadef), "-D__SUNW_D_%u", 942 0 stevel (uint_t)(sizeof (void *) * NBBY)); 943 0 stevel 944 0 stevel (void) snprintf(utsdef, sizeof (utsdef), "-D__%s_%s", 945 0 stevel dt_get_sysinfo(SI_SYSNAME, s1, sizeof (s1)), 946 0 stevel dt_get_sysinfo(SI_RELEASE, s2, sizeof (s2))); 947 0 stevel 948 0 stevel if (dt_cpp_add_arg(dtp, "-D__sun") == NULL || 949 0 stevel dt_cpp_add_arg(dtp, "-D__unix") == NULL || 950 0 stevel dt_cpp_add_arg(dtp, "-D__SVR4") == NULL || 951 0 stevel dt_cpp_add_arg(dtp, "-D__SUNW_D=1") == NULL || 952 0 stevel dt_cpp_add_arg(dtp, isadef) == NULL || 953 0 stevel dt_cpp_add_arg(dtp, utsdef) == NULL) 954 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 955 0 stevel 956 0 stevel if (flags & DTRACE_O_NODEV) 957 0 stevel bcopy(&_dtrace_conf, &dtp->dt_conf, sizeof (_dtrace_conf)); 958 0 stevel else if (dt_ioctl(dtp, DTRACEIOC_CONF, &dtp->dt_conf) != 0) 959 0 stevel return (set_open_errno(dtp, errp, errno)); 960 0 stevel 961 0 stevel if (flags & DTRACE_O_LP64) 962 0 stevel dtp->dt_conf.dtc_ctfmodel = CTF_MODEL_LP64; 963 0 stevel else if (flags & DTRACE_O_ILP32) 964 0 stevel dtp->dt_conf.dtc_ctfmodel = CTF_MODEL_ILP32; 965 0 stevel 966 0 stevel #ifdef __sparc 967 0 stevel /* 968 0 stevel * On SPARC systems, __sparc is always defined for <sys/isa_defs.h> 969 0 stevel * and __sparcv9 is defined if we are doing a 64-bit compile. 970 0 stevel */ 971 0 stevel if (dt_cpp_add_arg(dtp, "-D__sparc") == NULL) 972 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 973 0 stevel 974 0 stevel if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64 && 975 0 stevel dt_cpp_add_arg(dtp, "-D__sparcv9") == NULL) 976 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 977 0 stevel #endif 978 0 stevel 979 0 stevel #ifdef __x86 980 0 stevel /* 981 0 stevel * On x86 systems, __i386 is defined for <sys/isa_defs.h> for 32-bit 982 0 stevel * compiles and __amd64 is defined for 64-bit compiles. Unlike SPARC, 983 0 stevel * they are defined exclusive of one another (see PSARC 2004/619). 984 0 stevel */ 985 1151 dp if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64) { 986 1151 dp if (dt_cpp_add_arg(dtp, "-D__amd64") == NULL) 987 1151 dp return (set_open_errno(dtp, errp, EDT_NOMEM)); 988 1151 dp } else { 989 1151 dp if (dt_cpp_add_arg(dtp, "-D__i386") == NULL) 990 1151 dp return (set_open_errno(dtp, errp, EDT_NOMEM)); 991 1151 dp } 992 0 stevel #endif 993 0 stevel 994 0 stevel if (dtp->dt_conf.dtc_difversion < DIF_VERSION) 995 0 stevel return (set_open_errno(dtp, errp, EDT_DIFVERS)); 996 0 stevel 997 0 stevel if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_ILP32) 998 0 stevel bcopy(_dtrace_ints_32, dtp->dt_ints, sizeof (_dtrace_ints_32)); 999 0 stevel else 1000 0 stevel bcopy(_dtrace_ints_64, dtp->dt_ints, sizeof (_dtrace_ints_64)); 1001 0 stevel 1002 0 stevel dtp->dt_macros = dt_idhash_create("macro", NULL, 0, UINT_MAX); 1003 1017 bmc dtp->dt_aggs = dt_idhash_create("aggregation", NULL, 1004 1017 bmc DTRACE_AGGVARIDNONE + 1, UINT_MAX); 1005 0 stevel 1006 0 stevel dtp->dt_globals = dt_idhash_create("global", _dtrace_globals, 1007 0 stevel DIF_VAR_OTHER_UBASE, DIF_VAR_OTHER_MAX); 1008 0 stevel 1009 0 stevel dtp->dt_tls = dt_idhash_create("thread local", NULL, 1010 0 stevel DIF_VAR_OTHER_UBASE, DIF_VAR_OTHER_MAX); 1011 0 stevel 1012 0 stevel if (dtp->dt_macros == NULL || dtp->dt_aggs == NULL || 1013 0 stevel dtp->dt_globals == NULL || dtp->dt_tls == NULL) 1014 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 1015 0 stevel 1016 0 stevel /* 1017 0 stevel * Populate the dt_macros identifier hash table by hand: we can't use 1018 0 stevel * the dt_idhash_populate() mechanism because we're not yet compiling 1019 0 stevel * and dtrace_update() needs to immediately reference these idents. 1020 0 stevel */ 1021 0 stevel for (idp = _dtrace_macros; idp->di_name != NULL; idp++) { 1022 0 stevel if (dt_idhash_insert(dtp->dt_macros, idp->di_name, 1023 0 stevel idp->di_kind, idp->di_flags, idp->di_id, idp->di_attr, 1024 0 stevel idp->di_vers, idp->di_ops ? idp->di_ops : &dt_idops_thaw, 1025 0 stevel idp->di_iarg, 0) == NULL) 1026 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 1027 0 stevel } 1028 0 stevel 1029 0 stevel /* 1030 0 stevel * Update the module list using /system/object and load the values for 1031 0 stevel * the macro variable definitions according to the current process. 1032 0 stevel */ 1033 0 stevel dtrace_update(dtp); 1034 0 stevel 1035 0 stevel /* 1036 0 stevel * Select the intrinsics and typedefs we want based on the data model. 1037 0 stevel * The intrinsics are under "C". The typedefs are added under "D". 1038 0 stevel */ 1039 0 stevel if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_ILP32) { 1040 0 stevel dinp = _dtrace_intrinsics_32; 1041 0 stevel dtyp = _dtrace_typedefs_32; 1042 0 stevel } else { 1043 0 stevel dinp = _dtrace_intrinsics_64; 1044 0 stevel dtyp = _dtrace_typedefs_64; 1045 0 stevel } 1046 0 stevel 1047 0 stevel /* 1048 0 stevel * Create a dynamic CTF container under the "C" scope for intrinsic 1049 0 stevel * types and types defined in ANSI-C header files that are included. 1050 0 stevel */ 1051 0 stevel if ((dmp = dtp->dt_cdefs = dt_module_create(dtp, "C")) == NULL) 1052 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 1053 0 stevel 1054 0 stevel if ((dmp->dm_ctfp = ctf_create(&dtp->dt_ctferr)) == NULL) 1055 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1056 0 stevel 1057 0 stevel dt_dprintf("created CTF container for %s (%p)\n", 1058 0 stevel dmp->dm_name, (void *)dmp->dm_ctfp); 1059 0 stevel 1060 0 stevel (void) ctf_setmodel(dmp->dm_ctfp, dtp->dt_conf.dtc_ctfmodel); 1061 0 stevel ctf_setspecific(dmp->dm_ctfp, dmp); 1062 0 stevel 1063 0 stevel dmp->dm_flags = DT_DM_LOADED; /* fake up loaded bit */ 1064 0 stevel dmp->dm_modid = -1; /* no module ID */ 1065 0 stevel 1066 0 stevel /* 1067 0 stevel * Fill the dynamic "C" CTF container with all of the intrinsic 1068 0 stevel * integer and floating-point types appropriate for this data model. 1069 0 stevel */ 1070 0 stevel for (; dinp->din_name != NULL; dinp++) { 1071 0 stevel if (dinp->din_kind == CTF_K_INTEGER) { 1072 0 stevel err = ctf_add_integer(dmp->dm_ctfp, CTF_ADD_ROOT, 1073 0 stevel dinp->din_name, &dinp->din_data); 1074 0 stevel } else { 1075 0 stevel err = ctf_add_float(dmp->dm_ctfp, CTF_ADD_ROOT, 1076 0 stevel dinp->din_name, &dinp->din_data); 1077 0 stevel } 1078 0 stevel 1079 0 stevel if (err == CTF_ERR) { 1080 0 stevel dt_dprintf("failed to add %s to C container: %s\n", 1081 0 stevel dinp->din_name, ctf_errmsg( 1082 0 stevel ctf_errno(dmp->dm_ctfp))); 1083 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1084 0 stevel } 1085 0 stevel } 1086 0 stevel 1087 0 stevel if (ctf_update(dmp->dm_ctfp) != 0) { 1088 0 stevel dt_dprintf("failed to update C container: %s\n", 1089 0 stevel ctf_errmsg(ctf_errno(dmp->dm_ctfp))); 1090 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1091 0 stevel } 1092 0 stevel 1093 0 stevel /* 1094 0 stevel * Add intrinsic pointer types that are needed to initialize printf 1095 0 stevel * format dictionary types (see table in dt_printf.c). 1096 0 stevel */ 1097 0 stevel (void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, 1098 0 stevel ctf_lookup_by_name(dmp->dm_ctfp, "void")); 1099 0 stevel 1100 0 stevel (void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, 1101 0 stevel ctf_lookup_by_name(dmp->dm_ctfp, "char")); 1102 0 stevel 1103 0 stevel (void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, 1104 0 stevel ctf_lookup_by_name(dmp->dm_ctfp, "int")); 1105 0 stevel 1106 0 stevel if (ctf_update(dmp->dm_ctfp) != 0) { 1107 0 stevel dt_dprintf("failed to update C container: %s\n", 1108 0 stevel ctf_errmsg(ctf_errno(dmp->dm_ctfp))); 1109 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1110 0 stevel } 1111 0 stevel 1112 0 stevel /* 1113 0 stevel * Create a dynamic CTF container under the "D" scope for types that 1114 0 stevel * are defined by the D program itself or on-the-fly by the D compiler. 1115 0 stevel * The "D" CTF container is a child of the "C" CTF container. 1116 0 stevel */ 1117 0 stevel if ((dmp = dtp->dt_ddefs = dt_module_create(dtp, "D")) == NULL) 1118 0 stevel return (set_open_errno(dtp, errp, EDT_NOMEM)); 1119 0 stevel 1120 0 stevel if ((dmp->dm_ctfp = ctf_create(&dtp->dt_ctferr)) == NULL) 1121 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1122 0 stevel 1123 0 stevel dt_dprintf("created CTF container for %s (%p)\n", 1124 0 stevel dmp->dm_name, (void *)dmp->dm_ctfp); 1125 0 stevel 1126 0 stevel (void) ctf_setmodel(dmp->dm_ctfp, dtp->dt_conf.dtc_ctfmodel); 1127 0 stevel ctf_setspecific(dmp->dm_ctfp, dmp); 1128 0 stevel 1129 0 stevel dmp->dm_flags = DT_DM_LOADED; /* fake up loaded bit */ 1130 0 stevel dmp->dm_modid = -1; /* no module ID */ 1131 0 stevel 1132 0 stevel if (ctf_import(dmp->dm_ctfp, dtp->dt_cdefs->dm_ctfp) == CTF_ERR) { 1133 0 stevel dt_dprintf("failed to import D parent container: %s\n", 1134 0 stevel ctf_errmsg(ctf_errno(dmp->dm_ctfp))); 1135 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1136 0 stevel } 1137 0 stevel 1138 0 stevel /* 1139 0 stevel * Fill the dynamic "D" CTF container with all of the built-in typedefs 1140 0 stevel * that we need to use for our D variable and function definitions. 1141 0 stevel * This ensures that basic inttypes.h names are always available to us. 1142 0 stevel */ 1143 0 stevel for (; dtyp->dty_src != NULL; dtyp++) { 1144 0 stevel if (ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT, 1145 0 stevel dtyp->dty_dst, ctf_lookup_by_name(dmp->dm_ctfp, 1146 0 stevel dtyp->dty_src)) == CTF_ERR) { 1147 0 stevel dt_dprintf("failed to add typedef %s %s to D " 1148 0 stevel "container: %s", dtyp->dty_src, dtyp->dty_dst, 1149 0 stevel ctf_errmsg(ctf_errno(dmp->dm_ctfp))); 1150 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1151 0 stevel } 1152 0 stevel } 1153 0 stevel 1154 0 stevel /* 1155 0 stevel * Insert a CTF ID corresponding to a pointer to a type of kind 1156 0 stevel * CTF_K_FUNCTION we can use in the compiler for function pointers. 1157 0 stevel * CTF treats all function pointers as "int (*)()" so we only need one. 1158 0 stevel */ 1159 0 stevel ctc.ctc_return = ctf_lookup_by_name(dmp->dm_ctfp, "int"); 1160 0 stevel ctc.ctc_argc = 0; 1161 0 stevel ctc.ctc_flags = 0; 1162 0 stevel 1163 0 stevel dtp->dt_type_func = ctf_add_function(dmp->dm_ctfp, 1164 0 stevel CTF_ADD_ROOT, &ctc, NULL); 1165 0 stevel 1166 0 stevel dtp->dt_type_fptr = ctf_add_pointer(dmp->dm_ctfp, 1167 0 stevel CTF_ADD_ROOT, dtp->dt_type_func); 1168 0 stevel 1169 0 stevel /* 1170 0 stevel * We also insert CTF definitions for the special D intrinsic types 1171 0 stevel * string and <DYN> into the D container. The string type is added 1172 0 stevel * as a typedef of char[n]. The <DYN> type is an alias for void. 1173 0 stevel * We compare types to these special CTF ids throughout the compiler. 1174 0 stevel */ 1175 0 stevel ctr.ctr_contents = ctf_lookup_by_name(dmp->dm_ctfp, "char"); 1176 0 stevel ctr.ctr_index = ctf_lookup_by_name(dmp->dm_ctfp, "long"); 1177 0 stevel ctr.ctr_nelems = _dtrace_strsize; 1178 0 stevel 1179 0 stevel dtp->dt_type_str = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT, 1180 0 stevel "string", ctf_add_array(dmp->dm_ctfp, CTF_ADD_ROOT, &ctr)); 1181 0 stevel 1182 0 stevel dtp->dt_type_dyn = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT, 1183 0 stevel "<DYN>", ctf_lookup_by_name(dmp->dm_ctfp, "void")); 1184 0 stevel 1185 0 stevel dtp->dt_type_stack = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT, 1186 0 stevel "stack", ctf_lookup_by_name(dmp->dm_ctfp, "void")); 1187 0 stevel 1188 457 bmc dtp->dt_type_symaddr = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT, 1189 457 bmc "_symaddr", ctf_lookup_by_name(dmp->dm_ctfp, "void")); 1190 457 bmc 1191 457 bmc dtp->dt_type_usymaddr = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT, 1192 457 bmc "_usymaddr", ctf_lookup_by_name(dmp->dm_ctfp, "void")); 1193 457 bmc 1194 0 stevel if (dtp->dt_type_func == CTF_ERR || dtp->dt_type_fptr == CTF_ERR || 1195 0 stevel dtp->dt_type_str == CTF_ERR || dtp->dt_type_dyn == CTF_ERR || 1196 457 bmc dtp->dt_type_stack == CTF_ERR || dtp->dt_type_symaddr == CTF_ERR || 1197 457 bmc dtp->dt_type_usymaddr == CTF_ERR) { 1198 0 stevel dt_dprintf("failed to add intrinsic to D container: %s\n", 1199 0 stevel ctf_errmsg(ctf_errno(dmp->dm_ctfp))); 1200 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1201 0 stevel } 1202 0 stevel 1203 0 stevel if (ctf_update(dmp->dm_ctfp) != 0) { 1204 0 stevel dt_dprintf("failed update D container: %s\n", 1205 0 stevel ctf_errmsg(ctf_errno(dmp->dm_ctfp))); 1206 0 stevel return (set_open_errno(dtp, errp, EDT_CTF)); 1207 0 stevel } 1208 0 stevel 1209 0 stevel /* 1210 0 stevel * Initialize the integer description table used to convert integer 1211 0 stevel * constants to the appropriate types. Refer to the comments above 1212 0 stevel * dt_node_int() for a complete description of how this table is used. 1213 0 stevel */ 1214 0 stevel for (i = 0; i < sizeof (dtp->dt_ints) / sizeof (dtp->dt_ints[0]); i++) { 1215 0 stevel if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_EVERY, 1216 0 stevel dtp->dt_ints[i].did_name, &dtt) != 0) { 1217 0 stevel dt_dprintf("failed to lookup integer type %s: %s\n", 1218 0 stevel dtp->dt_ints[i].did_name, 1219 0 stevel dtrace_errmsg(dtp, dtrace_errno(dtp))); 1220 0 stevel return (set_open_errno(dtp, errp, dtp->dt_errno)); 1221 0 stevel } 1222 0 stevel dtp->dt_ints[i].did_ctfp = dtt.dtt_ctfp; 1223 0 stevel dtp->dt_ints[i].did_type = dtt.dtt_type; 1224 0 stevel } 1225 0 stevel 1226 0 stevel /* 1227 0 stevel * Now that we've created the "C" and "D" containers, move them to the 1228 0 stevel * start of the module list so that these types and symbols are found 1229 0 stevel * first (for stability) when iterating through the module list. 1230 0 stevel */ 1231 0 stevel dt_list_delete(&dtp->dt_modlist, dtp->dt_ddefs); 1232 0 stevel dt_list_prepend(&dtp->dt_modlist, dtp->dt_ddefs); 1233 0 stevel 1234 0 stevel dt_list_delete(&dtp->dt_modlist, dtp->dt_cdefs); 1235 0 stevel dt_list_prepend(&dtp->dt_modlist, dtp->dt_cdefs); 1236 0 stevel 1237 0 stevel if (dt_pfdict_create(dtp) == -1) 1238 0 stevel return (set_open_errno(dtp, errp, dtp->dt_errno)); 1239 0 stevel 1240 0 stevel /* 1241 0 stevel * If we are opening libdtrace DTRACE_O_NODEV enable C_ZDEFS by default 1242 0 stevel * because without /dev/dtrace open, we will not be able to load the 1243 0 stevel * names and attributes of any providers or probes from the kernel. 1244 0 stevel */ 1245 0 stevel if (flags & DTRACE_O_NODEV) 1246 0 stevel dtp->dt_cflags |= DTRACE_C_ZDEFS; 1247 0 stevel 1248 0 stevel /* 1249 0 stevel * Load hard-wired inlines into the definition cache by calling the 1250 0 stevel * compiler on the raw definition string defined above. 1251 0 stevel */ 1252 0 stevel if ((pgp = dtrace_program_strcompile(dtp, _dtrace_hardwire, 1253 0 stevel DTRACE_PROBESPEC_NONE, DTRACE_C_EMPTY, 0, NULL)) == NULL) { 1254 0 stevel dt_dprintf("failed to load hard-wired definitions: %s\n", 1255 0 stevel dtrace_errmsg(dtp, dtrace_errno(dtp))); 1256 0 stevel return (set_open_errno(dtp, errp, EDT_HARDWIRE)); 1257 0 stevel } 1258 0 stevel 1259 265 mws dt_program_destroy(dtp, pgp); 1260 0 stevel 1261 0 stevel /* 1262 0 stevel * Set up the default DTrace library path. Once set, the next call to 1263 0 stevel * dt_compile() will compile all the libraries. We intentionally defer 1264 0 stevel * library processing to improve overhead for clients that don't ever 1265 0 stevel * compile, and to provide better error reporting (because the full 1266 0 stevel * reporting of compiler errors requires dtrace_open() to succeed). 1267 0 stevel */ 1268 0 stevel if (dtrace_setopt(dtp, "libdir", _dtrace_libdir) != 0) 1269 0 stevel return (set_open_errno(dtp, errp, dtp->dt_errno)); 1270 0 stevel 1271 0 stevel return (dtp); 1272 0 stevel } 1273 0 stevel 1274 0 stevel dtrace_hdl_t * 1275 0 stevel dtrace_open(int version, int flags, int *errp) 1276 0 stevel { 1277 0 stevel return (dt_vopen(version, flags, errp, NULL, NULL)); 1278 0 stevel } 1279 0 stevel 1280 0 stevel dtrace_hdl_t * 1281 0 stevel dtrace_vopen(int version, int flags, int *errp, 1282 0 stevel const dtrace_vector_t *vector, void *arg) 1283 0 stevel { 1284 0 stevel return (dt_vopen(version, flags, errp, vector, arg)); 1285 0 stevel } 1286 0 stevel 1287 0 stevel void 1288 0 stevel dtrace_close(dtrace_hdl_t *dtp) 1289 0 stevel { 1290 0 stevel dt_ident_t *idp, *ndp; 1291 0 stevel dt_module_t *dmp; 1292 0 stevel dt_provider_t *pvp; 1293 0 stevel dtrace_prog_t *pgp; 1294 0 stevel dt_xlator_t *dxp; 1295 0 stevel dt_dirpath_t *dirp; 1296 0 stevel int i; 1297 0 stevel 1298 6390 ahl if (dtp->dt_procs != NULL) 1299 6390 ahl dt_proc_hash_destroy(dtp); 1300 6390 ahl 1301 0 stevel while ((pgp = dt_list_next(&dtp->dt_programs)) != NULL) 1302 265 mws dt_program_destroy(dtp, pgp); 1303 0 stevel 1304 0 stevel while ((dxp = dt_list_next(&dtp->dt_xlators)) != NULL) 1305 0 stevel dt_xlator_destroy(dtp, dxp); 1306 265 mws 1307 265 mws dt_free(dtp, dtp->dt_xlatormap); 1308 0 stevel 1309 0 stevel for (idp = dtp->dt_externs; idp != NULL; idp = ndp) { 1310 0 stevel ndp = idp->di_next; 1311 0 stevel dt_ident_destroy(idp); 1312 0 stevel } 1313 0 stevel 1314 0 stevel if (dtp->dt_macros != NULL) 1315 0 stevel dt_idhash_destroy(dtp->dt_macros); 1316 0 stevel if (dtp->dt_aggs != NULL) 1317 0 stevel dt_idhash_destroy(dtp->dt_aggs); 1318 0 stevel if (dtp->dt_globals != NULL) 1319 0 stevel dt_idhash_destroy(dtp->dt_globals); 1320 0 stevel if (dtp->dt_tls != NULL) 1321 0 stevel dt_idhash_destroy(dtp->dt_tls); 1322 0 stevel 1323 0 stevel while ((dmp = dt_list_next(&dtp->dt_modlist)) != NULL) 1324 0 stevel dt_module_destroy(dtp, dmp); 1325 0 stevel 1326 0 stevel while ((pvp = dt_list_next(&dtp->dt_provlist)) != NULL) 1327 0 stevel dt_provider_destroy(dtp, pvp); 1328 0 stevel 1329 0 stevel if (dtp->dt_fd != -1) 1330 0 stevel (void) close(dtp->dt_fd); 1331 0 stevel if (dtp->dt_ftfd != -1) 1332 0 stevel (void) close(dtp->dt_ftfd); 1333 0 stevel if (dtp->dt_cdefs_fd != -1) 1334 0 stevel (void) close(dtp->dt_cdefs_fd); 1335 0 stevel if (dtp->dt_ddefs_fd != -1) 1336 0 stevel (void) close(dtp->dt_ddefs_fd); 1337 0 stevel if (dtp->dt_stdout_fd != -1) 1338 0 stevel (void) close(dtp->dt_stdout_fd); 1339 0 stevel 1340 0 stevel dt_epid_destroy(dtp); 1341 0 stevel dt_aggid_destroy(dtp); 1342 0 stevel dt_format_destroy(dtp); 1343 0 stevel dt_buffered_destroy(dtp); 1344 0 stevel dt_aggregate_destroy(dtp); 1345 0 stevel free(dtp->dt_buf.dtbd_data); 1346 0 stevel dt_pfdict_destroy(dtp); 1347 0 stevel dt_provmod_destroy(&dtp->dt_provmod); 1348 0 stevel dt_dof_fini(dtp); 1349 0 stevel 1350 0 stevel for (i = 1; i < dtp->dt_cpp_argc; i++) 1351 0 stevel free(dtp->dt_cpp_argv[i]); 1352 0 stevel 1353 0 stevel while ((dirp = dt_list_next(&dtp->dt_lib_path)) != NULL) { 1354 0 stevel dt_list_delete(&dtp->dt_lib_path, dirp); 1355 0 stevel free(dirp->dir_path); 1356 0 stevel free(dirp); 1357 0 stevel } 1358 0 stevel 1359 0 stevel free(dtp->dt_cpp_argv); 1360 0 stevel free(dtp->dt_cpp_path); 1361 0 stevel free(dtp->dt_ld_path); 1362 0 stevel 1363 0 stevel free(dtp->dt_mods); 1364 0 stevel free(dtp->dt_provs); 1365 0 stevel free(dtp); 1366 0 stevel } 1367 0 stevel 1368 0 stevel int 1369 0 stevel dtrace_provider_modules(dtrace_hdl_t *dtp, const char **mods, int nmods) 1370 0 stevel { 1371 0 stevel dt_provmod_t *prov; 1372 0 stevel int i = 0; 1373 0 stevel 1374 0 stevel for (prov = dtp->dt_provmod; prov != NULL; prov = prov->dp_next, i++) { 1375 0 stevel if (i < nmods) 1376 0 stevel mods[i] = prov->dp_name; 1377 0 stevel } 1378 0 stevel 1379 0 stevel return (i); 1380 0 stevel } 1381 0 stevel 1382 0 stevel int 1383 0 stevel dtrace_ctlfd(dtrace_hdl_t *dtp) 1384 0 stevel { 1385 0 stevel return (dtp->dt_fd); 1386 0 stevel } 1387