1179237Sjb/*
2179237Sjb * CDDL HEADER START
3179237Sjb *
4179237Sjb * The contents of this file are subject to the terms of the
5179237Sjb * Common Development and Distribution License (the "License").
6179237Sjb * You may not use this file except in compliance with the License.
7179237Sjb *
8179237Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9179237Sjb * or http://www.opensolaris.org/os/licensing.
10179237Sjb * See the License for the specific language governing permissions
11179237Sjb * and limitations under the License.
12179237Sjb *
13179237Sjb * When distributing Covered Code, include this CDDL HEADER in each
14179237Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15179237Sjb * If applicable, add the following below this CDDL HEADER, with the
16179237Sjb * fields enclosed by brackets "[]" replaced with your own identifying
17179237Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
18179237Sjb *
19179237Sjb * CDDL HEADER END
20179237Sjb *
21179237Sjb * $FreeBSD$
22179237Sjb *
23179237Sjb */
24179237Sjb
25179237Sjbint	dtrace_debug = 0;
26179237SjbTUNABLE_INT("debug.dtrace.debug", &dtrace_debug);
27179237SjbSYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, "");
28179237Sjb
29179237Sjb/* Report registered DTrace providers. */
30179237Sjbstatic int
31179237Sjbsysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
32179237Sjb{
33179237Sjb	char	*p_name	= NULL;
34179237Sjb	dtrace_provider_t
35179237Sjb		*prov	= dtrace_provider;
36179237Sjb	int	error	= 0;
37179237Sjb	size_t	len	= 0;
38179237Sjb
39179237Sjb	mutex_enter(&dtrace_provider_lock);
40179237Sjb	mutex_enter(&dtrace_lock);
41179237Sjb
42179237Sjb	/* Compute the length of the space-separated provider name string. */
43179237Sjb	while (prov != NULL) {
44179237Sjb		len += strlen(prov->dtpv_name) + 1;
45179237Sjb		prov = prov->dtpv_next;
46179237Sjb	}
47179237Sjb
48179237Sjb	if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL)
49179237Sjb		error = ENOMEM;
50179237Sjb	else {
51179237Sjb		/* Start with an empty string. */
52179237Sjb		*p_name = '\0';
53179237Sjb
54179237Sjb		/* Point to the first provider again. */
55179237Sjb		prov = dtrace_provider;
56179237Sjb
57179237Sjb		/* Loop through the providers, appending the names. */
58179237Sjb		while (prov != NULL) {
59179237Sjb			if (prov != dtrace_provider)
60179237Sjb				(void) strlcat(p_name, " ", len);
61179237Sjb
62179237Sjb			(void) strlcat(p_name, prov->dtpv_name, len);
63179237Sjb
64179237Sjb			prov = prov->dtpv_next;
65179237Sjb		}
66179237Sjb	}
67179237Sjb
68179237Sjb	mutex_exit(&dtrace_lock);
69179237Sjb	mutex_exit(&dtrace_provider_lock);
70179237Sjb
71179237Sjb	if (p_name != NULL) {
72179237Sjb		error = sysctl_handle_string(oidp, p_name, len, req);
73179237Sjb
74179237Sjb		kmem_free(p_name, 0);
75179237Sjb	}
76179237Sjb
77179237Sjb	return (error);
78179237Sjb}
79179237Sjb
80179237SjbSYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD,
81179237Sjb    0, 0, sysctl_dtrace_providers, "A", "");
82179237Sjb
83