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 /*
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2017, Joyent, Inc.
25 * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
26 */
27
28 #include <sys/types.h>
29 #include <sys/modctl.h>
30 #include <sys/systeminfo.h>
31 #include <sys/resource.h>
32
33 #include <libelf.h>
34 #include <strings.h>
35 #include <alloca.h>
36 #include <limits.h>
37 #include <unistd.h>
38 #include <stdlib.h>
39 #include <stdio.h>
40 #include <fcntl.h>
41 #include <errno.h>
42 #include <assert.h>
43
44 #define _POSIX_PTHREAD_SEMANTICS
99 #define DT_VERS_1_2_2 DT_VERSION_NUMBER(1, 2, 2)
100 #define DT_VERS_1_3 DT_VERSION_NUMBER(1, 3, 0)
101 #define DT_VERS_1_4 DT_VERSION_NUMBER(1, 4, 0)
102 #define DT_VERS_1_4_1 DT_VERSION_NUMBER(1, 4, 1)
103 #define DT_VERS_1_5 DT_VERSION_NUMBER(1, 5, 0)
104 #define DT_VERS_1_6 DT_VERSION_NUMBER(1, 6, 0)
105 #define DT_VERS_1_6_1 DT_VERSION_NUMBER(1, 6, 1)
106 #define DT_VERS_1_6_2 DT_VERSION_NUMBER(1, 6, 2)
107 #define DT_VERS_1_6_3 DT_VERSION_NUMBER(1, 6, 3)
108 #define DT_VERS_1_7 DT_VERSION_NUMBER(1, 7, 0)
109 #define DT_VERS_1_7_1 DT_VERSION_NUMBER(1, 7, 1)
110 #define DT_VERS_1_8 DT_VERSION_NUMBER(1, 8, 0)
111 #define DT_VERS_1_8_1 DT_VERSION_NUMBER(1, 8, 1)
112 #define DT_VERS_1_9 DT_VERSION_NUMBER(1, 9, 0)
113 #define DT_VERS_1_9_1 DT_VERSION_NUMBER(1, 9, 1)
114 #define DT_VERS_1_10 DT_VERSION_NUMBER(1, 10, 0)
115 #define DT_VERS_1_11 DT_VERSION_NUMBER(1, 11, 0)
116 #define DT_VERS_1_12 DT_VERSION_NUMBER(1, 12, 0)
117 #define DT_VERS_1_12_1 DT_VERSION_NUMBER(1, 12, 1)
118 #define DT_VERS_1_13 DT_VERSION_NUMBER(1, 13, 0)
119 #define DT_VERS_LATEST DT_VERS_1_13
120 #define DT_VERS_STRING "Sun D 1.13"
121
122 const dt_version_t _dtrace_versions[] = {
123 DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */
124 DT_VERS_1_1, /* D API 1.1.0 Solaris Express 6/05 */
125 DT_VERS_1_2, /* D API 1.2.0 Solaris 10 Update 1 */
126 DT_VERS_1_2_1, /* D API 1.2.1 Solaris Express 4/06 */
127 DT_VERS_1_2_2, /* D API 1.2.2 Solaris Express 6/06 */
128 DT_VERS_1_3, /* D API 1.3 Solaris Express 10/06 */
129 DT_VERS_1_4, /* D API 1.4 Solaris Express 2/07 */
130 DT_VERS_1_4_1, /* D API 1.4.1 Solaris Express 4/07 */
131 DT_VERS_1_5, /* D API 1.5 Solaris Express 7/07 */
132 DT_VERS_1_6, /* D API 1.6 */
133 DT_VERS_1_6_1, /* D API 1.6.1 */
134 DT_VERS_1_6_2, /* D API 1.6.2 */
135 DT_VERS_1_6_3, /* D API 1.6.3 */
136 DT_VERS_1_7, /* D API 1.7 */
137 DT_VERS_1_7_1, /* D API 1.7.1 */
138 DT_VERS_1_8, /* D API 1.8 */
139 DT_VERS_1_8_1, /* D API 1.8.1 */
140 DT_VERS_1_9, /* D API 1.9 */
141 DT_VERS_1_9_1, /* D API 1.9.1 */
142 DT_VERS_1_10, /* D API 1.10 */
143 DT_VERS_1_11, /* D API 1.11 */
144 DT_VERS_1_12, /* D API 1.12 */
145 DT_VERS_1_12_1, /* D API 1.12.1 */
146 DT_VERS_1_13, /* D API 1.13 */
147 0
148 };
149
150 /*
151 * Table of global identifiers. This is used to populate the global identifier
152 * hash when a new dtrace client open occurs. For more info see dt_ident.h.
153 * The global identifiers that represent functions use the dt_idops_func ops
154 * and specify the private data pointer as a prototype string which is parsed
155 * when the identifier is first encountered. These prototypes look like ANSI
156 * C function prototypes except that the special symbol "@" can be used as a
157 * wildcard to represent a single parameter of any type (i.e. any dt_node_t).
158 * The standard "..." notation can also be used to represent varargs. An empty
159 * parameter list is taken to mean void (that is, no arguments are permitted).
160 * A parameter enclosed in square brackets (e.g. "[int]") denotes an optional
161 * argument.
162 */
163 static const dt_ident_t _dtrace_globals[] = {
164 { "alloca", DT_IDENT_FUNC, 0, DIF_SUBR_ALLOCA, DT_ATTR_STABCMN, DT_VERS_1_0,
165 &dt_idops_func, "void *(size_t)" },
166 { "arg0", DT_IDENT_SCALAR, 0, DIF_VAR_ARG0, DT_ATTR_STABCMN, DT_VERS_1_0,
384 { "strjoin", DT_IDENT_FUNC, 0, DIF_SUBR_STRJOIN, DT_ATTR_STABCMN, DT_VERS_1_0,
385 &dt_idops_func, "string(const char *, const char *)" },
386 { "strrchr", DT_IDENT_FUNC, 0, DIF_SUBR_STRRCHR, DT_ATTR_STABCMN, DT_VERS_1_1,
387 &dt_idops_func, "string(const char *, char)" },
388 { "strstr", DT_IDENT_FUNC, 0, DIF_SUBR_STRSTR, DT_ATTR_STABCMN, DT_VERS_1_1,
389 &dt_idops_func, "string(const char *, const char *)" },
390 { "strtok", DT_IDENT_FUNC, 0, DIF_SUBR_STRTOK, DT_ATTR_STABCMN, DT_VERS_1_1,
391 &dt_idops_func, "string(const char *, const char *)" },
392 { "strtoll", DT_IDENT_FUNC, 0, DIF_SUBR_STRTOLL, DT_ATTR_STABCMN, DT_VERS_1_11,
393 &dt_idops_func, "int64_t(const char *, [int])" },
394 { "substr", DT_IDENT_FUNC, 0, DIF_SUBR_SUBSTR, DT_ATTR_STABCMN, DT_VERS_1_1,
395 &dt_idops_func, "string(const char *, int, [int])" },
396 { "sum", DT_IDENT_AGGFUNC, 0, DTRACEAGG_SUM, DT_ATTR_STABCMN, DT_VERS_1_0,
397 &dt_idops_func, "void(@)" },
398 { "sym", DT_IDENT_ACTFUNC, 0, DT_ACT_SYM, DT_ATTR_STABCMN,
399 DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" },
400 { "system", DT_IDENT_ACTFUNC, 0, DT_ACT_SYSTEM, DT_ATTR_STABCMN, DT_VERS_1_0,
401 &dt_idops_func, "void(@, ...)" },
402 { "this", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0,
403 &dt_idops_type, "void" },
404 { "tid", DT_IDENT_SCALAR, 0, DIF_VAR_TID, DT_ATTR_STABCMN, DT_VERS_1_0,
405 &dt_idops_type, "id_t" },
406 { "timestamp", DT_IDENT_SCALAR, 0, DIF_VAR_TIMESTAMP,
407 DT_ATTR_STABCMN, DT_VERS_1_0,
408 &dt_idops_type, "uint64_t" },
409 { "tolower", DT_IDENT_FUNC, 0, DIF_SUBR_TOLOWER, DT_ATTR_STABCMN, DT_VERS_1_8,
410 &dt_idops_func, "string(const char *)" },
411 { "toupper", DT_IDENT_FUNC, 0, DIF_SUBR_TOUPPER, DT_ATTR_STABCMN, DT_VERS_1_8,
412 &dt_idops_func, "string(const char *)" },
413 { "trace", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACE, DT_ATTR_STABCMN, DT_VERS_1_0,
414 &dt_idops_func, "void(@)" },
415 { "tracemem", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACEMEM,
416 DT_ATTR_STABCMN, DT_VERS_1_0,
417 &dt_idops_func, "void(@, size_t, ...)" },
418 { "trunc", DT_IDENT_ACTFUNC, 0, DT_ACT_TRUNC, DT_ATTR_STABCMN,
419 DT_VERS_1_0, &dt_idops_func, "void(...)" },
420 { "uaddr", DT_IDENT_ACTFUNC, 0, DT_ACT_UADDR, DT_ATTR_STABCMN,
421 DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" },
422 { "ucaller", DT_IDENT_SCALAR, 0, DIF_VAR_UCALLER, DT_ATTR_STABCMN,
423 DT_VERS_1_2, &dt_idops_type, "uint64_t" },
|
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 /*
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2018, Joyent, Inc.
25 * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
26 */
27
28 #include <sys/types.h>
29 #include <sys/modctl.h>
30 #include <sys/systeminfo.h>
31 #include <sys/resource.h>
32
33 #include <libelf.h>
34 #include <strings.h>
35 #include <alloca.h>
36 #include <limits.h>
37 #include <unistd.h>
38 #include <stdlib.h>
39 #include <stdio.h>
40 #include <fcntl.h>
41 #include <errno.h>
42 #include <assert.h>
43
44 #define _POSIX_PTHREAD_SEMANTICS
99 #define DT_VERS_1_2_2 DT_VERSION_NUMBER(1, 2, 2)
100 #define DT_VERS_1_3 DT_VERSION_NUMBER(1, 3, 0)
101 #define DT_VERS_1_4 DT_VERSION_NUMBER(1, 4, 0)
102 #define DT_VERS_1_4_1 DT_VERSION_NUMBER(1, 4, 1)
103 #define DT_VERS_1_5 DT_VERSION_NUMBER(1, 5, 0)
104 #define DT_VERS_1_6 DT_VERSION_NUMBER(1, 6, 0)
105 #define DT_VERS_1_6_1 DT_VERSION_NUMBER(1, 6, 1)
106 #define DT_VERS_1_6_2 DT_VERSION_NUMBER(1, 6, 2)
107 #define DT_VERS_1_6_3 DT_VERSION_NUMBER(1, 6, 3)
108 #define DT_VERS_1_7 DT_VERSION_NUMBER(1, 7, 0)
109 #define DT_VERS_1_7_1 DT_VERSION_NUMBER(1, 7, 1)
110 #define DT_VERS_1_8 DT_VERSION_NUMBER(1, 8, 0)
111 #define DT_VERS_1_8_1 DT_VERSION_NUMBER(1, 8, 1)
112 #define DT_VERS_1_9 DT_VERSION_NUMBER(1, 9, 0)
113 #define DT_VERS_1_9_1 DT_VERSION_NUMBER(1, 9, 1)
114 #define DT_VERS_1_10 DT_VERSION_NUMBER(1, 10, 0)
115 #define DT_VERS_1_11 DT_VERSION_NUMBER(1, 11, 0)
116 #define DT_VERS_1_12 DT_VERSION_NUMBER(1, 12, 0)
117 #define DT_VERS_1_12_1 DT_VERSION_NUMBER(1, 12, 1)
118 #define DT_VERS_1_13 DT_VERSION_NUMBER(1, 13, 0)
119 #define DT_VERS_1_14 DT_VERSION_NUMBER(1, 14, 0)
120 #define DT_VERS_LATEST DT_VERS_1_14
121 #define DT_VERS_STRING "Sun D 1.14"
122
123 const dt_version_t _dtrace_versions[] = {
124 DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */
125 DT_VERS_1_1, /* D API 1.1.0 Solaris Express 6/05 */
126 DT_VERS_1_2, /* D API 1.2.0 Solaris 10 Update 1 */
127 DT_VERS_1_2_1, /* D API 1.2.1 Solaris Express 4/06 */
128 DT_VERS_1_2_2, /* D API 1.2.2 Solaris Express 6/06 */
129 DT_VERS_1_3, /* D API 1.3 Solaris Express 10/06 */
130 DT_VERS_1_4, /* D API 1.4 Solaris Express 2/07 */
131 DT_VERS_1_4_1, /* D API 1.4.1 Solaris Express 4/07 */
132 DT_VERS_1_5, /* D API 1.5 Solaris Express 7/07 */
133 DT_VERS_1_6, /* D API 1.6 */
134 DT_VERS_1_6_1, /* D API 1.6.1 */
135 DT_VERS_1_6_2, /* D API 1.6.2 */
136 DT_VERS_1_6_3, /* D API 1.6.3 */
137 DT_VERS_1_7, /* D API 1.7 */
138 DT_VERS_1_7_1, /* D API 1.7.1 */
139 DT_VERS_1_8, /* D API 1.8 */
140 DT_VERS_1_8_1, /* D API 1.8.1 */
141 DT_VERS_1_9, /* D API 1.9 */
142 DT_VERS_1_9_1, /* D API 1.9.1 */
143 DT_VERS_1_10, /* D API 1.10 */
144 DT_VERS_1_11, /* D API 1.11 */
145 DT_VERS_1_12, /* D API 1.12 */
146 DT_VERS_1_12_1, /* D API 1.12.1 */
147 DT_VERS_1_13, /* D API 1.13 */
148 DT_VERS_1_14, /* D API 1.14 */
149 0
150 };
151
152 /*
153 * Table of global identifiers. This is used to populate the global identifier
154 * hash when a new dtrace client open occurs. For more info see dt_ident.h.
155 * The global identifiers that represent functions use the dt_idops_func ops
156 * and specify the private data pointer as a prototype string which is parsed
157 * when the identifier is first encountered. These prototypes look like ANSI
158 * C function prototypes except that the special symbol "@" can be used as a
159 * wildcard to represent a single parameter of any type (i.e. any dt_node_t).
160 * The standard "..." notation can also be used to represent varargs. An empty
161 * parameter list is taken to mean void (that is, no arguments are permitted).
162 * A parameter enclosed in square brackets (e.g. "[int]") denotes an optional
163 * argument.
164 */
165 static const dt_ident_t _dtrace_globals[] = {
166 { "alloca", DT_IDENT_FUNC, 0, DIF_SUBR_ALLOCA, DT_ATTR_STABCMN, DT_VERS_1_0,
167 &dt_idops_func, "void *(size_t)" },
168 { "arg0", DT_IDENT_SCALAR, 0, DIF_VAR_ARG0, DT_ATTR_STABCMN, DT_VERS_1_0,
386 { "strjoin", DT_IDENT_FUNC, 0, DIF_SUBR_STRJOIN, DT_ATTR_STABCMN, DT_VERS_1_0,
387 &dt_idops_func, "string(const char *, const char *)" },
388 { "strrchr", DT_IDENT_FUNC, 0, DIF_SUBR_STRRCHR, DT_ATTR_STABCMN, DT_VERS_1_1,
389 &dt_idops_func, "string(const char *, char)" },
390 { "strstr", DT_IDENT_FUNC, 0, DIF_SUBR_STRSTR, DT_ATTR_STABCMN, DT_VERS_1_1,
391 &dt_idops_func, "string(const char *, const char *)" },
392 { "strtok", DT_IDENT_FUNC, 0, DIF_SUBR_STRTOK, DT_ATTR_STABCMN, DT_VERS_1_1,
393 &dt_idops_func, "string(const char *, const char *)" },
394 { "strtoll", DT_IDENT_FUNC, 0, DIF_SUBR_STRTOLL, DT_ATTR_STABCMN, DT_VERS_1_11,
395 &dt_idops_func, "int64_t(const char *, [int])" },
396 { "substr", DT_IDENT_FUNC, 0, DIF_SUBR_SUBSTR, DT_ATTR_STABCMN, DT_VERS_1_1,
397 &dt_idops_func, "string(const char *, int, [int])" },
398 { "sum", DT_IDENT_AGGFUNC, 0, DTRACEAGG_SUM, DT_ATTR_STABCMN, DT_VERS_1_0,
399 &dt_idops_func, "void(@)" },
400 { "sym", DT_IDENT_ACTFUNC, 0, DT_ACT_SYM, DT_ATTR_STABCMN,
401 DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" },
402 { "system", DT_IDENT_ACTFUNC, 0, DT_ACT_SYSTEM, DT_ATTR_STABCMN, DT_VERS_1_0,
403 &dt_idops_func, "void(@, ...)" },
404 { "this", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0,
405 &dt_idops_type, "void" },
406 { "threadname", DT_IDENT_SCALAR, 0, DIF_VAR_THREADNAME,
407 DT_ATTR_STABCMN, DT_VERS_1_14, &dt_idops_type, "string" },
408 { "tid", DT_IDENT_SCALAR, 0, DIF_VAR_TID, DT_ATTR_STABCMN, DT_VERS_1_0,
409 &dt_idops_type, "id_t" },
410 { "timestamp", DT_IDENT_SCALAR, 0, DIF_VAR_TIMESTAMP,
411 DT_ATTR_STABCMN, DT_VERS_1_0,
412 &dt_idops_type, "uint64_t" },
413 { "tolower", DT_IDENT_FUNC, 0, DIF_SUBR_TOLOWER, DT_ATTR_STABCMN, DT_VERS_1_8,
414 &dt_idops_func, "string(const char *)" },
415 { "toupper", DT_IDENT_FUNC, 0, DIF_SUBR_TOUPPER, DT_ATTR_STABCMN, DT_VERS_1_8,
416 &dt_idops_func, "string(const char *)" },
417 { "trace", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACE, DT_ATTR_STABCMN, DT_VERS_1_0,
418 &dt_idops_func, "void(@)" },
419 { "tracemem", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACEMEM,
420 DT_ATTR_STABCMN, DT_VERS_1_0,
421 &dt_idops_func, "void(@, size_t, ...)" },
422 { "trunc", DT_IDENT_ACTFUNC, 0, DT_ACT_TRUNC, DT_ATTR_STABCMN,
423 DT_VERS_1_0, &dt_idops_func, "void(...)" },
424 { "uaddr", DT_IDENT_ACTFUNC, 0, DT_ACT_UADDR, DT_ATTR_STABCMN,
425 DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" },
426 { "ucaller", DT_IDENT_SCALAR, 0, DIF_VAR_UCALLER, DT_ATTR_STABCMN,
427 DT_VERS_1_2, &dt_idops_type, "uint64_t" },
|