4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1994-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <sys/debug.h>
37 #include <sys/thread.h>
38 #include <sys/dtrace.h>
41 #include "tnf_types.h"
42 #include "tnf_trace.h"
50 size_t tnf_trace_file_size
= TNF_TRACE_FILE_DEFAULT
;
58 TNFW_B_UNSET_STOPPED(tnfw_b_state
);
59 tnf_tracing_active
= 1;
60 dtrace_vtime_enable_tnf();
61 /* Enable system call tracing for all processes */
71 TNFW_B_SET_STOPPED(tnfw_b_state
);
72 dtrace_vtime_disable_tnf();
73 tnf_tracing_active
= 0;
74 /* System call tracing is automatically disabled */
79 * Not reentrant: only called from tnf_allocbuf(), which is
88 ASSERT(tnf_buf
!= NULL
);
89 ASSERT(!tnf_tracing_active
);
91 stopped
= tnfw_b_state
& TNFW_B_STOPPED
;
94 * Initialize the buffer
96 tnfw_b_init_buffer(tnf_buf
, tnf_trace_file_size
);
99 * Mark allocator running (not stopped). Luckily,
100 * tnf_trace_alloc() first checks tnf_tracing_active, so no
101 * trace data will be written.
103 tnfw_b_state
= TNFW_B_RUNNING
;
106 * 1195835: Write out some tags now. The stopped bit needs
107 * to be clear while we do this.
109 /* LINTED pointer cast may result in improper alignment */
110 if ((ops
= (tnf_ops_t
*)curthread
->t_tnf_tpdp
) != NULL
) {
114 ASSERT(!LOCK_HELD(&ops
->busy
));
115 LOCK_INIT_HELD(&ops
->busy
); /* XXX save a call */
117 tag
= TAG_DATA(tnf_struct_type
);
118 (void) tag
->tag_desc(ops
, tag
);
119 tag
= TAG_DATA(tnf_probe_type
);
120 (void) tag
->tag_desc(ops
, tag
);
121 tag
= TAG_DATA(tnf_kernel_schedule
);
122 (void) tag
->tag_desc(ops
, tag
);
124 pos
= &ops
->wcb
.tnfw_w_tag_pos
;
126 pos
= &ops
->wcb
.tnfw_w_pos
;
127 TNFW_B_ROLLBACK(pos
);
129 LOCK_INIT_CLEAR(&ops
->busy
); /* XXX save a call */
132 /* Restore stopped bit */
133 tnfw_b_state
|= stopped
;