'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/08/2022 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.5.0 .\" Language: English .\" .TH "LIBTRACEFS" "3" "10/08/2022" "libtracefs 1\&.5\&.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, tracefs_instances \- 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); char **\fBtracefs_instances\fR(const char *\fIregex\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 \fBtracefs_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 initialized for the top instance\&. Note that the top instance cannot be created in the system, if it does not exist\&. .sp The \fBtracefs_instance_destroy()\fR removes the instance from the system, but does not free the structure\&. \fBtracefs_instance_free()\fR must still be called on \fIinstance\fR\&. .sp The tracefs_instance_alloc()* 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 \fBtracefs_instance_free()\fR function frees the tracefs_instance structure, without removing the trace instance from the system\&. .sp The \fBtracefs_instance_is_new()\fR function checks if the given \fIinstance\fR is newly created by \fBtracefs_instance_create()\fR, or it has been in the system before that\&. .sp The \fBtracefs_instances\fR() function returns a list of instances that exist in the system that match the regular expression \fIregex\fR\&. If \fIregex\fR is NULL, then it will match all instances that exist\&. The returned list must be freed with \fBtracefs_list_free\fR(3)\&. Note, if no instances are found an empty list is returned and that too needs to be free with \fBtracefs_list_free\fR(3)\&. .SH "RETURN VALUE" .sp The \fBtracefs_instance_create()\fR and \fBtracefs_instance_alloc()\fR functions return a pointer to a newly allocated tracefs_instance structure\&. It must be freed with \fBtracefs_instance_free()\fR\&. .sp The \fBtracefs_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 \fBtracefs_instance_is_new()\fR function returns true if the \fBtracefs_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 \fBtracefs_instance_create()\fR or \fBtracefs_instance_alloc()\fR\&. .sp The \fBtracefs_instances()\fR returns a list of instance names that exist on the system\&. The list must be freed with \fBtracefs_list_free\fR(3)\&. An empty list is returned if no instance exists that matches \fIregex\fR, and this needs to be freed with \fBtracefs_list_free\fR(3) as well\&. NULL is returned on error\&. .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 \fBlibtracefs\fR(3), \fBlibtraceevent\fR(3), \fBtrace\-cmd\fR(1) .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