xref: /freebsd/sys/cddl/dev/dtrace/dtrace_sysctl.c (revision f0188618f2abe08246731cf09b0b0a99609fd34c)
191eaf3e1SJohn Birrell /*
291eaf3e1SJohn Birrell  * CDDL HEADER START
391eaf3e1SJohn Birrell  *
491eaf3e1SJohn Birrell  * The contents of this file are subject to the terms of the
591eaf3e1SJohn Birrell  * Common Development and Distribution License (the "License").
691eaf3e1SJohn Birrell  * You may not use this file except in compliance with the License.
791eaf3e1SJohn Birrell  *
891eaf3e1SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
991eaf3e1SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
1091eaf3e1SJohn Birrell  * See the License for the specific language governing permissions
1191eaf3e1SJohn Birrell  * and limitations under the License.
1291eaf3e1SJohn Birrell  *
1391eaf3e1SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
1491eaf3e1SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1591eaf3e1SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
1691eaf3e1SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
1791eaf3e1SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
1891eaf3e1SJohn Birrell  *
1991eaf3e1SJohn Birrell  * CDDL HEADER END
2091eaf3e1SJohn Birrell  *
2191eaf3e1SJohn Birrell  * $FreeBSD$
2291eaf3e1SJohn Birrell  *
2391eaf3e1SJohn Birrell  */
2491eaf3e1SJohn Birrell 
25b53bfbbaSMark Johnston SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters");
26b53bfbbaSMark Johnston 
2791eaf3e1SJohn Birrell int	dtrace_debug = 0;
28af3b2549SHans Petter Selasky SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RWTUN, &dtrace_debug, 0, "");
2991eaf3e1SJohn Birrell 
3091eaf3e1SJohn Birrell /* Report registered DTrace providers. */
3191eaf3e1SJohn Birrell static int
3291eaf3e1SJohn Birrell sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
3391eaf3e1SJohn Birrell {
3491eaf3e1SJohn Birrell 	char	*p_name	= NULL;
3591eaf3e1SJohn Birrell 	dtrace_provider_t
3691eaf3e1SJohn Birrell 		*prov	= dtrace_provider;
3791eaf3e1SJohn Birrell 	int	error	= 0;
3891eaf3e1SJohn Birrell 	size_t	len	= 0;
3991eaf3e1SJohn Birrell 
4091eaf3e1SJohn Birrell 	mutex_enter(&dtrace_provider_lock);
4191eaf3e1SJohn Birrell 	mutex_enter(&dtrace_lock);
4291eaf3e1SJohn Birrell 
4391eaf3e1SJohn Birrell 	/* Compute the length of the space-separated provider name string. */
4491eaf3e1SJohn Birrell 	while (prov != NULL) {
4591eaf3e1SJohn Birrell 		len += strlen(prov->dtpv_name) + 1;
4691eaf3e1SJohn Birrell 		prov = prov->dtpv_next;
4791eaf3e1SJohn Birrell 	}
4891eaf3e1SJohn Birrell 
4991eaf3e1SJohn Birrell 	if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL)
5091eaf3e1SJohn Birrell 		error = ENOMEM;
5191eaf3e1SJohn Birrell 	else {
5291eaf3e1SJohn Birrell 		/* Start with an empty string. */
5391eaf3e1SJohn Birrell 		*p_name = '\0';
5491eaf3e1SJohn Birrell 
5591eaf3e1SJohn Birrell 		/* Point to the first provider again. */
5691eaf3e1SJohn Birrell 		prov = dtrace_provider;
5791eaf3e1SJohn Birrell 
5891eaf3e1SJohn Birrell 		/* Loop through the providers, appending the names. */
5991eaf3e1SJohn Birrell 		while (prov != NULL) {
6091eaf3e1SJohn Birrell 			if (prov != dtrace_provider)
6191eaf3e1SJohn Birrell 				(void) strlcat(p_name, " ", len);
6291eaf3e1SJohn Birrell 
6391eaf3e1SJohn Birrell 			(void) strlcat(p_name, prov->dtpv_name, len);
6491eaf3e1SJohn Birrell 
6591eaf3e1SJohn Birrell 			prov = prov->dtpv_next;
6691eaf3e1SJohn Birrell 		}
6791eaf3e1SJohn Birrell 	}
6891eaf3e1SJohn Birrell 
6991eaf3e1SJohn Birrell 	mutex_exit(&dtrace_lock);
7091eaf3e1SJohn Birrell 	mutex_exit(&dtrace_provider_lock);
7191eaf3e1SJohn Birrell 
7291eaf3e1SJohn Birrell 	if (p_name != NULL) {
7391eaf3e1SJohn Birrell 		error = sysctl_handle_string(oidp, p_name, len, req);
7491eaf3e1SJohn Birrell 
7591eaf3e1SJohn Birrell 		kmem_free(p_name, 0);
7691eaf3e1SJohn Birrell 	}
7791eaf3e1SJohn Birrell 
7891eaf3e1SJohn Birrell 	return (error);
7991eaf3e1SJohn Birrell }
8091eaf3e1SJohn Birrell 
8191eaf3e1SJohn Birrell SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD,
82b53bfbbaSMark Johnston     0, 0, sysctl_dtrace_providers, "A", "available DTrace providers");
8391eaf3e1SJohn Birrell 
84b53bfbbaSMark Johnston SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace parameters");
85b53bfbbaSMark Johnston 
86b53bfbbaSMark Johnston SYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max,
87e572bc11SMark Johnston     0, "largest allowed argument to memstr(), 0 indicates no limit");
88b53bfbbaSMark Johnston 
89*f0188618SHans Petter Selasky SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW,
90b53bfbbaSMark Johnston     &dtrace_dof_maxsize, 0, "largest allowed DOF table");
91b53bfbbaSMark Johnston 
92*f0188618SHans Petter Selasky SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW,
93b53bfbbaSMark Johnston     &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions");
94