dtrace_sysctl.c revision 269520
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 * 21 * $FreeBSD: stable/10/sys/cddl/dev/dtrace/dtrace_sysctl.c 269520 2014-08-04 15:36:22Z markj $ 22 * 23 */ 24 25SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters"); 26 27int dtrace_debug = 0; 28TUNABLE_INT("debug.dtrace.debug", &dtrace_debug); 29SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); 30 31/* Report registered DTrace providers. */ 32static int 33sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) 34{ 35 char *p_name = NULL; 36 dtrace_provider_t 37 *prov = dtrace_provider; 38 int error = 0; 39 size_t len = 0; 40 41 mutex_enter(&dtrace_provider_lock); 42 mutex_enter(&dtrace_lock); 43 44 /* Compute the length of the space-separated provider name string. */ 45 while (prov != NULL) { 46 len += strlen(prov->dtpv_name) + 1; 47 prov = prov->dtpv_next; 48 } 49 50 if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL) 51 error = ENOMEM; 52 else { 53 /* Start with an empty string. */ 54 *p_name = '\0'; 55 56 /* Point to the first provider again. */ 57 prov = dtrace_provider; 58 59 /* Loop through the providers, appending the names. */ 60 while (prov != NULL) { 61 if (prov != dtrace_provider) 62 (void) strlcat(p_name, " ", len); 63 64 (void) strlcat(p_name, prov->dtpv_name, len); 65 66 prov = prov->dtpv_next; 67 } 68 } 69 70 mutex_exit(&dtrace_lock); 71 mutex_exit(&dtrace_provider_lock); 72 73 if (p_name != NULL) { 74 error = sysctl_handle_string(oidp, p_name, len, req); 75 76 kmem_free(p_name, 0); 77 } 78 79 return (error); 80} 81 82SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD, 83 0, 0, sysctl_dtrace_providers, "A", "available DTrace providers"); 84 85SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace parameters"); 86 87SYSCTL_LONG(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW, 88 &dtrace_dof_maxsize, 0, "largest allowed DOF table"); 89 90SYSCTL_LONG(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW, 91 &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions"); 92 93SYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max, 94 0, "largest allowed argument to memstr(), 0 indicates no limit"); 95