'\" 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_tracers, tracefs_tracer_available, tracefs_get_clock, tracefs_list_free, tracefs_list_add, tracefs_list_size \- Helper functions for working with trace file system\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR char **\fBtracefs_tracers\fR(const char *\fItracing_dir\fR); bool \fBtracefs_tracer_available\fR(const char *\fItracing_dir\fR, const char *\fItracer\fR); char *\fBtracefs_get_clock\fR(struct tracefs_instance *\fIinstance\fR); void \fBtracefs_list_free\fR(char **\fIlist\fR); char **\fBtracefs_list_add\fR(char \fB*\fR\fB\fIlist\fR\fR\fB, const char *\fR\fB\fIstring\fR\fR\fB); int *tracefs_list_size\fR(char **\fIlist\fR); .fi .SH "DESCRIPTION" .sp Various useful functions for working with trace file system\&. .sp The \fBtracefs_tracers()\fR function returns array of strings with the names of supported tracer plugins, located in the given \fItracing_dir\fR directory\&. This could be NULL or the location of the tracefs mount point for the trace systems of the local machine, or it may be a path to a copy of the tracefs directory from another machine\&. The last entry in the array as a NULL pointer\&. The array must be freed with \fBtracefs_list_free()\fR API\&. .sp The \fBtracefs_tracer_available()\fR returns true if the \fItracer\fR is available in the given \fItracing_dir_director\fR, and false otherwise\&. .sp The \fBtracefs_get_clock()\fR function returns name of the current trace clock, used in the given \fIinstance\fR\&. If \fIinstance\fR is NULL, the clock of the main trace instance is returned\&. The returned string must be freed with free()\&. .sp The \fBtracefs_list_free()\fR function frees an array of strings, returned by \fBtracefs_event_systems()\fR, \fBtracefs_system_events()\fR and \fBtracefs_tracers()\fR APIs\&. .sp The \fBtracefs_list_add()\fR function adds \fIstring\fR to the string \fIlist\fR\&. If \fIlist\fR is NULL, then a new list is created with the first element a copy of \fIstring\fR, and the second element will be a NULL pointer\&. If \fIlist\fR is not NULL, then it is reallocated to include a new element and a NULL terminator, and the new allocated array is returned\&. The list passed in should be ignored, as it wil be freed if a new one was allocated\&. .sp The \fBtracefs_list_size()\fR is a fast way to find out the number of elements in a string array that is to be freed with \fBtracefs_list_free()\fR\&. Note, this depends on meta data that is created for these lists and will not work on normal string arrays like argv\&. .SH "RETURN VALUE" .sp The \fBtracefs_tracers()\fR returns array of strings\&. The last element in that array is a NULL pointer\&. The array must be freed with \fBtracefs_list_free()\fR API\&. In case of an error, NULL is returned\&. .sp The \fBtracefs_tracer_available()\fR returns true if the \fItracer\fR is available, and false otherwise\&. .sp The \fBtracefs_get_clock()\fR returns string, that must be freed with free(), or NULL in case of an error\&. .sp The \fBtracefs_list_add()\fR returns an allocated string array that must be freed with \fBtracefs_list_free()\fR on success or NULL on error\&. If NULL is returned, then the passed in \fIlist\fR is untouched\&. Thus, \fBtracefs_list_add()\fR should be treated similarly to \fBrealloc\fR(3)\&. .sp The \fBtracefs_list_size()\fR returns the number of strings in the \fIlist\fR\&. The passed in list must be one that is to be freed with \fBtracefs_list_free()\fR as the list has meta data that is used to determine the size and this does not work on any normal string array like argv\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include char **tracers = tracefs_tracers(NULL); if (tracers) { /* Got tracer plugins from the top trace instance */ \&.\&.\&. tracefs_list_free(tracers); } \&.\&.\&.\&. char *clock = tracefs_get_clock(NULL); if (clock) { /* Got current trace clock of the top trace instance */ \&.\&.\&. free(clock); } .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