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.
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.
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]
28 dtrace_state_t *state;
31 destroy_dev(dtrace_dev);
33 mutex_enter(&dtrace_provider_lock);
34 mutex_enter(&dtrace_lock);
35 mutex_enter(&cpu_lock);
37 ASSERT(dtrace_opens == 0);
39 if (dtrace_helpers > 0) {
40 mutex_exit(&cpu_lock);
41 mutex_exit(&dtrace_lock);
42 mutex_exit(&dtrace_provider_lock);
46 if (dtrace_unregister((dtrace_provider_id_t)dtrace_provider) != 0) {
47 mutex_exit(&cpu_lock);
48 mutex_exit(&dtrace_lock);
49 mutex_exit(&dtrace_provider_lock);
53 dtrace_provider = NULL;
55 if ((state = dtrace_anon_grab()) != NULL) {
57 * If there were ECBs on this state, the provider should
58 * have not been allowed to detach; assert that there is
61 ASSERT(state->dts_necbs == 0);
62 dtrace_state_destroy(state);
65 bzero(&dtrace_anon, sizeof (dtrace_anon_t));
67 mutex_exit(&cpu_lock);
69 if (dtrace_helptrace_enabled) {
70 kmem_free(dtrace_helptrace_buffer, 0);
71 dtrace_helptrace_buffer = NULL;
74 if (dtrace_probes != NULL) {
75 kmem_free(dtrace_probes, 0);
80 dtrace_hash_destroy(dtrace_bymod);
81 dtrace_hash_destroy(dtrace_byfunc);
82 dtrace_hash_destroy(dtrace_byname);
87 kmem_cache_destroy(dtrace_state_cache);
89 delete_unrhdr(dtrace_arena);
91 if (dtrace_toxrange != NULL) {
92 kmem_free(dtrace_toxrange, 0);
93 dtrace_toxrange = NULL;
95 dtrace_toxranges_max = 0;
98 ASSERT(dtrace_vtime_references == 0);
99 ASSERT(dtrace_opens == 0);
100 ASSERT(dtrace_retained == NULL);
102 mutex_exit(&dtrace_lock);
103 mutex_exit(&dtrace_provider_lock);
105 mutex_destroy(&dtrace_meta_lock);
106 mutex_destroy(&dtrace_provider_lock);
107 mutex_destroy(&dtrace_lock);
108 mutex_destroy(&dtrace_errlock);
111 mutex_destroy(&mod_lock);
113 /* Reset our hook for exceptions. */
114 dtrace_invop_uninit();
117 * Reset our hook for thread switches, but ensure that vtime isn't
120 dtrace_vtime_active = 0;
121 dtrace_vtime_switch_func = NULL;
123 /* Unhook from the trap handler. */
124 dtrace_trap_func = NULL;