17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/resource.h>
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <strings.h>
337c478bd9Sstevel@tonic-gate #include <signal.h>
347c478bd9Sstevel@tonic-gate #include <stdlib.h>
357c478bd9Sstevel@tonic-gate #include <unistd.h>
367c478bd9Sstevel@tonic-gate #include <limits.h>
377c478bd9Sstevel@tonic-gate #include <alloca.h>
387c478bd9Sstevel@tonic-gate #include <errno.h>
397c478bd9Sstevel@tonic-gate #include <fcntl.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <dt_impl.h>
427c478bd9Sstevel@tonic-gate #include <dt_string.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate static int
457c478bd9Sstevel@tonic-gate dt_opt_agg(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
467c478bd9Sstevel@tonic-gate {
477c478bd9Sstevel@tonic-gate 	dt_aggregate_t *agp = &dtp->dt_aggregate;
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate 	if (arg != NULL)
507c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate 	agp->dtat_flags |= option;
537c478bd9Sstevel@tonic-gate 	return (0);
547c478bd9Sstevel@tonic-gate }
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*ARGSUSED*/
577c478bd9Sstevel@tonic-gate static int
587c478bd9Sstevel@tonic-gate dt_opt_amin(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
597c478bd9Sstevel@tonic-gate {
607c478bd9Sstevel@tonic-gate 	char str[DTRACE_ATTR2STR_MAX];
617c478bd9Sstevel@tonic-gate 	dtrace_attribute_t attr;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate 	if (arg == NULL || dtrace_str2attr(arg, &attr) == -1)
647c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate 	dt_dprintf("set compiler attribute minimum to %s\n",
677c478bd9Sstevel@tonic-gate 	    dtrace_attr2str(attr, str, sizeof (str)));
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL) {
707c478bd9Sstevel@tonic-gate 		dtp->dt_pcb->pcb_cflags |= DTRACE_C_EATTR;
717c478bd9Sstevel@tonic-gate 		dtp->dt_pcb->pcb_amin = attr;
727c478bd9Sstevel@tonic-gate 	} else {
737c478bd9Sstevel@tonic-gate 		dtp->dt_cflags |= DTRACE_C_EATTR;
747c478bd9Sstevel@tonic-gate 		dtp->dt_amin = attr;
757c478bd9Sstevel@tonic-gate 	}
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 	return (0);
787c478bd9Sstevel@tonic-gate }
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate static void
817c478bd9Sstevel@tonic-gate dt_coredump(void)
827c478bd9Sstevel@tonic-gate {
837c478bd9Sstevel@tonic-gate 	const char msg[] = "libdtrace DEBUG: [ forcing coredump ]\n";
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 	struct sigaction act;
867c478bd9Sstevel@tonic-gate 	struct rlimit lim;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate 	(void) write(STDERR_FILENO, msg, sizeof (msg) - 1);
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	act.sa_handler = SIG_DFL;
917c478bd9Sstevel@tonic-gate 	act.sa_flags = 0;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 	(void) sigemptyset(&act.sa_mask);
947c478bd9Sstevel@tonic-gate 	(void) sigaction(SIGABRT, &act, NULL);
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate 	lim.rlim_cur = RLIM_INFINITY;
977c478bd9Sstevel@tonic-gate 	lim.rlim_max = RLIM_INFINITY;
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 	(void) setrlimit(RLIMIT_CORE, &lim);
1007c478bd9Sstevel@tonic-gate 	abort();
1017c478bd9Sstevel@tonic-gate }
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1047c478bd9Sstevel@tonic-gate static int
1057c478bd9Sstevel@tonic-gate dt_opt_core(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
1067c478bd9Sstevel@tonic-gate {
1077c478bd9Sstevel@tonic-gate 	static int enabled = 0;
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 	if (arg != NULL)
1107c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	if (enabled++ || atexit(dt_coredump) == 0)
1137c478bd9Sstevel@tonic-gate 		return (0);
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	return (dt_set_errno(dtp, errno));
1167c478bd9Sstevel@tonic-gate }
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1197c478bd9Sstevel@tonic-gate static int
1207c478bd9Sstevel@tonic-gate dt_opt_cpp_hdrs(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
1217c478bd9Sstevel@tonic-gate {
1227c478bd9Sstevel@tonic-gate 	if (arg != NULL)
1237c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL)
1267c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTCTX));
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate 	if (dt_cpp_add_arg(dtp, "-H") == NULL)
1297c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_NOMEM));
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	return (0);
1327c478bd9Sstevel@tonic-gate }
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1357c478bd9Sstevel@tonic-gate static int
1367c478bd9Sstevel@tonic-gate dt_opt_cpp_path(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
1377c478bd9Sstevel@tonic-gate {
1387c478bd9Sstevel@tonic-gate 	char *cpp;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 	if (arg == NULL)
1417c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL)
1447c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTCTX));
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate 	if ((cpp = strdup(arg)) == NULL)
1477c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_NOMEM));
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 	dtp->dt_cpp_argv[0] = (char *)strbasename(cpp);
1507c478bd9Sstevel@tonic-gate 	free(dtp->dt_cpp_path);
1517c478bd9Sstevel@tonic-gate 	dtp->dt_cpp_path = cpp;
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate 	return (0);
1547c478bd9Sstevel@tonic-gate }
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate static int
1577c478bd9Sstevel@tonic-gate dt_opt_cpp_opts(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
1587c478bd9Sstevel@tonic-gate {
1597c478bd9Sstevel@tonic-gate 	char *buf;
1607c478bd9Sstevel@tonic-gate 	size_t len;
1617c478bd9Sstevel@tonic-gate 	const char *opt = (const char *)option;
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 	if (opt == NULL || arg == NULL)
1647c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL)
1677c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTCTX));
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate 	len = strlen(opt) + strlen(arg) + 1;
1707c478bd9Sstevel@tonic-gate 	buf = alloca(len);
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate 	(void) strcpy(buf, opt);
1737c478bd9Sstevel@tonic-gate 	(void) strcat(buf, arg);
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	if (dt_cpp_add_arg(dtp, buf) == NULL)
1767c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_NOMEM));
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 	return (0);
1797c478bd9Sstevel@tonic-gate }
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1827c478bd9Sstevel@tonic-gate static int
1837c478bd9Sstevel@tonic-gate dt_opt_ctypes(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
1847c478bd9Sstevel@tonic-gate {
1857c478bd9Sstevel@tonic-gate 	int fd;
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate 	if (arg == NULL)
1887c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate 	if ((fd = open64(arg, O_CREAT | O_WRONLY, 0666)) == -1)
1917c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, errno));
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 	(void) close(dtp->dt_cdefs_fd);
1947c478bd9Sstevel@tonic-gate 	dtp->dt_cdefs_fd = fd;
1957c478bd9Sstevel@tonic-gate 	return (0);
1967c478bd9Sstevel@tonic-gate }
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1997c478bd9Sstevel@tonic-gate static int
2007c478bd9Sstevel@tonic-gate dt_opt_dtypes(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
2017c478bd9Sstevel@tonic-gate {
2027c478bd9Sstevel@tonic-gate 	int fd;
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate 	if (arg == NULL)
2057c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 	if ((fd = open64(arg, O_CREAT | O_WRONLY, 0666)) == -1)
2087c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, errno));
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 	(void) close(dtp->dt_ddefs_fd);
2117c478bd9Sstevel@tonic-gate 	dtp->dt_ddefs_fd = fd;
2127c478bd9Sstevel@tonic-gate 	return (0);
2137c478bd9Sstevel@tonic-gate }
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2167c478bd9Sstevel@tonic-gate static int
2177c478bd9Sstevel@tonic-gate dt_opt_debug(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
2187c478bd9Sstevel@tonic-gate {
2197c478bd9Sstevel@tonic-gate 	if (arg != NULL)
2207c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 	_dtrace_debug = 1;
2237c478bd9Sstevel@tonic-gate 	return (0);
2247c478bd9Sstevel@tonic-gate }
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2277c478bd9Sstevel@tonic-gate static int
2287c478bd9Sstevel@tonic-gate dt_opt_iregs(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
2297c478bd9Sstevel@tonic-gate {
2307c478bd9Sstevel@tonic-gate 	int n;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate 	if (arg == NULL || (n = atoi(arg)) <= 0)
2337c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate 	dtp->dt_conf.dtc_difintregs = n;
2367c478bd9Sstevel@tonic-gate 	return (0);
2377c478bd9Sstevel@tonic-gate }
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2407c478bd9Sstevel@tonic-gate static int
2417c478bd9Sstevel@tonic-gate dt_opt_lazyload(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
2427c478bd9Sstevel@tonic-gate {
2437c478bd9Sstevel@tonic-gate 	dtp->dt_lazyload = 1;
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate 	return (0);
2467c478bd9Sstevel@tonic-gate }
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2497c478bd9Sstevel@tonic-gate static int
2507c478bd9Sstevel@tonic-gate dt_opt_ld_path(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
2517c478bd9Sstevel@tonic-gate {
2527c478bd9Sstevel@tonic-gate 	char *ld;
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 	if (arg == NULL)
2557c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL)
2587c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTCTX));
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	if ((ld = strdup(arg)) == NULL)
2617c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_NOMEM));
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 	free(dtp->dt_ld_path);
2647c478bd9Sstevel@tonic-gate 	dtp->dt_ld_path = ld;
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate 	return (0);
2677c478bd9Sstevel@tonic-gate }
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2707c478bd9Sstevel@tonic-gate static int
2717c478bd9Sstevel@tonic-gate dt_opt_libdir(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
2727c478bd9Sstevel@tonic-gate {
2737c478bd9Sstevel@tonic-gate 	dt_dirpath_t *dp;
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate 	if (arg == NULL)
2767c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate 	if ((dp = malloc(sizeof (dt_dirpath_t))) == NULL ||
2797c478bd9Sstevel@tonic-gate 	    (dp->dir_path = strdup(arg)) == NULL) {
2807c478bd9Sstevel@tonic-gate 		free(dp);
2817c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_NOMEM));
2827c478bd9Sstevel@tonic-gate 	}
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate 	dt_list_append(&dtp->dt_lib_path, dp);
2857c478bd9Sstevel@tonic-gate 	return (0);
2867c478bd9Sstevel@tonic-gate }
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2897c478bd9Sstevel@tonic-gate static int
2907c478bd9Sstevel@tonic-gate dt_opt_linkmode(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
2917c478bd9Sstevel@tonic-gate {
2927c478bd9Sstevel@tonic-gate 	if (arg == NULL)
2937c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 	if (strcmp(arg, "kernel") == 0)
2967c478bd9Sstevel@tonic-gate 		dtp->dt_linkmode = DT_LINK_KERNEL;
2977c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "primary") == 0)
2987c478bd9Sstevel@tonic-gate 		dtp->dt_linkmode = DT_LINK_PRIMARY;
2997c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "dynamic") == 0)
3007c478bd9Sstevel@tonic-gate 		dtp->dt_linkmode = DT_LINK_DYNAMIC;
3017c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "static") == 0)
3027c478bd9Sstevel@tonic-gate 		dtp->dt_linkmode = DT_LINK_STATIC;
3037c478bd9Sstevel@tonic-gate 	else
3047c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 	return (0);
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3107c478bd9Sstevel@tonic-gate static int
3117c478bd9Sstevel@tonic-gate dt_opt_linktype(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
3127c478bd9Sstevel@tonic-gate {
3137c478bd9Sstevel@tonic-gate 	if (arg == NULL)
3147c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 	if (strcasecmp(arg, "elf") == 0)
3177c478bd9Sstevel@tonic-gate 		dtp->dt_linktype = DT_LTYP_ELF;
3187c478bd9Sstevel@tonic-gate 	else if (strcasecmp(arg, "dof") == 0)
3197c478bd9Sstevel@tonic-gate 		dtp->dt_linktype = DT_LTYP_DOF;
3207c478bd9Sstevel@tonic-gate 	else
3217c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate 	return (0);
3247c478bd9Sstevel@tonic-gate }
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3277c478bd9Sstevel@tonic-gate static int
3287c478bd9Sstevel@tonic-gate dt_opt_evaltime(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
3297c478bd9Sstevel@tonic-gate {
3307c478bd9Sstevel@tonic-gate 	if (arg == NULL)
3317c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate 	if (strcmp(arg, "exec") == 0)
3347c478bd9Sstevel@tonic-gate 		dtp->dt_prcmode = DT_PROC_STOP_CREATE;
3357c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "preinit") == 0)
3367c478bd9Sstevel@tonic-gate 		dtp->dt_prcmode = DT_PROC_STOP_PREINIT;
3377c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "postinit") == 0)
3387c478bd9Sstevel@tonic-gate 		dtp->dt_prcmode = DT_PROC_STOP_POSTINIT;
3397c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "main") == 0)
3407c478bd9Sstevel@tonic-gate 		dtp->dt_prcmode = DT_PROC_STOP_MAIN;
3417c478bd9Sstevel@tonic-gate 	else
3427c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate 	return (0);
3457c478bd9Sstevel@tonic-gate }
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3487c478bd9Sstevel@tonic-gate static int
3497c478bd9Sstevel@tonic-gate dt_opt_pgmax(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
3507c478bd9Sstevel@tonic-gate {
3517c478bd9Sstevel@tonic-gate 	int n;
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate 	if (arg == NULL || (n = atoi(arg)) < 0)
3547c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate 	dtp->dt_procs->dph_lrulim = n;
3577c478bd9Sstevel@tonic-gate 	return (0);
3587c478bd9Sstevel@tonic-gate }
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3617c478bd9Sstevel@tonic-gate static int
3627c478bd9Sstevel@tonic-gate dt_opt_stdc(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
3637c478bd9Sstevel@tonic-gate {
3647c478bd9Sstevel@tonic-gate 	if (arg == NULL)
3657c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL)
3687c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTCTX));
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate 	if (strcmp(arg, "a") == 0)
3717c478bd9Sstevel@tonic-gate 		dtp->dt_stdcmode = DT_STDC_XA;
3727c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "c") == 0)
3737c478bd9Sstevel@tonic-gate 		dtp->dt_stdcmode = DT_STDC_XC;
3747c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "s") == 0)
3757c478bd9Sstevel@tonic-gate 		dtp->dt_stdcmode = DT_STDC_XS;
3767c478bd9Sstevel@tonic-gate 	else if (strcmp(arg, "t") == 0)
3777c478bd9Sstevel@tonic-gate 		dtp->dt_stdcmode = DT_STDC_XT;
3787c478bd9Sstevel@tonic-gate 	else
3797c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate 	return (0);
3827c478bd9Sstevel@tonic-gate }
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3857c478bd9Sstevel@tonic-gate static int
3867c478bd9Sstevel@tonic-gate dt_opt_syslibdir(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
3877c478bd9Sstevel@tonic-gate {
3887c478bd9Sstevel@tonic-gate 	dt_dirpath_t *dp = dt_list_next(&dtp->dt_lib_path);
3897c478bd9Sstevel@tonic-gate 	char *path;
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate 	if (arg == NULL)
3927c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 	if ((path = strdup(arg)) == NULL)
3957c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_NOMEM));
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate 	free(dp->dir_path);
3987c478bd9Sstevel@tonic-gate 	dp->dir_path = path;
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate 	return (0);
4017c478bd9Sstevel@tonic-gate }
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4057c478bd9Sstevel@tonic-gate static int
4067c478bd9Sstevel@tonic-gate dt_opt_tree(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
4077c478bd9Sstevel@tonic-gate {
4087c478bd9Sstevel@tonic-gate 	int m;
4097c478bd9Sstevel@tonic-gate 
4107c478bd9Sstevel@tonic-gate 	if (arg == NULL || (m = atoi(arg)) <= 0)
4117c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate 	dtp->dt_treedump = m;
4147c478bd9Sstevel@tonic-gate 	return (0);
4157c478bd9Sstevel@tonic-gate }
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4187c478bd9Sstevel@tonic-gate static int
4197c478bd9Sstevel@tonic-gate dt_opt_tregs(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
4207c478bd9Sstevel@tonic-gate {
4217c478bd9Sstevel@tonic-gate 	int n;
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate 	if (arg == NULL || (n = atoi(arg)) <= 0)
4247c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate 	dtp->dt_conf.dtc_diftupregs = n;
4277c478bd9Sstevel@tonic-gate 	return (0);
4287c478bd9Sstevel@tonic-gate }
4297c478bd9Sstevel@tonic-gate 
430*1a7c1b72Smws /*ARGSUSED*/
431*1a7c1b72Smws static int
432*1a7c1b72Smws dt_opt_xlate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
433*1a7c1b72Smws {
434*1a7c1b72Smws 	if (arg == NULL)
435*1a7c1b72Smws 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
436*1a7c1b72Smws 
437*1a7c1b72Smws 	if (strcmp(arg, "dynamic") == 0)
438*1a7c1b72Smws 		dtp->dt_xlatemode = DT_XL_DYNAMIC;
439*1a7c1b72Smws 	else if (strcmp(arg, "static") == 0)
440*1a7c1b72Smws 		dtp->dt_xlatemode = DT_XL_STATIC;
441*1a7c1b72Smws 	else
442*1a7c1b72Smws 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
443*1a7c1b72Smws 
444*1a7c1b72Smws 	return (0);
445*1a7c1b72Smws }
446*1a7c1b72Smws 
447*1a7c1b72Smws /*ARGSUSED*/
448*1a7c1b72Smws 
4497c478bd9Sstevel@tonic-gate static int
4507c478bd9Sstevel@tonic-gate dt_opt_cflags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
4517c478bd9Sstevel@tonic-gate {
4527c478bd9Sstevel@tonic-gate 	if (arg != NULL)
4537c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL)
4567c478bd9Sstevel@tonic-gate 		dtp->dt_pcb->pcb_cflags |= option;
4577c478bd9Sstevel@tonic-gate 	else
4587c478bd9Sstevel@tonic-gate 		dtp->dt_cflags |= option;
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate 	return (0);
4617c478bd9Sstevel@tonic-gate }
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate static int
4647c478bd9Sstevel@tonic-gate dt_opt_dflags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
4657c478bd9Sstevel@tonic-gate {
4667c478bd9Sstevel@tonic-gate 	if (arg != NULL)
4677c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
4687c478bd9Sstevel@tonic-gate 
4697c478bd9Sstevel@tonic-gate 	dtp->dt_dflags |= option;
4707c478bd9Sstevel@tonic-gate 	return (0);
4717c478bd9Sstevel@tonic-gate }
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate static int
4747c478bd9Sstevel@tonic-gate dt_opt_invcflags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
4757c478bd9Sstevel@tonic-gate {
4767c478bd9Sstevel@tonic-gate 	if (arg != NULL)
4777c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
4787c478bd9Sstevel@tonic-gate 
4797c478bd9Sstevel@tonic-gate 	if (dtp->dt_pcb != NULL)
4807c478bd9Sstevel@tonic-gate 		dtp->dt_pcb->pcb_cflags &= ~option;
4817c478bd9Sstevel@tonic-gate 	else
4827c478bd9Sstevel@tonic-gate 		dtp->dt_cflags &= ~option;
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate 	return (0);
4857c478bd9Sstevel@tonic-gate }
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate /*ARGSUSED*/
4887c478bd9Sstevel@tonic-gate static int
4897c478bd9Sstevel@tonic-gate dt_opt_version(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
4907c478bd9Sstevel@tonic-gate {
4917c478bd9Sstevel@tonic-gate 	dt_version_t v;
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate 	if (arg == NULL)
4947c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate 	if (dt_version_str2num(arg, &v) == -1)
4977c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_VERSINVAL));
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate 	if (!dt_version_defined(v))
5007c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_VERSUNDEF));
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate 	return (dt_reduce(dtp, v));
5037c478bd9Sstevel@tonic-gate }
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate static int
5067c478bd9Sstevel@tonic-gate dt_opt_runtime(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
5077c478bd9Sstevel@tonic-gate {
5087c478bd9Sstevel@tonic-gate 	char *end;
5097c478bd9Sstevel@tonic-gate 	dtrace_optval_t val = 0;
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate 	if (arg != NULL) {
5127c478bd9Sstevel@tonic-gate 		errno = 0;
5137c478bd9Sstevel@tonic-gate 		val = strtoull(arg, &end, 0);
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate 		if (*end != '\0' || errno != 0 || val < 0)
5167c478bd9Sstevel@tonic-gate 			return (dt_set_errno(dtp, EDT_BADOPTVAL));
5177c478bd9Sstevel@tonic-gate 	}
5187c478bd9Sstevel@tonic-gate 
5197c478bd9Sstevel@tonic-gate 	dtp->dt_options[option] = val;
5207c478bd9Sstevel@tonic-gate 	return (0);
5217c478bd9Sstevel@tonic-gate }
5227c478bd9Sstevel@tonic-gate 
5237c478bd9Sstevel@tonic-gate static int
5247c478bd9Sstevel@tonic-gate dt_opt_size(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
5257c478bd9Sstevel@tonic-gate {
5267c478bd9Sstevel@tonic-gate 	char *end;
5277c478bd9Sstevel@tonic-gate 	int len;
5287c478bd9Sstevel@tonic-gate 	dtrace_optval_t mul = 1, val = 0;
5297c478bd9Sstevel@tonic-gate 
5307c478bd9Sstevel@tonic-gate 	if (arg != NULL) {
5317c478bd9Sstevel@tonic-gate 		len = strlen(arg);
5327c478bd9Sstevel@tonic-gate 		errno = 0;
5337c478bd9Sstevel@tonic-gate 
5347c478bd9Sstevel@tonic-gate 		switch (arg[len - 1]) {
5357c478bd9Sstevel@tonic-gate 		case 't':
5367c478bd9Sstevel@tonic-gate 		case 'T':
5377c478bd9Sstevel@tonic-gate 			mul *= 1024;
5387c478bd9Sstevel@tonic-gate 			/*FALLTHRU*/
5397c478bd9Sstevel@tonic-gate 		case 'g':
5407c478bd9Sstevel@tonic-gate 		case 'G':
5417c478bd9Sstevel@tonic-gate 			mul *= 1024;
5427c478bd9Sstevel@tonic-gate 			/*FALLTHRU*/
5437c478bd9Sstevel@tonic-gate 		case 'm':
5447c478bd9Sstevel@tonic-gate 		case 'M':
5457c478bd9Sstevel@tonic-gate 			mul *= 1024;
5467c478bd9Sstevel@tonic-gate 			/*FALLTHRU*/
5477c478bd9Sstevel@tonic-gate 		case 'k':
5487c478bd9Sstevel@tonic-gate 		case 'K':
5497c478bd9Sstevel@tonic-gate 			mul *= 1024;
5507c478bd9Sstevel@tonic-gate 			/*FALLTHRU*/
5517c478bd9Sstevel@tonic-gate 		default:
5527c478bd9Sstevel@tonic-gate 			break;
5537c478bd9Sstevel@tonic-gate 		}
5547c478bd9Sstevel@tonic-gate 
5557c478bd9Sstevel@tonic-gate 		val = strtoull(arg, &end, 0) * mul;
5567c478bd9Sstevel@tonic-gate 
5577c478bd9Sstevel@tonic-gate 		if ((mul > 1 && end != &arg[len - 1]) ||
5587c478bd9Sstevel@tonic-gate 		    (mul == 1 && *end != '\0') || val < 0 ||
5597c478bd9Sstevel@tonic-gate 		    errno != 0 || val == DTRACEOPT_UNSET)
5607c478bd9Sstevel@tonic-gate 			return (dt_set_errno(dtp, EDT_BADOPTVAL));
5617c478bd9Sstevel@tonic-gate 	}
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate 	dtp->dt_options[option] = val;
5647c478bd9Sstevel@tonic-gate 	return (0);
5657c478bd9Sstevel@tonic-gate }
5667c478bd9Sstevel@tonic-gate 
5677c478bd9Sstevel@tonic-gate static int
5687c478bd9Sstevel@tonic-gate dt_opt_rate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
5697c478bd9Sstevel@tonic-gate {
5707c478bd9Sstevel@tonic-gate 	char *end;
5717c478bd9Sstevel@tonic-gate 	int i;
5727c478bd9Sstevel@tonic-gate 	dtrace_optval_t mul = 1, val = 0;
5737c478bd9Sstevel@tonic-gate 
5747c478bd9Sstevel@tonic-gate 	const struct {
5757c478bd9Sstevel@tonic-gate 		char *name;
5767c478bd9Sstevel@tonic-gate 		hrtime_t mul;
5777c478bd9Sstevel@tonic-gate 	} suffix[] = {
5787c478bd9Sstevel@tonic-gate 		{ "ns", 	NANOSEC / NANOSEC },
5797c478bd9Sstevel@tonic-gate 		{ "nsec",	NANOSEC / NANOSEC },
5807c478bd9Sstevel@tonic-gate 		{ "us",		NANOSEC / MICROSEC },
5817c478bd9Sstevel@tonic-gate 		{ "usec",	NANOSEC / MICROSEC },
5827c478bd9Sstevel@tonic-gate 		{ "ms",		NANOSEC / MILLISEC },
5837c478bd9Sstevel@tonic-gate 		{ "msec",	NANOSEC / MILLISEC },
5847c478bd9Sstevel@tonic-gate 		{ "s",		NANOSEC / SEC },
5857c478bd9Sstevel@tonic-gate 		{ "sec",	NANOSEC / SEC },
5867c478bd9Sstevel@tonic-gate 		{ "m",		NANOSEC * (hrtime_t)60 },
5877c478bd9Sstevel@tonic-gate 		{ "min",	NANOSEC * (hrtime_t)60 },
5887c478bd9Sstevel@tonic-gate 		{ "h",		NANOSEC * (hrtime_t)60 * (hrtime_t)60 },
5897c478bd9Sstevel@tonic-gate 		{ "hour",	NANOSEC * (hrtime_t)60 * (hrtime_t)60 },
5907c478bd9Sstevel@tonic-gate 		{ "d",		NANOSEC * (hrtime_t)(24 * 60 * 60) },
5917c478bd9Sstevel@tonic-gate 		{ "day",	NANOSEC * (hrtime_t)(24 * 60 * 60) },
5927c478bd9Sstevel@tonic-gate 		{ "hz",		0 },
5937c478bd9Sstevel@tonic-gate 		{ NULL }
5947c478bd9Sstevel@tonic-gate 	};
5957c478bd9Sstevel@tonic-gate 
5967c478bd9Sstevel@tonic-gate 	if (arg != NULL) {
5977c478bd9Sstevel@tonic-gate 		errno = 0;
5987c478bd9Sstevel@tonic-gate 		val = strtoull(arg, &end, 0);
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate 		for (i = 0; suffix[i].name != NULL; i++) {
6017c478bd9Sstevel@tonic-gate 			if (strcasecmp(suffix[i].name, end) == 0) {
6027c478bd9Sstevel@tonic-gate 				mul = suffix[i].mul;
6037c478bd9Sstevel@tonic-gate 				break;
6047c478bd9Sstevel@tonic-gate 			}
6057c478bd9Sstevel@tonic-gate 		}
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate 		if (suffix[i].name == NULL && *end != '\0' || val < 0)
6087c478bd9Sstevel@tonic-gate 			return (dt_set_errno(dtp, EDT_BADOPTVAL));
6097c478bd9Sstevel@tonic-gate 
6107c478bd9Sstevel@tonic-gate 		if (mul == 0) {
6117c478bd9Sstevel@tonic-gate 			/*
6127c478bd9Sstevel@tonic-gate 			 * The rate has been specified in frequency-per-second.
6137c478bd9Sstevel@tonic-gate 			 */
6147c478bd9Sstevel@tonic-gate 			if (val != 0)
6157c478bd9Sstevel@tonic-gate 				val = NANOSEC / val;
6167c478bd9Sstevel@tonic-gate 		} else {
6177c478bd9Sstevel@tonic-gate 			val *= mul;
6187c478bd9Sstevel@tonic-gate 		}
6197c478bd9Sstevel@tonic-gate 	}
6207c478bd9Sstevel@tonic-gate 
6217c478bd9Sstevel@tonic-gate 	dtp->dt_options[option] = val;
6227c478bd9Sstevel@tonic-gate 	return (0);
6237c478bd9Sstevel@tonic-gate }
6247c478bd9Sstevel@tonic-gate 
6257c478bd9Sstevel@tonic-gate /*
6267c478bd9Sstevel@tonic-gate  * When setting the strsize option, set the option in the dt_options array
6277c478bd9Sstevel@tonic-gate  * using dt_opt_size() as usual, and then update the definition of the CTF
6287c478bd9Sstevel@tonic-gate  * type for the D intrinsic "string" to be an array of the corresponding size.
6297c478bd9Sstevel@tonic-gate  * If any errors occur, reset dt_options[option] to its previous value.
6307c478bd9Sstevel@tonic-gate  */
6317c478bd9Sstevel@tonic-gate static int
6327c478bd9Sstevel@tonic-gate dt_opt_strsize(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
6337c478bd9Sstevel@tonic-gate {
6347c478bd9Sstevel@tonic-gate 	dtrace_optval_t val = dtp->dt_options[option];
6357c478bd9Sstevel@tonic-gate 	ctf_file_t *fp = DT_STR_CTFP(dtp);
6367c478bd9Sstevel@tonic-gate 	ctf_id_t type = ctf_type_resolve(fp, DT_STR_TYPE(dtp));
6377c478bd9Sstevel@tonic-gate 	ctf_arinfo_t r;
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate 	if (dt_opt_size(dtp, arg, option) != 0)
6407c478bd9Sstevel@tonic-gate 		return (-1); /* dt_errno is set for us */
6417c478bd9Sstevel@tonic-gate 
6427c478bd9Sstevel@tonic-gate 	if (dtp->dt_options[option] > UINT_MAX) {
6437c478bd9Sstevel@tonic-gate 		dtp->dt_options[option] = val;
6447c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EOVERFLOW));
6457c478bd9Sstevel@tonic-gate 	}
6467c478bd9Sstevel@tonic-gate 
6477c478bd9Sstevel@tonic-gate 	if (ctf_array_info(fp, type, &r) == CTF_ERR) {
6487c478bd9Sstevel@tonic-gate 		dtp->dt_options[option] = val;
6497c478bd9Sstevel@tonic-gate 		dtp->dt_ctferr = ctf_errno(fp);
6507c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_CTF));
6517c478bd9Sstevel@tonic-gate 	}
6527c478bd9Sstevel@tonic-gate 
6537c478bd9Sstevel@tonic-gate 	r.ctr_nelems = (uint_t)dtp->dt_options[option];
6547c478bd9Sstevel@tonic-gate 
6557c478bd9Sstevel@tonic-gate 	if (ctf_set_array(fp, type, &r) == CTF_ERR ||
6567c478bd9Sstevel@tonic-gate 	    ctf_update(fp) == CTF_ERR) {
6577c478bd9Sstevel@tonic-gate 		dtp->dt_options[option] = val;
6587c478bd9Sstevel@tonic-gate 		dtp->dt_ctferr = ctf_errno(fp);
6597c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_CTF));
6607c478bd9Sstevel@tonic-gate 	}
6617c478bd9Sstevel@tonic-gate 
6627c478bd9Sstevel@tonic-gate 	return (0);
6637c478bd9Sstevel@tonic-gate }
6647c478bd9Sstevel@tonic-gate 
6657c478bd9Sstevel@tonic-gate static const struct {
6667c478bd9Sstevel@tonic-gate 	const char *dtbp_name;
6677c478bd9Sstevel@tonic-gate 	int dtbp_policy;
6687c478bd9Sstevel@tonic-gate } _dtrace_bufpolicies[] = {
6697c478bd9Sstevel@tonic-gate 	{ "ring", DTRACEOPT_BUFPOLICY_RING },
6707c478bd9Sstevel@tonic-gate 	{ "fill", DTRACEOPT_BUFPOLICY_FILL },
6717c478bd9Sstevel@tonic-gate 	{ "switch", DTRACEOPT_BUFPOLICY_SWITCH },
6727c478bd9Sstevel@tonic-gate 	{ NULL, 0 }
6737c478bd9Sstevel@tonic-gate };
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate /*ARGSUSED*/
6767c478bd9Sstevel@tonic-gate static int
6777c478bd9Sstevel@tonic-gate dt_opt_bufpolicy(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
6787c478bd9Sstevel@tonic-gate {
6797c478bd9Sstevel@tonic-gate 	dtrace_optval_t policy = DTRACEOPT_UNSET;
6807c478bd9Sstevel@tonic-gate 	int i;
6817c478bd9Sstevel@tonic-gate 
6827c478bd9Sstevel@tonic-gate 	if (arg == NULL)
6837c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
6847c478bd9Sstevel@tonic-gate 
6857c478bd9Sstevel@tonic-gate 	for (i = 0; _dtrace_bufpolicies[i].dtbp_name != NULL; i++) {
6867c478bd9Sstevel@tonic-gate 		if (strcmp(_dtrace_bufpolicies[i].dtbp_name, arg) == 0) {
6877c478bd9Sstevel@tonic-gate 			policy = _dtrace_bufpolicies[i].dtbp_policy;
6887c478bd9Sstevel@tonic-gate 			break;
6897c478bd9Sstevel@tonic-gate 		}
6907c478bd9Sstevel@tonic-gate 	}
6917c478bd9Sstevel@tonic-gate 
6927c478bd9Sstevel@tonic-gate 	if (policy == DTRACEOPT_UNSET)
6937c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
6947c478bd9Sstevel@tonic-gate 
6957c478bd9Sstevel@tonic-gate 	dtp->dt_options[DTRACEOPT_BUFPOLICY] = policy;
6967c478bd9Sstevel@tonic-gate 
6977c478bd9Sstevel@tonic-gate 	return (0);
6987c478bd9Sstevel@tonic-gate }
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate static const struct {
7017c478bd9Sstevel@tonic-gate 	const char *dtbr_name;
7027c478bd9Sstevel@tonic-gate 	int dtbr_policy;
7037c478bd9Sstevel@tonic-gate } _dtrace_bufresize[] = {
7047c478bd9Sstevel@tonic-gate 	{ "auto", DTRACEOPT_BUFRESIZE_AUTO },
7057c478bd9Sstevel@tonic-gate 	{ "manual", DTRACEOPT_BUFRESIZE_MANUAL },
7067c478bd9Sstevel@tonic-gate 	{ NULL, 0 }
7077c478bd9Sstevel@tonic-gate };
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate /*ARGSUSED*/
7107c478bd9Sstevel@tonic-gate static int
7117c478bd9Sstevel@tonic-gate dt_opt_bufresize(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
7127c478bd9Sstevel@tonic-gate {
7137c478bd9Sstevel@tonic-gate 	dtrace_optval_t policy = DTRACEOPT_UNSET;
7147c478bd9Sstevel@tonic-gate 	int i;
7157c478bd9Sstevel@tonic-gate 
7167c478bd9Sstevel@tonic-gate 	if (arg == NULL)
7177c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
7187c478bd9Sstevel@tonic-gate 
7197c478bd9Sstevel@tonic-gate 	for (i = 0; _dtrace_bufresize[i].dtbr_name != NULL; i++) {
7207c478bd9Sstevel@tonic-gate 		if (strcmp(_dtrace_bufresize[i].dtbr_name, arg) == 0) {
7217c478bd9Sstevel@tonic-gate 			policy = _dtrace_bufresize[i].dtbr_policy;
7227c478bd9Sstevel@tonic-gate 			break;
7237c478bd9Sstevel@tonic-gate 		}
7247c478bd9Sstevel@tonic-gate 	}
7257c478bd9Sstevel@tonic-gate 
7267c478bd9Sstevel@tonic-gate 	if (policy == DTRACEOPT_UNSET)
7277c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADOPTVAL));
7287c478bd9Sstevel@tonic-gate 
7297c478bd9Sstevel@tonic-gate 	dtp->dt_options[DTRACEOPT_BUFRESIZE] = policy;
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate 	return (0);
7327c478bd9Sstevel@tonic-gate }
7337c478bd9Sstevel@tonic-gate 
7347c478bd9Sstevel@tonic-gate int
7357c478bd9Sstevel@tonic-gate dt_options_load(dtrace_hdl_t *dtp)
7367c478bd9Sstevel@tonic-gate {
7377c478bd9Sstevel@tonic-gate 	dof_hdr_t hdr, *dof;
7387c478bd9Sstevel@tonic-gate 	dof_sec_t *sec;
7397c478bd9Sstevel@tonic-gate 	size_t offs;
7407c478bd9Sstevel@tonic-gate 	int i;
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate 	/*
7437c478bd9Sstevel@tonic-gate 	 * To load the option values, we need to ask the kernel to provide its
7447c478bd9Sstevel@tonic-gate 	 * DOF, which we'll sift through to look for OPTDESC sections.
7457c478bd9Sstevel@tonic-gate 	 */
7467c478bd9Sstevel@tonic-gate 	bzero(&hdr, sizeof (dof_hdr_t));
7477c478bd9Sstevel@tonic-gate 	hdr.dofh_loadsz = sizeof (dof_hdr_t);
7487c478bd9Sstevel@tonic-gate 
7497c478bd9Sstevel@tonic-gate 	if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &hdr) == -1)
7507c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, errno));
7517c478bd9Sstevel@tonic-gate 
7527c478bd9Sstevel@tonic-gate 	if (hdr.dofh_loadsz < sizeof (dof_hdr_t))
7537c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EINVAL));
7547c478bd9Sstevel@tonic-gate 
7557c478bd9Sstevel@tonic-gate 	dof = alloca(hdr.dofh_loadsz);
7567c478bd9Sstevel@tonic-gate 	bzero(dof, sizeof (dof_hdr_t));
7577c478bd9Sstevel@tonic-gate 	dof->dofh_loadsz = hdr.dofh_loadsz;
7587c478bd9Sstevel@tonic-gate 
7597c478bd9Sstevel@tonic-gate 	for (i = 0; i < DTRACEOPT_MAX; i++)
7607c478bd9Sstevel@tonic-gate 		dtp->dt_options[i] = DTRACEOPT_UNSET;
7617c478bd9Sstevel@tonic-gate 
7627c478bd9Sstevel@tonic-gate 	if (dt_ioctl(dtp, DTRACEIOC_DOFGET, dof) == -1)
7637c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, errno));
7647c478bd9Sstevel@tonic-gate 
7657c478bd9Sstevel@tonic-gate 	for (i = 0; i < dof->dofh_secnum; i++) {
7660b38a8bdSahl 		sec = (dof_sec_t *)(uintptr_t)((uintptr_t)dof +
7677c478bd9Sstevel@tonic-gate 		    dof->dofh_secoff + i * dof->dofh_secsize);
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate 		if (sec->dofs_type != DOF_SECT_OPTDESC)
7707c478bd9Sstevel@tonic-gate 			continue;
7717c478bd9Sstevel@tonic-gate 
7727c478bd9Sstevel@tonic-gate 		break;
7737c478bd9Sstevel@tonic-gate 	}
7747c478bd9Sstevel@tonic-gate 
7757c478bd9Sstevel@tonic-gate 	for (offs = 0; offs < sec->dofs_size; offs += sec->dofs_entsize) {
7760b38a8bdSahl 		dof_optdesc_t *opt = (dof_optdesc_t *)(uintptr_t)
7770b38a8bdSahl 		    ((uintptr_t)dof + sec->dofs_offset + offs);
7787c478bd9Sstevel@tonic-gate 
7797c478bd9Sstevel@tonic-gate 		if (opt->dofo_strtab != DOF_SECIDX_NONE)
7807c478bd9Sstevel@tonic-gate 			continue;
7817c478bd9Sstevel@tonic-gate 
7827c478bd9Sstevel@tonic-gate 		if (opt->dofo_option >= DTRACEOPT_MAX)
7837c478bd9Sstevel@tonic-gate 			continue;
7847c478bd9Sstevel@tonic-gate 
7857c478bd9Sstevel@tonic-gate 		dtp->dt_options[opt->dofo_option] = opt->dofo_value;
7867c478bd9Sstevel@tonic-gate 	}
7877c478bd9Sstevel@tonic-gate 
7887c478bd9Sstevel@tonic-gate 	return (0);
7897c478bd9Sstevel@tonic-gate }
7907c478bd9Sstevel@tonic-gate 
7917c478bd9Sstevel@tonic-gate typedef struct dt_option {
7927c478bd9Sstevel@tonic-gate 	const char *o_name;
7937c478bd9Sstevel@tonic-gate 	int (*o_func)(dtrace_hdl_t *, const char *, uintptr_t);
7947c478bd9Sstevel@tonic-gate 	uintptr_t o_option;
7957c478bd9Sstevel@tonic-gate } dt_option_t;
7967c478bd9Sstevel@tonic-gate 
7977c478bd9Sstevel@tonic-gate /*
7987c478bd9Sstevel@tonic-gate  * Compile-time options.
7997c478bd9Sstevel@tonic-gate  */
8007c478bd9Sstevel@tonic-gate static const dt_option_t _dtrace_ctoptions[] = {
8017c478bd9Sstevel@tonic-gate 	{ "aggpercpu", dt_opt_agg, DTRACE_A_PERCPU },
8027c478bd9Sstevel@tonic-gate 	{ "amin", dt_opt_amin },
8037c478bd9Sstevel@tonic-gate 	{ "argref", dt_opt_cflags, DTRACE_C_ARGREF },
8047c478bd9Sstevel@tonic-gate 	{ "core", dt_opt_core },
8057c478bd9Sstevel@tonic-gate 	{ "cpp", dt_opt_cflags, DTRACE_C_CPP },
8067c478bd9Sstevel@tonic-gate 	{ "cpphdrs", dt_opt_cpp_hdrs },
8077c478bd9Sstevel@tonic-gate 	{ "cpppath", dt_opt_cpp_path },
8087c478bd9Sstevel@tonic-gate 	{ "ctypes", dt_opt_ctypes },
8097c478bd9Sstevel@tonic-gate 	{ "defaultargs", dt_opt_cflags, DTRACE_C_DEFARG },
8107c478bd9Sstevel@tonic-gate 	{ "dtypes", dt_opt_dtypes },
8117c478bd9Sstevel@tonic-gate 	{ "debug", dt_opt_debug },
8127c478bd9Sstevel@tonic-gate 	{ "define", dt_opt_cpp_opts, (uintptr_t)"-D" },
8137c478bd9Sstevel@tonic-gate 	{ "empty", dt_opt_cflags, DTRACE_C_EMPTY },
8147c478bd9Sstevel@tonic-gate 	{ "errtags", dt_opt_cflags, DTRACE_C_ETAGS },
8157c478bd9Sstevel@tonic-gate 	{ "evaltime", dt_opt_evaltime },
8167c478bd9Sstevel@tonic-gate 	{ "incdir", dt_opt_cpp_opts, (uintptr_t)"-I" },
8177c478bd9Sstevel@tonic-gate 	{ "iregs", dt_opt_iregs },
8187c478bd9Sstevel@tonic-gate 	{ "kdefs", dt_opt_invcflags, DTRACE_C_KNODEF },
8197c478bd9Sstevel@tonic-gate 	{ "knodefs", dt_opt_cflags, DTRACE_C_KNODEF },
820*1a7c1b72Smws 	{ "late", dt_opt_xlate },
8217c478bd9Sstevel@tonic-gate 	{ "lazyload", dt_opt_lazyload },
8227c478bd9Sstevel@tonic-gate 	{ "ldpath", dt_opt_ld_path },
8237c478bd9Sstevel@tonic-gate 	{ "libdir", dt_opt_libdir },
8247c478bd9Sstevel@tonic-gate 	{ "linkmode", dt_opt_linkmode },
8257c478bd9Sstevel@tonic-gate 	{ "linktype", dt_opt_linktype },
8267c478bd9Sstevel@tonic-gate 	{ "nolibs", dt_opt_cflags, DTRACE_C_NOLIBS },
8277c478bd9Sstevel@tonic-gate 	{ "pgmax", dt_opt_pgmax },
8287c478bd9Sstevel@tonic-gate 	{ "pspec", dt_opt_cflags, DTRACE_C_PSPEC },
8297c478bd9Sstevel@tonic-gate 	{ "stdc", dt_opt_stdc },
8307c478bd9Sstevel@tonic-gate 	{ "strip", dt_opt_dflags, DTRACE_D_STRIP },
8317c478bd9Sstevel@tonic-gate 	{ "syslibdir", dt_opt_syslibdir },
8327c478bd9Sstevel@tonic-gate 	{ "tree", dt_opt_tree },
8337c478bd9Sstevel@tonic-gate 	{ "tregs", dt_opt_tregs },
8347c478bd9Sstevel@tonic-gate 	{ "udefs", dt_opt_invcflags, DTRACE_C_UNODEF },
8357c478bd9Sstevel@tonic-gate 	{ "undef", dt_opt_cpp_opts, (uintptr_t)"-U" },
8367c478bd9Sstevel@tonic-gate 	{ "unodefs", dt_opt_cflags, DTRACE_C_UNODEF },
8377c478bd9Sstevel@tonic-gate 	{ "verbose", dt_opt_cflags, DTRACE_C_DIFV },
8387c478bd9Sstevel@tonic-gate 	{ "version", dt_opt_version },
8397c478bd9Sstevel@tonic-gate 	{ "zdefs", dt_opt_cflags, DTRACE_C_ZDEFS },
8407c478bd9Sstevel@tonic-gate 	{ NULL }
8417c478bd9Sstevel@tonic-gate };
8427c478bd9Sstevel@tonic-gate 
8437c478bd9Sstevel@tonic-gate /*
8447c478bd9Sstevel@tonic-gate  * Run-time options.
8457c478bd9Sstevel@tonic-gate  */
8467c478bd9Sstevel@tonic-gate static const dt_option_t _dtrace_rtoptions[] = {
8477c478bd9Sstevel@tonic-gate 	{ "aggrate", dt_opt_rate, DTRACEOPT_AGGRATE },
8487c478bd9Sstevel@tonic-gate 	{ "aggsize", dt_opt_size, DTRACEOPT_AGGSIZE },
8497c478bd9Sstevel@tonic-gate 	{ "bufsize", dt_opt_size, DTRACEOPT_BUFSIZE },
8507c478bd9Sstevel@tonic-gate 	{ "bufpolicy", dt_opt_bufpolicy, DTRACEOPT_BUFPOLICY },
8517c478bd9Sstevel@tonic-gate 	{ "bufresize", dt_opt_bufresize, DTRACEOPT_BUFRESIZE },
8527c478bd9Sstevel@tonic-gate 	{ "cleanrate", dt_opt_rate, DTRACEOPT_CLEANRATE },
8537c478bd9Sstevel@tonic-gate 	{ "cpu", dt_opt_runtime, DTRACEOPT_CPU },
8547c478bd9Sstevel@tonic-gate 	{ "destructive", dt_opt_runtime, DTRACEOPT_DESTRUCTIVE },
8557c478bd9Sstevel@tonic-gate 	{ "dynvarsize", dt_opt_size, DTRACEOPT_DYNVARSIZE },
8567c478bd9Sstevel@tonic-gate 	{ "flowindent", dt_opt_runtime, DTRACEOPT_FLOWINDENT },
8577c478bd9Sstevel@tonic-gate 	{ "grabanon", dt_opt_runtime, DTRACEOPT_GRABANON },
8587c478bd9Sstevel@tonic-gate 	{ "jstackframes", dt_opt_runtime, DTRACEOPT_JSTACKFRAMES },
8597c478bd9Sstevel@tonic-gate 	{ "jstackstrsize", dt_opt_runtime, DTRACEOPT_JSTACKSTRSIZE },
8607c478bd9Sstevel@tonic-gate 	{ "nspec", dt_opt_runtime, DTRACEOPT_NSPEC },
8617c478bd9Sstevel@tonic-gate 	{ "quiet", dt_opt_runtime, DTRACEOPT_QUIET },
8627c478bd9Sstevel@tonic-gate 	{ "rawbytes", dt_opt_runtime, DTRACEOPT_RAWBYTES },
8637c478bd9Sstevel@tonic-gate 	{ "specsize", dt_opt_size, DTRACEOPT_SPECSIZE },
8647c478bd9Sstevel@tonic-gate 	{ "stackframes", dt_opt_runtime, DTRACEOPT_STACKFRAMES },
8657c478bd9Sstevel@tonic-gate 	{ "stackindent", dt_opt_runtime, DTRACEOPT_STACKINDENT },
8667c478bd9Sstevel@tonic-gate 	{ "statusrate", dt_opt_rate, DTRACEOPT_STATUSRATE },
8677c478bd9Sstevel@tonic-gate 	{ "strsize", dt_opt_strsize, DTRACEOPT_STRSIZE },
8687c478bd9Sstevel@tonic-gate 	{ "switchrate", dt_opt_rate, DTRACEOPT_SWITCHRATE },
8697c478bd9Sstevel@tonic-gate 	{ "ustackframes", dt_opt_runtime, DTRACEOPT_USTACKFRAMES },
8707c478bd9Sstevel@tonic-gate 	{ NULL }
8717c478bd9Sstevel@tonic-gate };
8727c478bd9Sstevel@tonic-gate 
8737c478bd9Sstevel@tonic-gate int
8747c478bd9Sstevel@tonic-gate dtrace_getopt(dtrace_hdl_t *dtp, const char *opt, dtrace_optval_t *val)
8757c478bd9Sstevel@tonic-gate {
8767c478bd9Sstevel@tonic-gate 	const dt_option_t *op;
8777c478bd9Sstevel@tonic-gate 
8787c478bd9Sstevel@tonic-gate 	if (opt == NULL)
8797c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EINVAL));
8807c478bd9Sstevel@tonic-gate 
8817c478bd9Sstevel@tonic-gate 	/*
8827c478bd9Sstevel@tonic-gate 	 * We only need to search the run-time options -- it's not legal
8837c478bd9Sstevel@tonic-gate 	 * to get the values of compile-time options.
8847c478bd9Sstevel@tonic-gate 	 */
8857c478bd9Sstevel@tonic-gate 	for (op = _dtrace_rtoptions; op->o_name != NULL; op++) {
8867c478bd9Sstevel@tonic-gate 		if (strcmp(op->o_name, opt) == 0) {
8877c478bd9Sstevel@tonic-gate 			*val = dtp->dt_options[op->o_option];
8887c478bd9Sstevel@tonic-gate 			return (0);
8897c478bd9Sstevel@tonic-gate 		}
8907c478bd9Sstevel@tonic-gate 	}
8917c478bd9Sstevel@tonic-gate 
8927c478bd9Sstevel@tonic-gate 	return (dt_set_errno(dtp, EDT_BADOPTNAME));
8937c478bd9Sstevel@tonic-gate }
8947c478bd9Sstevel@tonic-gate 
8957c478bd9Sstevel@tonic-gate int
8967c478bd9Sstevel@tonic-gate dtrace_setopt(dtrace_hdl_t *dtp, const char *opt, const char *val)
8977c478bd9Sstevel@tonic-gate {
8987c478bd9Sstevel@tonic-gate 	const dt_option_t *op;
8997c478bd9Sstevel@tonic-gate 
9007c478bd9Sstevel@tonic-gate 	if (opt == NULL)
9017c478bd9Sstevel@tonic-gate 		return (dt_set_errno(dtp, EINVAL));
9027c478bd9Sstevel@tonic-gate 
9037c478bd9Sstevel@tonic-gate 	for (op = _dtrace_ctoptions; op->o_name != NULL; op++) {
9047c478bd9Sstevel@tonic-gate 		if (strcmp(op->o_name, opt) == 0)
9057c478bd9Sstevel@tonic-gate 			return (op->o_func(dtp, val, op->o_option));
9067c478bd9Sstevel@tonic-gate 	}
9077c478bd9Sstevel@tonic-gate 
9087c478bd9Sstevel@tonic-gate 	for (op = _dtrace_rtoptions; op->o_name != NULL; op++) {
9097c478bd9Sstevel@tonic-gate 		if (strcmp(op->o_name, opt) == 0) {
9107c478bd9Sstevel@tonic-gate 			/*
9117c478bd9Sstevel@tonic-gate 			 * Currently, no run-time option may be set while
9127c478bd9Sstevel@tonic-gate 			 * tracing is active.
9137c478bd9Sstevel@tonic-gate 			 */
9147c478bd9Sstevel@tonic-gate 			if (dtp->dt_active)
9157c478bd9Sstevel@tonic-gate 				return (dt_set_errno(dtp, EDT_ACTIVE));
9167c478bd9Sstevel@tonic-gate 
9177c478bd9Sstevel@tonic-gate 			return (op->o_func(dtp, val, op->o_option));
9187c478bd9Sstevel@tonic-gate 		}
9197c478bd9Sstevel@tonic-gate 	}
9207c478bd9Sstevel@tonic-gate 
9217c478bd9Sstevel@tonic-gate 	return (dt_set_errno(dtp, EDT_BADOPTNAME));
9227c478bd9Sstevel@tonic-gate }
923