'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 05/25/2021 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.2.0 .\" Language: English .\" .TH "LIBTRACEFS" "3" "05/25/2021" "libtracefs 1\&.2\&.0" "libtracefs Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" tracefs_instance_create, tracefs_instance_destroy, tracefs_instance_alloc, tracefs_instance_free, tracefs_instance_is_new \- Manage trace instances\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR struct tracefs_instance *\fBtracefs_instance_create\fR(const char *\fIname\fR); int \fBtracefs_instance_destroy\fR(struct tracefs_instance *\fIinstance\fR); struct tracefs_instance *\fBtracefs_instance_alloc\fR(const char *\fItracing_dir\fR, const char *\fIname\fR); void \fBtracefs_instance_free\fR(struct tracefs_instance *\fIinstance\fR); bool \fBtracefs_instance_is_new\fR(struct tracefs_instance *\fIinstance\fR); .fi .SH "DESCRIPTION" .sp This set of functions can be used to manage trace instances\&. A trace instance is a sub buffer used by the Linux tracing system\&. Given a unique name, the events enabled in an instance do not affect the main tracing system, nor other instances, as events enabled in the main tracing system or other instances do not affect the given instance\&. .sp The \fItracefs_instance_create()\fR function allocates and initializes a new tracefs_instance structure and returns it\&. If the instance with \fIname\fR does not yet exist in the system, it will be created\&. The \fIname\fR could be NULL, then the new tracefs_instance structure is initialised for the top instance\&. Note that the top instance cannot be created in the system, if it does not exist\&. .sp The \fItracefs_instance_destroy()\fR removes the instance from the system, but does not free the structure\&. \fItracefs_instance_free()_\fR must still be called on \fIinstance\fR\&. .sp The \fItracefs_instance_alloc()\fR function allocates a new tracefs_instance structure for existing trace instance\&. If the instance does not exist in the system, the function fails\&. The \fItracing_dir\fR parameter points to the system trace directory\&. It can be NULL, then default system trace directory is used\&. This parameter is useful to allocate instances to trace directories, copied from another machine\&. The \fIname\fR is the name of the instance, or NULL for the top instance in the given \fItracing_dir\fR\&. .sp The \fItracefs_instance_free()\fR function frees the tracefs_instance structure, without removing the trace instance from the system\&. .sp The \fItracefs_instance_is_new()\fR function checks if the given \fIinstance\fR is newly created by \fItracefs_instance_create()\fR, or it has been in the system before that\&. .SH "RETURN VALUE" .sp The \fItracefs_instance_create()\fR and \fItracefs_instance_alloc()\fR functions return a pointer to a newly allocated tracefs_instance structure\&. It must be freed with \fItracefs_instance_free()\fR\&. .sp The \fItracefs_instance_destroy()\fR function returns 0 if it succeeds to remove the instance, otherwise it returns \-1 if the instance does not exist or it fails to remove it\&. .sp The \fItracefs_instance_is_new()\fR function returns true if the \fItracefs_instance_create()\fR that allocated \fIinstance\fR also created the trace instance in the system, or false if the trace instance already existed in the system when \fIinstance\fR was allocated by \fItracefs_instance_create()\fR or \fItracefs_instance_alloc()\fR\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include struct tracefs_instance *inst = tracefs_instance_create("foo"); if (!inst) { /* Error creating a new trace instance */ \&.\&.\&. } \&.\&.\&. if (tracefs_instance_is_new(inst)) tracefs_instance_destroy(inst); tracefs_instance_free(inst); \&.\&.\&. struct tracefs_instance *inst = tracefs_instance_alloc(NULL, "bar"); if (!inst) { /* Error allocating \*(Aqbar\*(Aq trace instance */ \&.\&.\&. } \&.\&.\&. tracefs_instance_free(inst); .fi .if n \{\ .RE .\} .SH "FILES" .sp .if n \{\ .RS 4 .\} .nf \fBtracefs\&.h\fR Header file to include in order to have access to the library APIs\&. \fB\-ltracefs\fR Linker switch to add when building a program that uses the library\&. .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fIlibtracefs(3)\fR, \fIlibtraceevent(3)\fR, \fItrace\-cmd(1)\fR .SH "AUTHOR" .sp .if n \{\ .RS 4 .\} .nf \fBSteven Rostedt\fR <\m[blue]\fBrostedt@goodmis\&.org\fR\m[]\&\s-2\u[1]\d\s+2> \fBTzvetomir Stoyanov\fR <\m[blue]\fBtz\&.stoyanov@gmail\&.com\fR\m[]\&\s-2\u[2]\d\s+2> .fi .if n \{\ .RE .\} .SH "REPORTING BUGS" .sp Report bugs to <\m[blue]\fBlinux\-trace\-devel@vger\&.kernel\&.org\fR\m[]\&\s-2\u[3]\d\s+2> .SH "LICENSE" .sp libtracefs is Free Software licensed under the GNU LGPL 2\&.1 .SH "RESOURCES" .sp \m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/libs/libtrace/libtracefs\&.git/\fR\m[] .SH "COPYING" .sp Copyright (C) 2020 VMware, Inc\&. Free use of this software is granted under the terms of the GNU Public License (GPL)\&. .SH "NOTES" .IP " 1." 4 rostedt@goodmis.org .RS 4 \%mailto:rostedt@goodmis.org .RE .IP " 2." 4 tz.stoyanov@gmail.com .RS 4 \%mailto:tz.stoyanov@gmail.com .RE .IP " 3." 4 linux-trace-devel@vger.kernel.org .RS 4 \%mailto:linux-trace-devel@vger.kernel.org .RE