xref: /onnv-gate/usr/src/lib/libdtrace/common/dt_ident.c (revision 13093:48f2dbca79a2)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51464Sahl  * Common Development and Distribution License (the "License").
61464Sahl  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211464Sahl 
220Sstevel@tonic-gate /*
23*13093SRoger.Faulkner@Oracle.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <sys/sysmacros.h>
270Sstevel@tonic-gate #include <strings.h>
280Sstevel@tonic-gate #include <stdlib.h>
290Sstevel@tonic-gate #include <alloca.h>
300Sstevel@tonic-gate #include <assert.h>
310Sstevel@tonic-gate #include <errno.h>
320Sstevel@tonic-gate #include <ctype.h>
330Sstevel@tonic-gate #include <sys/procfs_isa.h>
340Sstevel@tonic-gate #include <limits.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <dt_ident.h>
370Sstevel@tonic-gate #include <dt_parser.h>
380Sstevel@tonic-gate #include <dt_provider.h>
390Sstevel@tonic-gate #include <dt_strtab.h>
400Sstevel@tonic-gate #include <dt_impl.h>
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * Common code for cooking an identifier that uses a typed signature list (we
440Sstevel@tonic-gate  * use this for associative arrays and functions).  If the argument list is
450Sstevel@tonic-gate  * of the same length and types, then return the return type.  Otherwise
460Sstevel@tonic-gate  * print an appropriate compiler error message and abort the compile.
470Sstevel@tonic-gate  */
480Sstevel@tonic-gate static void
dt_idcook_sign(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * args,const char * prefix,const char * suffix)490Sstevel@tonic-gate dt_idcook_sign(dt_node_t *dnp, dt_ident_t *idp,
500Sstevel@tonic-gate     int argc, dt_node_t *args, const char *prefix, const char *suffix)
510Sstevel@tonic-gate {
520Sstevel@tonic-gate 	dt_idsig_t *isp = idp->di_data;
531017Sbmc 	int i, compat, mismatch, arglimit, iskey;
540Sstevel@tonic-gate 
550Sstevel@tonic-gate 	char n1[DT_TYPE_NAMELEN];
560Sstevel@tonic-gate 	char n2[DT_TYPE_NAMELEN];
570Sstevel@tonic-gate 
581017Sbmc 	iskey = idp->di_kind == DT_IDENT_ARRAY || idp->di_kind == DT_IDENT_AGG;
591017Sbmc 
600Sstevel@tonic-gate 	if (isp->dis_varargs >= 0) {
610Sstevel@tonic-gate 		mismatch = argc < isp->dis_varargs;
620Sstevel@tonic-gate 		arglimit = isp->dis_varargs;
630Sstevel@tonic-gate 	} else if (isp->dis_optargs >= 0) {
640Sstevel@tonic-gate 		mismatch = (argc < isp->dis_optargs || argc > isp->dis_argc);
650Sstevel@tonic-gate 		arglimit = argc;
660Sstevel@tonic-gate 	} else {
670Sstevel@tonic-gate 		mismatch = argc != isp->dis_argc;
680Sstevel@tonic-gate 		arglimit = isp->dis_argc;
690Sstevel@tonic-gate 	}
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	if (mismatch) {
721017Sbmc 		xyerror(D_PROTO_LEN, "%s%s%s prototype mismatch: %d %s%s"
730Sstevel@tonic-gate 		    "passed, %s%d expected\n", prefix, idp->di_name, suffix,
741017Sbmc 		    argc, iskey ? "key" : "arg", argc == 1 ? " " : "s ",
750Sstevel@tonic-gate 		    isp->dis_optargs >= 0 ? "at least " : "",
760Sstevel@tonic-gate 		    isp->dis_optargs >= 0 ? isp->dis_optargs : arglimit);
770Sstevel@tonic-gate 	}
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 	for (i = 0; i < arglimit; i++, args = args->dn_list) {
800Sstevel@tonic-gate 		if (isp->dis_args[i].dn_ctfp != NULL)
810Sstevel@tonic-gate 			compat = dt_node_is_argcompat(&isp->dis_args[i], args);
820Sstevel@tonic-gate 		else
830Sstevel@tonic-gate 			compat = 1; /* "@" matches any type */
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 		if (!compat) {
860Sstevel@tonic-gate 			xyerror(D_PROTO_ARG,
871017Sbmc 			    "%s%s%s %s #%d is incompatible with "
881017Sbmc 			    "prototype:\n\tprototype: %s\n\t%9s: %s\n",
891017Sbmc 			    prefix, idp->di_name, suffix,
901017Sbmc 			    iskey ? "key" : "argument", i + 1,
910Sstevel@tonic-gate 			    dt_node_type_name(&isp->dis_args[i], n1,
920Sstevel@tonic-gate 			    sizeof (n1)),
931017Sbmc 			    iskey ? "key" : "argument",
940Sstevel@tonic-gate 			    dt_node_type_name(args, n2, sizeof (n2)));
950Sstevel@tonic-gate 		}
960Sstevel@tonic-gate 	}
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 	dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
990Sstevel@tonic-gate }
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate /*
1020Sstevel@tonic-gate  * Cook an associative array identifier.  If this is the first time we are
1030Sstevel@tonic-gate  * cooking this array, create its signature based on the argument list.
1040Sstevel@tonic-gate  * Otherwise validate the argument list against the existing signature.
1050Sstevel@tonic-gate  */
1060Sstevel@tonic-gate static void
dt_idcook_assc(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * args)1070Sstevel@tonic-gate dt_idcook_assc(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
1080Sstevel@tonic-gate {
1090Sstevel@tonic-gate 	if (idp->di_data == NULL) {
1100Sstevel@tonic-gate 		dt_idsig_t *isp = idp->di_data = malloc(sizeof (dt_idsig_t));
1110Sstevel@tonic-gate 		char n[DT_TYPE_NAMELEN];
1120Sstevel@tonic-gate 		int i;
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate 		if (isp == NULL)
1150Sstevel@tonic-gate 			longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate 		isp->dis_varargs = -1;
1180Sstevel@tonic-gate 		isp->dis_optargs = -1;
1190Sstevel@tonic-gate 		isp->dis_argc = argc;
1200Sstevel@tonic-gate 		isp->dis_args = NULL;
1211017Sbmc 		isp->dis_auxinfo = 0;
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate 		if (argc != 0 && (isp->dis_args = calloc(argc,
1240Sstevel@tonic-gate 		    sizeof (dt_node_t))) == NULL) {
1250Sstevel@tonic-gate 			idp->di_data = NULL;
1260Sstevel@tonic-gate 			free(isp);
1270Sstevel@tonic-gate 			longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
1280Sstevel@tonic-gate 		}
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate 		/*
1310Sstevel@tonic-gate 		 * If this identifier has not been explicitly declared earlier,
1320Sstevel@tonic-gate 		 * set the identifier's base type to be our special type <DYN>.
1330Sstevel@tonic-gate 		 * If this ident is an aggregation, it will remain as is.  If
1340Sstevel@tonic-gate 		 * this ident is an associative array, it will be reassigned
1350Sstevel@tonic-gate 		 * based on the result type of the first assignment statement.
1360Sstevel@tonic-gate 		 */
1370Sstevel@tonic-gate 		if (!(idp->di_flags & DT_IDFLG_DECL)) {
1380Sstevel@tonic-gate 			idp->di_ctfp = DT_DYN_CTFP(yypcb->pcb_hdl);
1390Sstevel@tonic-gate 			idp->di_type = DT_DYN_TYPE(yypcb->pcb_hdl);
1400Sstevel@tonic-gate 		}
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate 		for (i = 0; i < argc; i++, args = args->dn_list) {
1430Sstevel@tonic-gate 			if (dt_node_is_dynamic(args) || dt_node_is_void(args)) {
1440Sstevel@tonic-gate 				xyerror(D_KEY_TYPE, "%s expression may not be "
1450Sstevel@tonic-gate 				    "used as %s index: key #%d\n",
1460Sstevel@tonic-gate 				    dt_node_type_name(args, n, sizeof (n)),
1470Sstevel@tonic-gate 				    dt_idkind_name(idp->di_kind), i + 1);
1480Sstevel@tonic-gate 			}
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate 			dt_node_type_propagate(args, &isp->dis_args[i]);
1510Sstevel@tonic-gate 			isp->dis_args[i].dn_list = &isp->dis_args[i + 1];
1520Sstevel@tonic-gate 		}
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 		if (argc != 0)
1550Sstevel@tonic-gate 			isp->dis_args[argc - 1].dn_list = NULL;
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate 		dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate 	} else {
1600Sstevel@tonic-gate 		dt_idcook_sign(dnp, idp, argc, args,
1610Sstevel@tonic-gate 		    idp->di_kind == DT_IDENT_AGG ? "@" : "", "[ ]");
1620Sstevel@tonic-gate 	}
1630Sstevel@tonic-gate }
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate /*
1660Sstevel@tonic-gate  * Cook a function call.  If this is the first time we are cooking this
1670Sstevel@tonic-gate  * identifier, create its type signature based on predefined prototype stored
1680Sstevel@tonic-gate  * in di_iarg.  We then validate the argument list against this signature.
1690Sstevel@tonic-gate  */
1700Sstevel@tonic-gate static void
dt_idcook_func(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * args)1710Sstevel@tonic-gate dt_idcook_func(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
1720Sstevel@tonic-gate {
1730Sstevel@tonic-gate 	if (idp->di_data == NULL) {
1740Sstevel@tonic-gate 		dtrace_hdl_t *dtp = yypcb->pcb_hdl;
1750Sstevel@tonic-gate 		dtrace_typeinfo_t dtt;
1760Sstevel@tonic-gate 		dt_idsig_t *isp;
1770Sstevel@tonic-gate 		char *s, *p1, *p2;
1780Sstevel@tonic-gate 		int i = 0;
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 		assert(idp->di_iarg != NULL);
181*13093SRoger.Faulkner@Oracle.COM 		s = strdupa(idp->di_iarg);
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate 		if ((p2 = strrchr(s, ')')) != NULL)
1840Sstevel@tonic-gate 			*p2 = '\0'; /* mark end of parameter list string */
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate 		if ((p1 = strchr(s, '(')) != NULL)
1870Sstevel@tonic-gate 			*p1++ = '\0'; /* mark end of return type string */
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate 		if (p1 == NULL || p2 == NULL) {
1900Sstevel@tonic-gate 			xyerror(D_UNKNOWN, "internal error: malformed entry "
1910Sstevel@tonic-gate 			    "for built-in function %s\n", idp->di_name);
1920Sstevel@tonic-gate 		}
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate 		for (p2 = p1; *p2 != '\0'; p2++) {
1950Sstevel@tonic-gate 			if (!isspace(*p2)) {
1960Sstevel@tonic-gate 				i++;
1970Sstevel@tonic-gate 				break;
1980Sstevel@tonic-gate 			}
1990Sstevel@tonic-gate 		}
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate 		for (p2 = strchr(p2, ','); p2++ != NULL; i++)
2020Sstevel@tonic-gate 			p2 = strchr(p2, ',');
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate 		/*
2050Sstevel@tonic-gate 		 * We first allocate a new ident signature structure with the
2060Sstevel@tonic-gate 		 * appropriate number of argument entries, and then look up
2070Sstevel@tonic-gate 		 * the return type and store its CTF data in di_ctfp/type.
2080Sstevel@tonic-gate 		 */
2090Sstevel@tonic-gate 		if ((isp = idp->di_data = malloc(sizeof (dt_idsig_t))) == NULL)
2100Sstevel@tonic-gate 			longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate 		isp->dis_varargs = -1;
2130Sstevel@tonic-gate 		isp->dis_optargs = -1;
2140Sstevel@tonic-gate 		isp->dis_argc = i;
2150Sstevel@tonic-gate 		isp->dis_args = NULL;
2161017Sbmc 		isp->dis_auxinfo = 0;
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate 		if (i != 0 && (isp->dis_args = calloc(i,
2190Sstevel@tonic-gate 		    sizeof (dt_node_t))) == NULL) {
2200Sstevel@tonic-gate 			idp->di_data = NULL;
2210Sstevel@tonic-gate 			free(isp);
2220Sstevel@tonic-gate 			longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2230Sstevel@tonic-gate 		}
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate 		if (dt_type_lookup(s, &dtt) == -1) {
2260Sstevel@tonic-gate 			xyerror(D_UNKNOWN, "failed to resolve type of %s (%s):"
2270Sstevel@tonic-gate 			    " %s\n", idp->di_name, s,
2280Sstevel@tonic-gate 			    dtrace_errmsg(dtp, dtrace_errno(dtp)));
2290Sstevel@tonic-gate 		}
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate 		if (idp->di_kind == DT_IDENT_AGGFUNC) {
2320Sstevel@tonic-gate 			idp->di_ctfp = DT_DYN_CTFP(dtp);
2330Sstevel@tonic-gate 			idp->di_type = DT_DYN_TYPE(dtp);
2340Sstevel@tonic-gate 		} else {
2350Sstevel@tonic-gate 			idp->di_ctfp = dtt.dtt_ctfp;
2360Sstevel@tonic-gate 			idp->di_type = dtt.dtt_type;
2370Sstevel@tonic-gate 		}
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate 		/*
2400Sstevel@tonic-gate 		 * For each comma-delimited parameter in the prototype string,
2410Sstevel@tonic-gate 		 * we look up the corresponding type and store its CTF data in
2420Sstevel@tonic-gate 		 * the corresponding location in dis_args[].  We also recognize
2430Sstevel@tonic-gate 		 * the special type string "@" to indicate that the specified
2440Sstevel@tonic-gate 		 * parameter may be a D expression of *any* type (represented
2450Sstevel@tonic-gate 		 * as a dis_args[] element with ctfp = NULL, type == CTF_ERR).
2460Sstevel@tonic-gate 		 * If a varargs "..." is present, we record the argument index
2470Sstevel@tonic-gate 		 * in dis_varargs for the benefit of dt_idcook_sign(), above.
2480Sstevel@tonic-gate 		 * If the type of an argument is enclosed in square brackets
2490Sstevel@tonic-gate 		 * (e.g. "[int]"), the argument is considered optional:  the
2500Sstevel@tonic-gate 		 * argument may be absent, but if it is present, it must be of
2510Sstevel@tonic-gate 		 * the specified type.  Note that varargs may not optional,
2520Sstevel@tonic-gate 		 * optional arguments may not follow varargs, and non-optional
2530Sstevel@tonic-gate 		 * arguments may not follow optional arguments.
2540Sstevel@tonic-gate 		 */
2550Sstevel@tonic-gate 		for (i = 0; i < isp->dis_argc; i++, p1 = p2) {
2560Sstevel@tonic-gate 			while (isspace(*p1))
2570Sstevel@tonic-gate 				p1++; /* skip leading whitespace */
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate 			if ((p2 = strchr(p1, ',')) == NULL)
2600Sstevel@tonic-gate 				p2 = p1 + strlen(p1);
2610Sstevel@tonic-gate 			else
2620Sstevel@tonic-gate 				*p2++ = '\0';
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate 			if (strcmp(p1, "@") == 0 || strcmp(p1, "...") == 0) {
2650Sstevel@tonic-gate 				isp->dis_args[i].dn_ctfp = NULL;
2660Sstevel@tonic-gate 				isp->dis_args[i].dn_type = CTF_ERR;
2670Sstevel@tonic-gate 				if (*p1 == '.')
2680Sstevel@tonic-gate 					isp->dis_varargs = i;
2690Sstevel@tonic-gate 				continue;
2700Sstevel@tonic-gate 			}
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate 			if (*p1 == '[' && p1[strlen(p1) - 1] == ']') {
2730Sstevel@tonic-gate 				if (isp->dis_varargs != -1) {
2740Sstevel@tonic-gate 					xyerror(D_UNKNOWN, "optional arg#%d "
2750Sstevel@tonic-gate 					    "may not follow variable arg#%d\n",
2760Sstevel@tonic-gate 					    i + 1, isp->dis_varargs + 1);
2770Sstevel@tonic-gate 				}
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate 				if (isp->dis_optargs == -1)
2800Sstevel@tonic-gate 					isp->dis_optargs = i;
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate 				p1[strlen(p1) - 1] = '\0';
2830Sstevel@tonic-gate 				p1++;
2840Sstevel@tonic-gate 			} else if (isp->dis_optargs != -1) {
2850Sstevel@tonic-gate 				xyerror(D_UNKNOWN, "required arg#%d may not "
2860Sstevel@tonic-gate 				    "follow optional arg#%d\n", i + 1,
2870Sstevel@tonic-gate 				    isp->dis_optargs + 1);
2880Sstevel@tonic-gate 			}
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate 			if (dt_type_lookup(p1, &dtt) == -1) {
2910Sstevel@tonic-gate 				xyerror(D_UNKNOWN, "failed to resolve type of "
2920Sstevel@tonic-gate 				    "%s arg#%d (%s): %s\n", idp->di_name, i + 1,
2930Sstevel@tonic-gate 				    p1, dtrace_errmsg(dtp, dtrace_errno(dtp)));
2940Sstevel@tonic-gate 			}
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 			dt_node_type_assign(&isp->dis_args[i],
2970Sstevel@tonic-gate 			    dtt.dtt_ctfp, dtt.dtt_type);
2980Sstevel@tonic-gate 		}
2990Sstevel@tonic-gate 	}
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate 	dt_idcook_sign(dnp, idp, argc, args, "", "( )");
3020Sstevel@tonic-gate }
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate /*
3050Sstevel@tonic-gate  * Cook a reference to the dynamically typed args[] array.  We verify that the
3060Sstevel@tonic-gate  * reference is using a single integer constant, and then construct a new ident
3070Sstevel@tonic-gate  * representing the appropriate type or translation specifically for this node.
3080Sstevel@tonic-gate  */
3090Sstevel@tonic-gate static void
dt_idcook_args(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * ap)3100Sstevel@tonic-gate dt_idcook_args(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)
3110Sstevel@tonic-gate {
3120Sstevel@tonic-gate 	dtrace_hdl_t *dtp = yypcb->pcb_hdl;
3130Sstevel@tonic-gate 	dt_probe_t *prp = yypcb->pcb_probe;
3140Sstevel@tonic-gate 
315265Smws 	dt_node_t tag, *nnp, *xnp;
3160Sstevel@tonic-gate 	dt_xlator_t *dxp;
3170Sstevel@tonic-gate 	dt_ident_t *xidp;
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate 	char n1[DT_TYPE_NAMELEN];
3200Sstevel@tonic-gate 	char n2[DT_TYPE_NAMELEN];
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate 	if (argc != 1) {
3230Sstevel@tonic-gate 		xyerror(D_PROTO_LEN, "%s[ ] prototype mismatch: %d arg%s"
3240Sstevel@tonic-gate 		    "passed, 1 expected\n", idp->di_name, argc,
3250Sstevel@tonic-gate 		    argc == 1 ? " " : "s ");
3260Sstevel@tonic-gate 	}
3270Sstevel@tonic-gate 
3280Sstevel@tonic-gate 	if (ap->dn_kind != DT_NODE_INT) {
3290Sstevel@tonic-gate 		xyerror(D_PROTO_ARG, "%s[ ] argument #1 is incompatible with "
3300Sstevel@tonic-gate 		    "prototype:\n\tprototype: %s\n\t argument: %s\n",
3310Sstevel@tonic-gate 		    idp->di_name, "integer constant",
3320Sstevel@tonic-gate 		    dt_type_name(ap->dn_ctfp, ap->dn_type, n1, sizeof (n1)));
3330Sstevel@tonic-gate 	}
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate 	if (yypcb->pcb_pdesc == NULL) {
3360Sstevel@tonic-gate 		xyerror(D_ARGS_NONE, "%s[ ] may not be referenced outside "
3370Sstevel@tonic-gate 		    "of a probe clause\n", idp->di_name);
3380Sstevel@tonic-gate 	}
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate 	if (prp == NULL) {
3410Sstevel@tonic-gate 		xyerror(D_ARGS_MULTI,
3420Sstevel@tonic-gate 		    "%s[ ] may not be referenced because probe description %s "
3430Sstevel@tonic-gate 		    "matches an unstable set of probes\n", idp->di_name,
3440Sstevel@tonic-gate 		    dtrace_desc2str(yypcb->pcb_pdesc, n1, sizeof (n1)));
3450Sstevel@tonic-gate 	}
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate 	if (ap->dn_value >= prp->pr_argc) {
3480Sstevel@tonic-gate 		xyerror(D_ARGS_IDX, "index %lld is out of range for %s %s[ ]\n",
3490Sstevel@tonic-gate 		    (longlong_t)ap->dn_value, dtrace_desc2str(yypcb->pcb_pdesc,
3500Sstevel@tonic-gate 		    n1, sizeof (n1)), idp->di_name);
3510Sstevel@tonic-gate 	}
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate 	/*
354265Smws 	 * Look up the native and translated argument types for the probe.
3550Sstevel@tonic-gate 	 * If no translation is needed, these will be the same underlying node.
3560Sstevel@tonic-gate 	 * If translation is needed, look up the appropriate translator.  Once
3570Sstevel@tonic-gate 	 * we have the appropriate node, create a new dt_ident_t for this node,
3580Sstevel@tonic-gate 	 * assign it the appropriate attributes, and set the type of 'dnp'.
3590Sstevel@tonic-gate 	 */
3600Sstevel@tonic-gate 	xnp = prp->pr_xargv[ap->dn_value];
3610Sstevel@tonic-gate 	nnp = prp->pr_nargv[prp->pr_mapping[ap->dn_value]];
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate 	if (xnp->dn_type == CTF_ERR) {
3640Sstevel@tonic-gate 		xyerror(D_ARGS_TYPE, "failed to resolve translated type for "
3650Sstevel@tonic-gate 		    "%s[%lld]\n", idp->di_name, (longlong_t)ap->dn_value);
3660Sstevel@tonic-gate 	}
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate 	if (nnp->dn_type == CTF_ERR) {
3690Sstevel@tonic-gate 		xyerror(D_ARGS_TYPE, "failed to resolve native type for "
3700Sstevel@tonic-gate 		    "%s[%lld]\n", idp->di_name, (longlong_t)ap->dn_value);
3710Sstevel@tonic-gate 	}
3720Sstevel@tonic-gate 
373265Smws 	if (dtp->dt_xlatemode == DT_XL_STATIC && (
374265Smws 	    nnp == xnp || dt_node_is_argcompat(nnp, xnp))) {
3750Sstevel@tonic-gate 		dnp->dn_ident = dt_ident_create(idp->di_name, idp->di_kind,
3760Sstevel@tonic-gate 		    idp->di_flags | DT_IDFLG_ORPHAN, idp->di_id, idp->di_attr,
377265Smws 		    idp->di_vers, idp->di_ops, idp->di_iarg, idp->di_gen);
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate 		if (dnp->dn_ident == NULL)
3800Sstevel@tonic-gate 			longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate 		dt_node_type_assign(dnp,
3830Sstevel@tonic-gate 		    prp->pr_argv[ap->dn_value].dtt_ctfp,
3840Sstevel@tonic-gate 		    prp->pr_argv[ap->dn_value].dtt_type);
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate 	} else if ((dxp = dt_xlator_lookup(dtp,
387265Smws 	    nnp, xnp, DT_XLATE_FUZZY)) != NULL || (
388265Smws 	    dxp = dt_xlator_lookup(dtp, dt_probe_tag(prp, ap->dn_value, &tag),
389265Smws 	    xnp, DT_XLATE_EXACT | DT_XLATE_EXTERN)) != NULL) {
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 		xidp = dt_xlator_ident(dxp, xnp->dn_ctfp, xnp->dn_type);
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate 		dnp->dn_ident = dt_ident_create(idp->di_name, xidp->di_kind,
3940Sstevel@tonic-gate 		    xidp->di_flags | DT_IDFLG_ORPHAN, idp->di_id, idp->di_attr,
395265Smws 		    idp->di_vers, idp->di_ops, idp->di_iarg, idp->di_gen);
3960Sstevel@tonic-gate 
3970Sstevel@tonic-gate 		if (dnp->dn_ident == NULL)
3980Sstevel@tonic-gate 			longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
3990Sstevel@tonic-gate 
400265Smws 		if (dt_xlator_dynamic(dxp))
401265Smws 			dxp->dx_arg = (int)ap->dn_value;
402265Smws 
4030Sstevel@tonic-gate 		/*
4040Sstevel@tonic-gate 		 * Propagate relevant members from the translator's internal
4050Sstevel@tonic-gate 		 * dt_ident_t.  This code must be kept in sync with the state
4060Sstevel@tonic-gate 		 * that is initialized for idents in dt_xlator_create().
4070Sstevel@tonic-gate 		 */
4080Sstevel@tonic-gate 		dnp->dn_ident->di_data = xidp->di_data;
4090Sstevel@tonic-gate 		dnp->dn_ident->di_ctfp = xidp->di_ctfp;
4100Sstevel@tonic-gate 		dnp->dn_ident->di_type = xidp->di_type;
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate 		dt_node_type_assign(dnp, DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate 	} else {
4150Sstevel@tonic-gate 		xyerror(D_ARGS_XLATOR, "translator for %s[%lld] from %s to %s "
4160Sstevel@tonic-gate 		    "is not defined\n", idp->di_name, (longlong_t)ap->dn_value,
4170Sstevel@tonic-gate 		    dt_node_type_name(nnp, n1, sizeof (n1)),
4180Sstevel@tonic-gate 		    dt_node_type_name(xnp, n2, sizeof (n2)));
4190Sstevel@tonic-gate 	}
4200Sstevel@tonic-gate 
4210Sstevel@tonic-gate 	assert(dnp->dn_ident->di_flags & DT_IDFLG_ORPHAN);
4220Sstevel@tonic-gate 	assert(dnp->dn_ident->di_id == idp->di_id);
4230Sstevel@tonic-gate }
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate static void
dt_idcook_regs(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * ap)4260Sstevel@tonic-gate dt_idcook_regs(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)
4270Sstevel@tonic-gate {
4280Sstevel@tonic-gate 	dtrace_typeinfo_t dtt;
4290Sstevel@tonic-gate 	dtrace_hdl_t *dtp = yypcb->pcb_hdl;
4300Sstevel@tonic-gate 	char n[DT_TYPE_NAMELEN];
4310Sstevel@tonic-gate 
4320Sstevel@tonic-gate 	if (argc != 1) {
4330Sstevel@tonic-gate 		xyerror(D_PROTO_LEN, "%s[ ] prototype mismatch: %d arg%s"
4340Sstevel@tonic-gate 		    "passed, 1 expected\n", idp->di_name,
4350Sstevel@tonic-gate 		    argc, argc == 1 ? " " : "s ");
4360Sstevel@tonic-gate 	}
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate 	if (ap->dn_kind != DT_NODE_INT) {
4390Sstevel@tonic-gate 		xyerror(D_PROTO_ARG, "%s[ ] argument #1 is incompatible with "
4400Sstevel@tonic-gate 		    "prototype:\n\tprototype: %s\n\t argument: %s\n",
4410Sstevel@tonic-gate 		    idp->di_name, "integer constant",
4420Sstevel@tonic-gate 		    dt_type_name(ap->dn_ctfp, ap->dn_type, n, sizeof (n)));
4430Sstevel@tonic-gate 	}
4440Sstevel@tonic-gate 
4450Sstevel@tonic-gate 	if ((ap->dn_flags & DT_NF_SIGNED) && (int64_t)ap->dn_value < 0) {
4460Sstevel@tonic-gate 		xyerror(D_REGS_IDX, "index %lld is out of range for array %s\n",
4470Sstevel@tonic-gate 		    (longlong_t)ap->dn_value, idp->di_name);
4480Sstevel@tonic-gate 	}
4490Sstevel@tonic-gate 
4500Sstevel@tonic-gate 	if (dt_type_lookup("uint64_t", &dtt) == -1) {
4510Sstevel@tonic-gate 		xyerror(D_UNKNOWN, "failed to resolve type of %s: %s\n",
4520Sstevel@tonic-gate 		    idp->di_name, dtrace_errmsg(dtp, dtrace_errno(dtp)));
4530Sstevel@tonic-gate 	}
4540Sstevel@tonic-gate 
4550Sstevel@tonic-gate 	idp->di_ctfp = dtt.dtt_ctfp;
4560Sstevel@tonic-gate 	idp->di_type = dtt.dtt_type;
4570Sstevel@tonic-gate 
4580Sstevel@tonic-gate 	dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
4590Sstevel@tonic-gate }
4600Sstevel@tonic-gate 
4610Sstevel@tonic-gate /*ARGSUSED*/
4620Sstevel@tonic-gate static void
dt_idcook_type(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * args)4630Sstevel@tonic-gate dt_idcook_type(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
4640Sstevel@tonic-gate {
4650Sstevel@tonic-gate 	if (idp->di_type == CTF_ERR) {
4660Sstevel@tonic-gate 		dtrace_hdl_t *dtp = yypcb->pcb_hdl;
4670Sstevel@tonic-gate 		dtrace_typeinfo_t dtt;
4680Sstevel@tonic-gate 
4690Sstevel@tonic-gate 		if (dt_type_lookup(idp->di_iarg, &dtt) == -1) {
4700Sstevel@tonic-gate 			xyerror(D_UNKNOWN,
4710Sstevel@tonic-gate 			    "failed to resolve type %s for identifier %s: %s\n",
4720Sstevel@tonic-gate 			    (const char *)idp->di_iarg, idp->di_name,
4730Sstevel@tonic-gate 			    dtrace_errmsg(dtp, dtrace_errno(dtp)));
4740Sstevel@tonic-gate 		}
4750Sstevel@tonic-gate 
4760Sstevel@tonic-gate 		idp->di_ctfp = dtt.dtt_ctfp;
4770Sstevel@tonic-gate 		idp->di_type = dtt.dtt_type;
4780Sstevel@tonic-gate 	}
4790Sstevel@tonic-gate 
4800Sstevel@tonic-gate 	dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
4810Sstevel@tonic-gate }
4820Sstevel@tonic-gate 
4830Sstevel@tonic-gate /*ARGSUSED*/
4840Sstevel@tonic-gate static void
dt_idcook_thaw(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * args)4850Sstevel@tonic-gate dt_idcook_thaw(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
4860Sstevel@tonic-gate {
4870Sstevel@tonic-gate 	if (idp->di_ctfp != NULL && idp->di_type != CTF_ERR)
4880Sstevel@tonic-gate 		dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
4890Sstevel@tonic-gate }
4900Sstevel@tonic-gate 
4910Sstevel@tonic-gate static void
dt_idcook_inline(dt_node_t * dnp,dt_ident_t * idp,int argc,dt_node_t * args)4920Sstevel@tonic-gate dt_idcook_inline(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
4930Sstevel@tonic-gate {
4940Sstevel@tonic-gate 	if (idp->di_kind == DT_IDENT_ARRAY)
4950Sstevel@tonic-gate 		dt_idcook_assc(dnp, idp, argc, args);
4960Sstevel@tonic-gate 	else
4970Sstevel@tonic-gate 		dt_idcook_thaw(dnp, idp, argc, args);
4980Sstevel@tonic-gate }
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate static void
dt_iddtor_sign(dt_ident_t * idp)5010Sstevel@tonic-gate dt_iddtor_sign(dt_ident_t *idp)
5020Sstevel@tonic-gate {
5030Sstevel@tonic-gate 	if (idp->di_data != NULL)
5040Sstevel@tonic-gate 		free(((dt_idsig_t *)idp->di_data)->dis_args);
5050Sstevel@tonic-gate 	free(idp->di_data);
5060Sstevel@tonic-gate }
5070Sstevel@tonic-gate 
5080Sstevel@tonic-gate static void
dt_iddtor_free(dt_ident_t * idp)5090Sstevel@tonic-gate dt_iddtor_free(dt_ident_t *idp)
5100Sstevel@tonic-gate {
5110Sstevel@tonic-gate 	free(idp->di_data);
5120Sstevel@tonic-gate }
5130Sstevel@tonic-gate 
5140Sstevel@tonic-gate static void
dt_iddtor_inline(dt_ident_t * idp)5150Sstevel@tonic-gate dt_iddtor_inline(dt_ident_t *idp)
5160Sstevel@tonic-gate {
5170Sstevel@tonic-gate 	dt_idnode_t *inp = idp->di_iarg;
5180Sstevel@tonic-gate 
5190Sstevel@tonic-gate 	if (inp != NULL) {
5200Sstevel@tonic-gate 		dt_node_link_free(&inp->din_list);
5210Sstevel@tonic-gate 
5220Sstevel@tonic-gate 		if (inp->din_hash != NULL)
5230Sstevel@tonic-gate 			dt_idhash_destroy(inp->din_hash);
5240Sstevel@tonic-gate 
5250Sstevel@tonic-gate 		free(inp->din_argv);
5260Sstevel@tonic-gate 		free(inp);
5270Sstevel@tonic-gate 	}
5280Sstevel@tonic-gate 
5290Sstevel@tonic-gate 	if (idp->di_kind == DT_IDENT_ARRAY)
5300Sstevel@tonic-gate 		dt_iddtor_sign(idp);
5310Sstevel@tonic-gate 	else
5320Sstevel@tonic-gate 		dt_iddtor_free(idp);
5330Sstevel@tonic-gate }
5340Sstevel@tonic-gate 
5350Sstevel@tonic-gate /*ARGSUSED*/
5360Sstevel@tonic-gate static void
dt_iddtor_none(dt_ident_t * idp)5370Sstevel@tonic-gate dt_iddtor_none(dt_ident_t *idp)
5380Sstevel@tonic-gate {
5390Sstevel@tonic-gate 	/* do nothing */
5400Sstevel@tonic-gate }
5410Sstevel@tonic-gate 
5420Sstevel@tonic-gate static void
dt_iddtor_probe(dt_ident_t * idp)5430Sstevel@tonic-gate dt_iddtor_probe(dt_ident_t *idp)
5440Sstevel@tonic-gate {
5450Sstevel@tonic-gate 	if (idp->di_data != NULL)
5460Sstevel@tonic-gate 		dt_probe_destroy(idp->di_data);
5470Sstevel@tonic-gate }
5480Sstevel@tonic-gate 
5490Sstevel@tonic-gate static size_t
dt_idsize_type(dt_ident_t * idp)5500Sstevel@tonic-gate dt_idsize_type(dt_ident_t *idp)
5510Sstevel@tonic-gate {
5520Sstevel@tonic-gate 	return (ctf_type_size(idp->di_ctfp, idp->di_type));
5530Sstevel@tonic-gate }
5540Sstevel@tonic-gate 
5550Sstevel@tonic-gate /*ARGSUSED*/
5560Sstevel@tonic-gate static size_t
dt_idsize_none(dt_ident_t * idp)5570Sstevel@tonic-gate dt_idsize_none(dt_ident_t *idp)
5580Sstevel@tonic-gate {
5590Sstevel@tonic-gate 	return (0);
5600Sstevel@tonic-gate }
5610Sstevel@tonic-gate 
5620Sstevel@tonic-gate const dt_idops_t dt_idops_assc = {
5630Sstevel@tonic-gate 	dt_idcook_assc,
5640Sstevel@tonic-gate 	dt_iddtor_sign,
5650Sstevel@tonic-gate 	dt_idsize_none,
5660Sstevel@tonic-gate };
5670Sstevel@tonic-gate 
5680Sstevel@tonic-gate const dt_idops_t dt_idops_func = {
5690Sstevel@tonic-gate 	dt_idcook_func,
5700Sstevel@tonic-gate 	dt_iddtor_sign,
5710Sstevel@tonic-gate 	dt_idsize_none,
5720Sstevel@tonic-gate };
5730Sstevel@tonic-gate 
5740Sstevel@tonic-gate const dt_idops_t dt_idops_args = {
5750Sstevel@tonic-gate 	dt_idcook_args,
5760Sstevel@tonic-gate 	dt_iddtor_none,
5770Sstevel@tonic-gate 	dt_idsize_none,
5780Sstevel@tonic-gate };
5790Sstevel@tonic-gate 
5800Sstevel@tonic-gate const dt_idops_t dt_idops_regs = {
5810Sstevel@tonic-gate 	dt_idcook_regs,
5820Sstevel@tonic-gate 	dt_iddtor_free,
5830Sstevel@tonic-gate 	dt_idsize_none,
5840Sstevel@tonic-gate };
5850Sstevel@tonic-gate 
5860Sstevel@tonic-gate const dt_idops_t dt_idops_type = {
5870Sstevel@tonic-gate 	dt_idcook_type,
5880Sstevel@tonic-gate 	dt_iddtor_free,
5890Sstevel@tonic-gate 	dt_idsize_type,
5900Sstevel@tonic-gate };
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate const dt_idops_t dt_idops_thaw = {
5930Sstevel@tonic-gate 	dt_idcook_thaw,
5940Sstevel@tonic-gate 	dt_iddtor_free,
5950Sstevel@tonic-gate 	dt_idsize_type,
5960Sstevel@tonic-gate };
5970Sstevel@tonic-gate 
5980Sstevel@tonic-gate const dt_idops_t dt_idops_inline = {
5990Sstevel@tonic-gate 	dt_idcook_inline,
6000Sstevel@tonic-gate 	dt_iddtor_inline,
6010Sstevel@tonic-gate 	dt_idsize_type,
6020Sstevel@tonic-gate };
6030Sstevel@tonic-gate 
6040Sstevel@tonic-gate const dt_idops_t dt_idops_probe = {
6050Sstevel@tonic-gate 	dt_idcook_thaw,
6060Sstevel@tonic-gate 	dt_iddtor_probe,
6070Sstevel@tonic-gate 	dt_idsize_none,
6080Sstevel@tonic-gate };
6090Sstevel@tonic-gate 
6100Sstevel@tonic-gate static void
dt_idhash_populate(dt_idhash_t * dhp)6110Sstevel@tonic-gate dt_idhash_populate(dt_idhash_t *dhp)
6120Sstevel@tonic-gate {
6130Sstevel@tonic-gate 	const dt_ident_t *idp = dhp->dh_tmpl;
6140Sstevel@tonic-gate 
6150Sstevel@tonic-gate 	dhp->dh_tmpl = NULL; /* clear dh_tmpl first to avoid recursion */
6160Sstevel@tonic-gate 	dt_dprintf("populating %s idhash from %p\n", dhp->dh_name, (void *)idp);
6170Sstevel@tonic-gate 
6180Sstevel@tonic-gate 	for (; idp->di_name != NULL; idp++) {
6190Sstevel@tonic-gate 		if (dt_idhash_insert(dhp, idp->di_name,
6200Sstevel@tonic-gate 		    idp->di_kind, idp->di_flags, idp->di_id, idp->di_attr,
6210Sstevel@tonic-gate 		    idp->di_vers, idp->di_ops ? idp->di_ops : &dt_idops_thaw,
6220Sstevel@tonic-gate 		    idp->di_iarg, 0) == NULL)
6230Sstevel@tonic-gate 			longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
6240Sstevel@tonic-gate 	}
6250Sstevel@tonic-gate }
6260Sstevel@tonic-gate 
6270Sstevel@tonic-gate dt_idhash_t *
dt_idhash_create(const char * name,const dt_ident_t * tmpl,uint_t min,uint_t max)6280Sstevel@tonic-gate dt_idhash_create(const char *name, const dt_ident_t *tmpl,
6290Sstevel@tonic-gate     uint_t min, uint_t max)
6300Sstevel@tonic-gate {
6310Sstevel@tonic-gate 	dt_idhash_t *dhp;
6320Sstevel@tonic-gate 	size_t size;
6330Sstevel@tonic-gate 
6340Sstevel@tonic-gate 	assert(min <= max);
6350Sstevel@tonic-gate 
6360Sstevel@tonic-gate 	size = sizeof (dt_idhash_t) +
6370Sstevel@tonic-gate 	    sizeof (dt_ident_t *) * (_dtrace_strbuckets - 1);
6380Sstevel@tonic-gate 
6390Sstevel@tonic-gate 	if ((dhp = malloc(size)) == NULL)
6400Sstevel@tonic-gate 		return (NULL);
6410Sstevel@tonic-gate 
6420Sstevel@tonic-gate 	bzero(dhp, size);
6430Sstevel@tonic-gate 	dhp->dh_name = name;
6440Sstevel@tonic-gate 	dhp->dh_tmpl = tmpl;
6450Sstevel@tonic-gate 	dhp->dh_nextid = min;
6460Sstevel@tonic-gate 	dhp->dh_minid = min;
6470Sstevel@tonic-gate 	dhp->dh_maxid = max;
6480Sstevel@tonic-gate 	dhp->dh_hashsz = _dtrace_strbuckets;
6490Sstevel@tonic-gate 
6500Sstevel@tonic-gate 	return (dhp);
6510Sstevel@tonic-gate }
6520Sstevel@tonic-gate 
6530Sstevel@tonic-gate /*
6540Sstevel@tonic-gate  * Destroy an entire identifier hash.  This must be done using two passes with
6550Sstevel@tonic-gate  * an inlined version of dt_ident_destroy() to avoid referencing freed memory.
6560Sstevel@tonic-gate  * In the first pass di_dtor() is called for all identifiers; then the second
6570Sstevel@tonic-gate  * pass frees the actual dt_ident_t's.  These must be done separately because
6580Sstevel@tonic-gate  * a di_dtor() may operate on data structures which contain references to other
6590Sstevel@tonic-gate  * identifiers inside of this hash itself (e.g. a global inline definition
6600Sstevel@tonic-gate  * which contains a parse tree that refers to another global variable).
6610Sstevel@tonic-gate  */
6620Sstevel@tonic-gate void
dt_idhash_destroy(dt_idhash_t * dhp)6630Sstevel@tonic-gate dt_idhash_destroy(dt_idhash_t *dhp)
6640Sstevel@tonic-gate {
6650Sstevel@tonic-gate 	dt_ident_t *idp, *next;
6660Sstevel@tonic-gate 	ulong_t i;
6670Sstevel@tonic-gate 
6680Sstevel@tonic-gate 	for (i = 0; i < dhp->dh_hashsz; i++) {
6690Sstevel@tonic-gate 		for (idp = dhp->dh_hash[i]; idp != NULL; idp = next) {
6700Sstevel@tonic-gate 			next = idp->di_next;
6710Sstevel@tonic-gate 			idp->di_ops->di_dtor(idp);
6720Sstevel@tonic-gate 		}
6730Sstevel@tonic-gate 	}
6740Sstevel@tonic-gate 
6750Sstevel@tonic-gate 	for (i = 0; i < dhp->dh_hashsz; i++) {
6760Sstevel@tonic-gate 		for (idp = dhp->dh_hash[i]; idp != NULL; idp = next) {
6770Sstevel@tonic-gate 			next = idp->di_next;
6780Sstevel@tonic-gate 			free(idp->di_name);
6790Sstevel@tonic-gate 			free(idp);
6800Sstevel@tonic-gate 		}
6810Sstevel@tonic-gate 	}
6820Sstevel@tonic-gate 
6830Sstevel@tonic-gate 	free(dhp);
6840Sstevel@tonic-gate }
6850Sstevel@tonic-gate 
6860Sstevel@tonic-gate void
dt_idhash_update(dt_idhash_t * dhp)6870Sstevel@tonic-gate dt_idhash_update(dt_idhash_t *dhp)
6880Sstevel@tonic-gate {
6890Sstevel@tonic-gate 	uint_t nextid = dhp->dh_minid;
6900Sstevel@tonic-gate 	dt_ident_t *idp;
6910Sstevel@tonic-gate 	ulong_t i;
6920Sstevel@tonic-gate 
6930Sstevel@tonic-gate 	for (i = 0; i < dhp->dh_hashsz; i++) {
6940Sstevel@tonic-gate 		for (idp = dhp->dh_hash[i]; idp != NULL; idp = idp->di_next) {
6951464Sahl 			/*
6961464Sahl 			 * Right now we're hard coding which types need to be
6971464Sahl 			 * reset, but ideally this would be done dynamically.
6981464Sahl 			 */
6990Sstevel@tonic-gate 			if (idp->di_kind == DT_IDENT_ARRAY ||
7001464Sahl 			    idp->di_kind == DT_IDENT_SCALAR ||
7011464Sahl 			    idp->di_kind == DT_IDENT_AGG)
7020Sstevel@tonic-gate 				nextid = MAX(nextid, idp->di_id + 1);
7030Sstevel@tonic-gate 		}
7040Sstevel@tonic-gate 	}
7050Sstevel@tonic-gate 
7060Sstevel@tonic-gate 	dhp->dh_nextid = nextid;
7070Sstevel@tonic-gate }
7080Sstevel@tonic-gate 
7090Sstevel@tonic-gate dt_ident_t *
dt_idhash_lookup(dt_idhash_t * dhp,const char * name)7100Sstevel@tonic-gate dt_idhash_lookup(dt_idhash_t *dhp, const char *name)
7110Sstevel@tonic-gate {
7120Sstevel@tonic-gate 	size_t len;
7130Sstevel@tonic-gate 	ulong_t h = dt_strtab_hash(name, &len) % dhp->dh_hashsz;
7140Sstevel@tonic-gate 	dt_ident_t *idp;
7150Sstevel@tonic-gate 
7160Sstevel@tonic-gate 	if (dhp->dh_tmpl != NULL)
7170Sstevel@tonic-gate 		dt_idhash_populate(dhp); /* fill hash w/ initial population */
7180Sstevel@tonic-gate 
7190Sstevel@tonic-gate 	for (idp = dhp->dh_hash[h]; idp != NULL; idp = idp->di_next) {
7200Sstevel@tonic-gate 		if (strcmp(idp->di_name, name) == 0)
7210Sstevel@tonic-gate 			return (idp);
7220Sstevel@tonic-gate 	}
7230Sstevel@tonic-gate 
7240Sstevel@tonic-gate 	return (NULL);
7250Sstevel@tonic-gate }
7260Sstevel@tonic-gate 
7270Sstevel@tonic-gate int
dt_idhash_nextid(dt_idhash_t * dhp,uint_t * p)7280Sstevel@tonic-gate dt_idhash_nextid(dt_idhash_t *dhp, uint_t *p)
7290Sstevel@tonic-gate {
7300Sstevel@tonic-gate 	if (dhp->dh_nextid >= dhp->dh_maxid)
7310Sstevel@tonic-gate 		return (-1); /* no more id's are free to allocate */
7320Sstevel@tonic-gate 
7330Sstevel@tonic-gate 	*p = dhp->dh_nextid++;
7340Sstevel@tonic-gate 	return (0);
7350Sstevel@tonic-gate }
7360Sstevel@tonic-gate 
7370Sstevel@tonic-gate ulong_t
dt_idhash_size(const dt_idhash_t * dhp)7380Sstevel@tonic-gate dt_idhash_size(const dt_idhash_t *dhp)
7390Sstevel@tonic-gate {
7400Sstevel@tonic-gate 	return (dhp->dh_nelems);
7410Sstevel@tonic-gate }
7420Sstevel@tonic-gate 
7430Sstevel@tonic-gate const char *
dt_idhash_name(const dt_idhash_t * dhp)7440Sstevel@tonic-gate dt_idhash_name(const dt_idhash_t *dhp)
7450Sstevel@tonic-gate {
7460Sstevel@tonic-gate 	return (dhp->dh_name);
7470Sstevel@tonic-gate }
7480Sstevel@tonic-gate 
7490Sstevel@tonic-gate dt_ident_t *
dt_idhash_insert(dt_idhash_t * dhp,const char * name,ushort_t kind,ushort_t flags,uint_t id,dtrace_attribute_t attr,uint_t vers,const dt_idops_t * ops,void * iarg,ulong_t gen)7500Sstevel@tonic-gate dt_idhash_insert(dt_idhash_t *dhp, const char *name, ushort_t kind,
7510Sstevel@tonic-gate     ushort_t flags, uint_t id, dtrace_attribute_t attr, uint_t vers,
7520Sstevel@tonic-gate     const dt_idops_t *ops, void *iarg, ulong_t gen)
7530Sstevel@tonic-gate {
7540Sstevel@tonic-gate 	dt_ident_t *idp;
7550Sstevel@tonic-gate 	ulong_t h;
7560Sstevel@tonic-gate 
7570Sstevel@tonic-gate 	if (dhp->dh_tmpl != NULL)
7580Sstevel@tonic-gate 		dt_idhash_populate(dhp); /* fill hash w/ initial population */
7590Sstevel@tonic-gate 
7600Sstevel@tonic-gate 	idp = dt_ident_create(name, kind, flags, id,
7610Sstevel@tonic-gate 	    attr, vers, ops, iarg, gen);
7620Sstevel@tonic-gate 
7630Sstevel@tonic-gate 	if (idp == NULL)
7640Sstevel@tonic-gate 		return (NULL);
7650Sstevel@tonic-gate 
7660Sstevel@tonic-gate 	h = dt_strtab_hash(name, NULL) % dhp->dh_hashsz;
7670Sstevel@tonic-gate 	idp->di_next = dhp->dh_hash[h];
7680Sstevel@tonic-gate 
7690Sstevel@tonic-gate 	dhp->dh_hash[h] = idp;
7700Sstevel@tonic-gate 	dhp->dh_nelems++;
7710Sstevel@tonic-gate 
7720Sstevel@tonic-gate 	if (dhp->dh_defer != NULL)
7730Sstevel@tonic-gate 		dhp->dh_defer(dhp, idp);
7740Sstevel@tonic-gate 
7750Sstevel@tonic-gate 	return (idp);
7760Sstevel@tonic-gate }
7770Sstevel@tonic-gate 
7780Sstevel@tonic-gate void
dt_idhash_xinsert(dt_idhash_t * dhp,dt_ident_t * idp)7790Sstevel@tonic-gate dt_idhash_xinsert(dt_idhash_t *dhp, dt_ident_t *idp)
7800Sstevel@tonic-gate {
7810Sstevel@tonic-gate 	ulong_t h;
7820Sstevel@tonic-gate 
7830Sstevel@tonic-gate 	if (dhp->dh_tmpl != NULL)
7840Sstevel@tonic-gate 		dt_idhash_populate(dhp); /* fill hash w/ initial population */
7850Sstevel@tonic-gate 
7860Sstevel@tonic-gate 	h = dt_strtab_hash(idp->di_name, NULL) % dhp->dh_hashsz;
7870Sstevel@tonic-gate 	idp->di_next = dhp->dh_hash[h];
7880Sstevel@tonic-gate 	idp->di_flags &= ~DT_IDFLG_ORPHAN;
7890Sstevel@tonic-gate 
7900Sstevel@tonic-gate 	dhp->dh_hash[h] = idp;
7910Sstevel@tonic-gate 	dhp->dh_nelems++;
7920Sstevel@tonic-gate 
7930Sstevel@tonic-gate 	if (dhp->dh_defer != NULL)
7940Sstevel@tonic-gate 		dhp->dh_defer(dhp, idp);
7950Sstevel@tonic-gate }
7960Sstevel@tonic-gate 
7970Sstevel@tonic-gate void
dt_idhash_delete(dt_idhash_t * dhp,dt_ident_t * key)7980Sstevel@tonic-gate dt_idhash_delete(dt_idhash_t *dhp, dt_ident_t *key)
7990Sstevel@tonic-gate {
8000Sstevel@tonic-gate 	size_t len;
8010Sstevel@tonic-gate 	ulong_t h = dt_strtab_hash(key->di_name, &len) % dhp->dh_hashsz;
8020Sstevel@tonic-gate 	dt_ident_t **pp = &dhp->dh_hash[h];
8030Sstevel@tonic-gate 	dt_ident_t *idp;
8040Sstevel@tonic-gate 
8050Sstevel@tonic-gate 	for (idp = dhp->dh_hash[h]; idp != NULL; idp = idp->di_next) {
8060Sstevel@tonic-gate 		if (idp == key)
8070Sstevel@tonic-gate 			break;
8080Sstevel@tonic-gate 		else
8090Sstevel@tonic-gate 			pp = &idp->di_next;
8100Sstevel@tonic-gate 	}
8110Sstevel@tonic-gate 
8120Sstevel@tonic-gate 	assert(idp == key);
8130Sstevel@tonic-gate 	*pp = idp->di_next;
8140Sstevel@tonic-gate 
8150Sstevel@tonic-gate 	assert(dhp->dh_nelems != 0);
8160Sstevel@tonic-gate 	dhp->dh_nelems--;
8170Sstevel@tonic-gate 
818265Smws 	if (!(idp->di_flags & DT_IDFLG_ORPHAN))
819265Smws 		dt_ident_destroy(idp);
8200Sstevel@tonic-gate }
8210Sstevel@tonic-gate 
8220Sstevel@tonic-gate static int
dt_idhash_comp(const void * lp,const void * rp)8230Sstevel@tonic-gate dt_idhash_comp(const void *lp, const void *rp)
8240Sstevel@tonic-gate {
8250Sstevel@tonic-gate 	const dt_ident_t *lhs = *((const dt_ident_t **)lp);
8260Sstevel@tonic-gate 	const dt_ident_t *rhs = *((const dt_ident_t **)rp);
8270Sstevel@tonic-gate 
8280Sstevel@tonic-gate 	if (lhs->di_id != rhs->di_id)
8290Sstevel@tonic-gate 		return ((int)(lhs->di_id - rhs->di_id));
8300Sstevel@tonic-gate 	else
8310Sstevel@tonic-gate 		return (strcmp(lhs->di_name, rhs->di_name));
8320Sstevel@tonic-gate }
8330Sstevel@tonic-gate 
8340Sstevel@tonic-gate int
dt_idhash_iter(dt_idhash_t * dhp,dt_idhash_f * func,void * data)8350Sstevel@tonic-gate dt_idhash_iter(dt_idhash_t *dhp, dt_idhash_f *func, void *data)
8360Sstevel@tonic-gate {
8370Sstevel@tonic-gate 	dt_ident_t **ids;
8380Sstevel@tonic-gate 	dt_ident_t *idp;
8394568Sahl 	ulong_t i, j, n;
8400Sstevel@tonic-gate 	int rv;
8410Sstevel@tonic-gate 
8420Sstevel@tonic-gate 	if (dhp->dh_tmpl != NULL)
8430Sstevel@tonic-gate 		dt_idhash_populate(dhp); /* fill hash w/ initial population */
8440Sstevel@tonic-gate 
8454568Sahl 	n = dhp->dh_nelems;
8464568Sahl 	ids = alloca(sizeof (dt_ident_t *) * n);
8470Sstevel@tonic-gate 
8480Sstevel@tonic-gate 	for (i = 0, j = 0; i < dhp->dh_hashsz; i++) {
8490Sstevel@tonic-gate 		for (idp = dhp->dh_hash[i]; idp != NULL; idp = idp->di_next)
8500Sstevel@tonic-gate 			ids[j++] = idp;
8510Sstevel@tonic-gate 	}
8520Sstevel@tonic-gate 
8530Sstevel@tonic-gate 	qsort(ids, dhp->dh_nelems, sizeof (dt_ident_t *), dt_idhash_comp);
8540Sstevel@tonic-gate 
8554568Sahl 	for (i = 0; i < n; i++) {
8560Sstevel@tonic-gate 		if ((rv = func(dhp, ids[i], data)) != 0)
8570Sstevel@tonic-gate 			return (rv);
8580Sstevel@tonic-gate 	}
8590Sstevel@tonic-gate 
8600Sstevel@tonic-gate 	return (0);
8610Sstevel@tonic-gate }
8620Sstevel@tonic-gate 
8630Sstevel@tonic-gate dt_ident_t *
dt_idstack_lookup(dt_idstack_t * sp,const char * name)8640Sstevel@tonic-gate dt_idstack_lookup(dt_idstack_t *sp, const char *name)
8650Sstevel@tonic-gate {
8660Sstevel@tonic-gate 	dt_idhash_t *dhp;
8670Sstevel@tonic-gate 	dt_ident_t *idp;
8680Sstevel@tonic-gate 
8690Sstevel@tonic-gate 	for (dhp = dt_list_prev(&sp->dids_list);
8700Sstevel@tonic-gate 	    dhp != NULL; dhp = dt_list_prev(dhp)) {
8710Sstevel@tonic-gate 		if ((idp = dt_idhash_lookup(dhp, name)) != NULL)
8720Sstevel@tonic-gate 			return (idp);
8730Sstevel@tonic-gate 	}
8740Sstevel@tonic-gate 
8750Sstevel@tonic-gate 	return (NULL);
8760Sstevel@tonic-gate }
8770Sstevel@tonic-gate 
8780Sstevel@tonic-gate void
dt_idstack_push(dt_idstack_t * sp,dt_idhash_t * dhp)8790Sstevel@tonic-gate dt_idstack_push(dt_idstack_t *sp, dt_idhash_t *dhp)
8800Sstevel@tonic-gate {
8810Sstevel@tonic-gate 	dt_list_append(&sp->dids_list, dhp);
8820Sstevel@tonic-gate }
8830Sstevel@tonic-gate 
8840Sstevel@tonic-gate void
dt_idstack_pop(dt_idstack_t * sp,dt_idhash_t * dhp)8850Sstevel@tonic-gate dt_idstack_pop(dt_idstack_t *sp, dt_idhash_t *dhp)
8860Sstevel@tonic-gate {
8870Sstevel@tonic-gate 	assert(dt_list_prev(&sp->dids_list) == dhp);
8880Sstevel@tonic-gate 	dt_list_delete(&sp->dids_list, dhp);
8890Sstevel@tonic-gate }
8900Sstevel@tonic-gate 
8910Sstevel@tonic-gate dt_ident_t *
dt_ident_create(const char * name,ushort_t kind,ushort_t flags,uint_t id,dtrace_attribute_t attr,uint_t vers,const dt_idops_t * ops,void * iarg,ulong_t gen)8920Sstevel@tonic-gate dt_ident_create(const char *name, ushort_t kind, ushort_t flags, uint_t id,
8930Sstevel@tonic-gate     dtrace_attribute_t attr, uint_t vers,
8940Sstevel@tonic-gate     const dt_idops_t *ops, void *iarg, ulong_t gen)
8950Sstevel@tonic-gate {
8960Sstevel@tonic-gate 	dt_ident_t *idp;
8970Sstevel@tonic-gate 	char *s = NULL;
8980Sstevel@tonic-gate 
8990Sstevel@tonic-gate 	if ((name != NULL && (s = strdup(name)) == NULL) ||
9000Sstevel@tonic-gate 	    (idp = malloc(sizeof (dt_ident_t))) == NULL) {
9010Sstevel@tonic-gate 		free(s);
9020Sstevel@tonic-gate 		return (NULL);
9030Sstevel@tonic-gate 	}
9040Sstevel@tonic-gate 
9050Sstevel@tonic-gate 	idp->di_name = s;
9060Sstevel@tonic-gate 	idp->di_kind = kind;
9070Sstevel@tonic-gate 	idp->di_flags = flags;
9080Sstevel@tonic-gate 	idp->di_id = id;
9090Sstevel@tonic-gate 	idp->di_attr = attr;
9100Sstevel@tonic-gate 	idp->di_vers = vers;
9110Sstevel@tonic-gate 	idp->di_ops = ops;
9120Sstevel@tonic-gate 	idp->di_iarg = iarg;
9130Sstevel@tonic-gate 	idp->di_data = NULL;
9140Sstevel@tonic-gate 	idp->di_ctfp = NULL;
9150Sstevel@tonic-gate 	idp->di_type = CTF_ERR;
9160Sstevel@tonic-gate 	idp->di_next = NULL;
9170Sstevel@tonic-gate 	idp->di_gen = gen;
9180Sstevel@tonic-gate 	idp->di_lineno = yylineno;
9190Sstevel@tonic-gate 
9200Sstevel@tonic-gate 	return (idp);
9210Sstevel@tonic-gate }
9220Sstevel@tonic-gate 
9230Sstevel@tonic-gate /*
9240Sstevel@tonic-gate  * Destroy an individual identifier.  This code must be kept in sync with the
9250Sstevel@tonic-gate  * dt_idhash_destroy() function below, which separates out the call to di_dtor.
9260Sstevel@tonic-gate  */
9270Sstevel@tonic-gate void
dt_ident_destroy(dt_ident_t * idp)9280Sstevel@tonic-gate dt_ident_destroy(dt_ident_t *idp)
9290Sstevel@tonic-gate {
9300Sstevel@tonic-gate 	idp->di_ops->di_dtor(idp);
9310Sstevel@tonic-gate 	free(idp->di_name);
9320Sstevel@tonic-gate 	free(idp);
9330Sstevel@tonic-gate }
9340Sstevel@tonic-gate 
9350Sstevel@tonic-gate void
dt_ident_morph(dt_ident_t * idp,ushort_t kind,const dt_idops_t * ops,void * iarg)9360Sstevel@tonic-gate dt_ident_morph(dt_ident_t *idp, ushort_t kind,
9370Sstevel@tonic-gate     const dt_idops_t *ops, void *iarg)
9380Sstevel@tonic-gate {
9390Sstevel@tonic-gate 	idp->di_ops->di_dtor(idp);
9400Sstevel@tonic-gate 	idp->di_kind = kind;
9410Sstevel@tonic-gate 	idp->di_ops = ops;
9420Sstevel@tonic-gate 	idp->di_iarg = iarg;
9430Sstevel@tonic-gate 	idp->di_data = NULL;
9440Sstevel@tonic-gate }
9450Sstevel@tonic-gate 
9460Sstevel@tonic-gate dtrace_attribute_t
dt_ident_cook(dt_node_t * dnp,dt_ident_t * idp,dt_node_t ** pargp)9470Sstevel@tonic-gate dt_ident_cook(dt_node_t *dnp, dt_ident_t *idp, dt_node_t **pargp)
9480Sstevel@tonic-gate {
9490Sstevel@tonic-gate 	dtrace_attribute_t attr;
9500Sstevel@tonic-gate 	dt_node_t *args, *argp;
9510Sstevel@tonic-gate 	int argc = 0;
9520Sstevel@tonic-gate 
9530Sstevel@tonic-gate 	attr = dt_node_list_cook(pargp, DT_IDFLG_REF);
9540Sstevel@tonic-gate 	args = pargp ? *pargp : NULL;
9550Sstevel@tonic-gate 
9560Sstevel@tonic-gate 	for (argp = args; argp != NULL; argp = argp->dn_list)
9570Sstevel@tonic-gate 		argc++;
9580Sstevel@tonic-gate 
9590Sstevel@tonic-gate 	idp->di_ops->di_cook(dnp, idp, argc, args);
9600Sstevel@tonic-gate 
9610Sstevel@tonic-gate 	if (idp->di_flags & DT_IDFLG_USER)
9620Sstevel@tonic-gate 		dnp->dn_flags |= DT_NF_USERLAND;
9630Sstevel@tonic-gate 
9640Sstevel@tonic-gate 	return (dt_attr_min(attr, idp->di_attr));
9650Sstevel@tonic-gate }
9660Sstevel@tonic-gate 
9670Sstevel@tonic-gate void
dt_ident_type_assign(dt_ident_t * idp,ctf_file_t * fp,ctf_id_t type)9680Sstevel@tonic-gate dt_ident_type_assign(dt_ident_t *idp, ctf_file_t *fp, ctf_id_t type)
9690Sstevel@tonic-gate {
9700Sstevel@tonic-gate 	idp->di_ctfp = fp;
9710Sstevel@tonic-gate 	idp->di_type = type;
9720Sstevel@tonic-gate }
9730Sstevel@tonic-gate 
9740Sstevel@tonic-gate dt_ident_t *
dt_ident_resolve(dt_ident_t * idp)9750Sstevel@tonic-gate dt_ident_resolve(dt_ident_t *idp)
9760Sstevel@tonic-gate {
9770Sstevel@tonic-gate 	while (idp->di_flags & DT_IDFLG_INLINE) {
9780Sstevel@tonic-gate 		const dt_node_t *dnp = ((dt_idnode_t *)idp->di_iarg)->din_root;
9790Sstevel@tonic-gate 
980265Smws 		if (dnp == NULL)
981265Smws 			break; /* can't resolve any further yet */
982265Smws 
9830Sstevel@tonic-gate 		switch (dnp->dn_kind) {
9840Sstevel@tonic-gate 		case DT_NODE_VAR:
9850Sstevel@tonic-gate 		case DT_NODE_SYM:
9860Sstevel@tonic-gate 		case DT_NODE_FUNC:
9870Sstevel@tonic-gate 		case DT_NODE_AGG:
9880Sstevel@tonic-gate 		case DT_NODE_INLINE:
9890Sstevel@tonic-gate 		case DT_NODE_PROBE:
9900Sstevel@tonic-gate 			idp = dnp->dn_ident;
9910Sstevel@tonic-gate 			continue;
9920Sstevel@tonic-gate 		}
9930Sstevel@tonic-gate 
9940Sstevel@tonic-gate 		if (dt_node_is_dynamic(dnp))
9950Sstevel@tonic-gate 			idp = dnp->dn_ident;
9960Sstevel@tonic-gate 		else
9970Sstevel@tonic-gate 			break;
9980Sstevel@tonic-gate 	}
9990Sstevel@tonic-gate 
10000Sstevel@tonic-gate 	return (idp);
10010Sstevel@tonic-gate }
10020Sstevel@tonic-gate 
10030Sstevel@tonic-gate size_t
dt_ident_size(dt_ident_t * idp)10040Sstevel@tonic-gate dt_ident_size(dt_ident_t *idp)
10050Sstevel@tonic-gate {
10060Sstevel@tonic-gate 	idp = dt_ident_resolve(idp);
10070Sstevel@tonic-gate 	return (idp->di_ops->di_size(idp));
10080Sstevel@tonic-gate }
10090Sstevel@tonic-gate 
10100Sstevel@tonic-gate int
dt_ident_unref(const dt_ident_t * idp)10110Sstevel@tonic-gate dt_ident_unref(const dt_ident_t *idp)
10120Sstevel@tonic-gate {
10130Sstevel@tonic-gate 	return (idp->di_gen == yypcb->pcb_hdl->dt_gen &&
10140Sstevel@tonic-gate 	    (idp->di_flags & (DT_IDFLG_REF|DT_IDFLG_MOD|DT_IDFLG_DECL)) == 0);
10150Sstevel@tonic-gate }
10160Sstevel@tonic-gate 
10170Sstevel@tonic-gate const char *
dt_idkind_name(uint_t kind)10180Sstevel@tonic-gate dt_idkind_name(uint_t kind)
10190Sstevel@tonic-gate {
10200Sstevel@tonic-gate 	switch (kind) {
10210Sstevel@tonic-gate 	case DT_IDENT_ARRAY:	return ("associative array");
10220Sstevel@tonic-gate 	case DT_IDENT_SCALAR:	return ("scalar");
10230Sstevel@tonic-gate 	case DT_IDENT_PTR:	return ("pointer");
10240Sstevel@tonic-gate 	case DT_IDENT_FUNC:	return ("function");
10250Sstevel@tonic-gate 	case DT_IDENT_AGG:	return ("aggregation");
10260Sstevel@tonic-gate 	case DT_IDENT_AGGFUNC:	return ("aggregating function");
10270Sstevel@tonic-gate 	case DT_IDENT_ACTFUNC:	return ("tracing function");
10280Sstevel@tonic-gate 	case DT_IDENT_XLSOU:	return ("translated data");
10290Sstevel@tonic-gate 	case DT_IDENT_XLPTR:	return ("pointer to translated data");
10300Sstevel@tonic-gate 	case DT_IDENT_SYMBOL:	return ("external symbol reference");
10310Sstevel@tonic-gate 	case DT_IDENT_ENUM:	return ("enumerator");
10320Sstevel@tonic-gate 	case DT_IDENT_PRAGAT:	return ("#pragma attributes");
10330Sstevel@tonic-gate 	case DT_IDENT_PRAGBN:	return ("#pragma binding");
10340Sstevel@tonic-gate 	case DT_IDENT_PROBE:	return ("probe definition");
10350Sstevel@tonic-gate 	default:		return ("<?>");
10360Sstevel@tonic-gate 	}
10370Sstevel@tonic-gate }
1038