'\" te .\" Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH TNFCTL_BUFFER_ALLOC 3TNF "Mar 4, 1997" .SH NAME tnfctl_buffer_alloc, tnfctl_buffer_dealloc \- allocate or deallocate a buffer for trace data .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-ltnfctl\fR [ \fIlibrary\fR ... ] #include \fBtnfctl_errcode_t\fR \fBtnfctl_buffer_alloc\fR(\fBtnfctl_handle_t *\fR\fIhndl\fR, \fBconst char *\fR\fItrace_file_name\fR, \fBsize_t\fR \fItrace_buffer_size\fR); .fi .LP .nf \fB\fR\fBtnfctl_buffer_dealloc\fR(\fBtnfctl_handle_t *\fR\fIhndl\fR); .fi .SH DESCRIPTION .sp .LP \fBtnfctl_buffer_alloc()\fR allocates a buffer to which trace events are logged. When tracing a process using a \fBtnfctl\fR handle returned by \fBtnfctl_pid_open\fR(3TNF), \fBtnfctl_exec_open\fR(3TNF), \fBtnfctl_indirect_open\fR(3TNF), and \fBtnfctl_internal_open\fR(3TNF)), \fItrace_file_name\fR is the name of the trace file to which trace events should be logged. It can be an absolute path specification or a relative path specification. If it is relative, the current working directory of the process that is calling \fBtnfctl_buffer_alloc()\fR is prefixed to \fItrace_file_name\fR. If the named trace file already exists, it is overwritten. For kernel tracing, that is, for a tnfctl handle returned by \fBtnfctl_kernel_open\fR(3TNF), trace events are logged to a trace buffer in memory; therefore, \fItrace_file_name\fR is ignored. Use \fBtnfxtract\fR(1) to extract a kernel buffer into a file. .sp .LP \fItrace_buffer_size\fR is the size in bytes of the trace buffer that should be allocated. An error is returned if an attempt is made to allocate a buffer when one already exists. \fBtnfctl_buffer_alloc()\fR affects the trace attributes; use \fBtnfctl_trace_attrs_get\fR(3TNF) to get the latest trace attributes after a buffer is allocated. .sp .LP \fBtnfctl_buffer_dealloc()\fR is used to deallocate a kernel trace buffer that is no longer needed. \fIhndl\fR must be a kernel handle, returned by \fBtnfctl_kernel_open\fR(3TNF). A process's trace file cannot be deallocated using \fBtnfctl_buffer_dealloc()\fR. Instead, once the trace file is no longer needed for analysis and after the process being traced exits, use \fBrm\fR(1) to remove the trace file. Do not remove the trace file while the process being traced is still alive. \fBtnfctl_buffer_dealloc()\fR affects the trace attributes; use \fBtnfctl_trace_attrs_get\fR(3TNF) to get the latest trace attributes after a buffer is deallocated. .sp .LP For a complete discussion of \fBtnf tracing\fR, see \fBtracing\fR(3TNF). .SH RETURN VALUES .sp .LP \fBtnfctl_buffer_alloc()\fR and \fBtnfctl_buffer_dealloc()\fR return \fBTNFCTL_ERR_NONE\fR upon success. .SH ERRORS .sp .LP The following error codes apply to \fBtnfctl_buffer_alloc()\fR: .sp .ne 2 .na \fB\fBTNFCTL_ERR_BUFEXISTS\fR\fR .ad .RS 27n A buffer already exists. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_ACCES\fR\fR .ad .RS 27n Permission denied; could not create a trace file. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_SIZETOOSMALL\fR\fR .ad .RS 27n The \fItrace_buffer_size\fR requested is smaller than the minimum trace buffer size needed. Use \fBtrace_min_size\fR of trace attributes in \fBtnfctl_trace_attrs_get\fR(3TNF) to determine the minimum size of the buffer. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_SIZETOOBIG\fR\fR .ad .RS 27n The requested trace file size is too big. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_BADARG\fR\fR .ad .RS 27n \fItrace_file_name\fR is \fINULL\fR or the absolute path name is longer than \fBMAX\fR\fBPATH\fR\fBLEN.\fR .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_ALLOCFAIL\fR\fR .ad .RS 27n A memory allocation failure occurred. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_INTERNAL\fR\fR .ad .RS 27n An internal error occurred. .RE .sp .LP The following error codes apply to \fBtnfctl_buffer_dealloc()\fR: .sp .ne 2 .na \fB\fBTNFCTL_ERR_BADARG\fR\fR .ad .RS 25n \fIhndl\fR is not a kernel handle. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_NOBUF\fR\fR .ad .RS 25n No buffer exists to deallocate. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_BADDEALLOC\fR\fR .ad .RS 25n Cannot deallocate a trace buffer unless tracing is stopped. Use \fBtnfctl_trace_state_set\fR(3TNF) to stop tracing. .RE .sp .ne 2 .na \fB\fBTNFCTL_ERR_INTERNAL\fR\fR .ad .RS 25n An internal error occurred. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ MT Level MT-Safe .TE .SH SEE ALSO .sp .LP \fBprex\fR(1), \fBrm\fR(1), \fBtnfxtract\fR(1), \fBTNF_PROBE\fR(3TNF), \fBlibtnfctl\fR(3TNF), \fBtnfctl_exec_open\fR(3TNF), \fBtnfctl_indirect_open\fR(3TNF), \fBtnfctl_internal_open\fR(3TNF), \fBtnfctl_kernel_open\fR(3TNF), \fBtnfctl_pid_open\fR(3TNF), \fBtnfctl_trace_attrs_get\fR(3TNF), \fBtracing\fR(3TNF), \fBattributes\fR(5)