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 2591eaf3e1SJohn Birrell int dtrace_debug = 0; 2691eaf3e1SJohn Birrell TUNABLE_INT("debug.dtrace.debug", &dtrace_debug); 2791eaf3e1SJohn Birrell SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); 2891eaf3e1SJohn Birrell 2991eaf3e1SJohn Birrell /* Report registered DTrace providers. */ 3091eaf3e1SJohn Birrell static int 3191eaf3e1SJohn Birrell sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) 3291eaf3e1SJohn Birrell { 3391eaf3e1SJohn Birrell char *p_name = NULL; 3491eaf3e1SJohn Birrell dtrace_provider_t 3591eaf3e1SJohn Birrell *prov = dtrace_provider; 3691eaf3e1SJohn Birrell int error = 0; 3791eaf3e1SJohn Birrell size_t len = 0; 3891eaf3e1SJohn Birrell 3991eaf3e1SJohn Birrell mutex_enter(&dtrace_provider_lock); 4091eaf3e1SJohn Birrell mutex_enter(&dtrace_lock); 4191eaf3e1SJohn Birrell 4291eaf3e1SJohn Birrell /* Compute the length of the space-separated provider name string. */ 4391eaf3e1SJohn Birrell while (prov != NULL) { 4491eaf3e1SJohn Birrell len += strlen(prov->dtpv_name) + 1; 4591eaf3e1SJohn Birrell prov = prov->dtpv_next; 4691eaf3e1SJohn Birrell } 4791eaf3e1SJohn Birrell 4891eaf3e1SJohn Birrell if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL) 4991eaf3e1SJohn Birrell error = ENOMEM; 5091eaf3e1SJohn Birrell else { 5191eaf3e1SJohn Birrell /* Start with an empty string. */ 5291eaf3e1SJohn Birrell *p_name = '\0'; 5391eaf3e1SJohn Birrell 5491eaf3e1SJohn Birrell /* Point to the first provider again. */ 5591eaf3e1SJohn Birrell prov = dtrace_provider; 5691eaf3e1SJohn Birrell 5791eaf3e1SJohn Birrell /* Loop through the providers, appending the names. */ 5891eaf3e1SJohn Birrell while (prov != NULL) { 5991eaf3e1SJohn Birrell if (prov != dtrace_provider) 6091eaf3e1SJohn Birrell (void) strlcat(p_name, " ", len); 6191eaf3e1SJohn Birrell 6291eaf3e1SJohn Birrell (void) strlcat(p_name, prov->dtpv_name, len); 6391eaf3e1SJohn Birrell 6491eaf3e1SJohn Birrell prov = prov->dtpv_next; 6591eaf3e1SJohn Birrell } 6691eaf3e1SJohn Birrell } 6791eaf3e1SJohn Birrell 6891eaf3e1SJohn Birrell mutex_exit(&dtrace_lock); 6991eaf3e1SJohn Birrell mutex_exit(&dtrace_provider_lock); 7091eaf3e1SJohn Birrell 7191eaf3e1SJohn Birrell if (p_name != NULL) { 7291eaf3e1SJohn Birrell error = sysctl_handle_string(oidp, p_name, len, req); 7391eaf3e1SJohn Birrell 7491eaf3e1SJohn Birrell kmem_free(p_name, 0); 7591eaf3e1SJohn Birrell } 7691eaf3e1SJohn Birrell 7791eaf3e1SJohn Birrell return (error); 7891eaf3e1SJohn Birrell } 7991eaf3e1SJohn Birrell 8091eaf3e1SJohn Birrell SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD, 8191eaf3e1SJohn Birrell 0, 0, sysctl_dtrace_providers, "A", ""); 8291eaf3e1SJohn Birrell 83*e572bc11SMark Johnston SYSCTL_INT(_debug_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max, 84*e572bc11SMark Johnston 0, "largest allowed argument to memstr(), 0 indicates no limit"); 85