'\" 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_local_events, tracefs_local_events_system, tracefs_fill_local_events, tracefs_load_cmdlines \- Initialize a tep handler with trace events from the local system\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR struct tep_handle *\fBtracefs_local_events\fR(const char *\fItracing_dir\fR); struct tep_handle *\fBtracefs_local_events_system\fR(const char *\fItracing_dir\fR, const char * const *\fIsys_names\fR); int \fBtracefs_fill_local_events\fR(const char *\fItracing_dir\fR, struct tep_handle *\fItep\fR, int *\fIparsing_failures\fR); int \fBtracefs_load_cmdlines\fR(const char *\fItracing_dir\fR, struct tep_handle *\fItep\fR); .fi .SH "DESCRIPTION" .sp Functions for initializing a tep handler with trace events from the local system\&. .sp The \fBtracefs_local_events()\fR function allocates a new \fItep\fR handler and initializes it with events from all trace systems, 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\&. .sp The \fBtracefs_local_events_system()\fR function allocates a new \fItep\fR handler and initializes it with events from specified trace systems \fIsys_names\fR, 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 \fIsys_names\fR argument is an array of trace system names, that will be used for \fItep\fR handler initialization\&. The last element in that array must be a NULL pointer\&. .sp The \fBtracefs_fill_local_events()\fR function initializes already allocated \fItep\fR handler with events from all trace systems, 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 \fItep\fR argument must be a pointer to already allocated tep handler, that is going to be initialized\&. The \fIparsing_failures\fR argument could be NULL or a pointer to an integer, where the number of failures while parsing the event files are returned\&. .sp The above functions will also load the mappings between pids and the process command line names\&. In some cases the \fItep\fR handle is created with one of the above before tracing begins\&. As the mappings get updated during the trace, there may be a need to read the mappings again after the trace\&. The \fBtracefs_load_cmdlines()\fR does just that\&. The \fItracing_dir\fR is the directory of the mount point to load from, or NULL to use the mount point of the tracefs file system\&. .SH "RETURN VALUE" .sp The \fBtracefs_local_events()\fR and \fBtracefs_local_events_system()\fR functions return pointer to allocated and initialized \fItep\fR handler, or NULL in case of an error\&. The returned \fItep\fR handler must be freed with \fBtep_free\fR(3)\&. .sp The \fBtracefs_fill_local_events()\fR function returns \-1 in case of an error or 0 otherwise\&. .sp The \fBtracefs_load_cmdlines()\fR function returns \-1 in case of an error, or 0 otherwise\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include struct tep_handle *tep; \&.\&.\&. tep = tracefs_local_events(NULL); if (!tep) { /* Failed to initialise tep handler with local events from top instance */ \&.\&.\&. } \&.\&.\&. tep_free(tep); \&.\&.\&. const char *systems[] = {"ftrace", "irq", NULL}; tep = tracefs_local_events_system(NULL, systems); if (!tep) { /* Failed to initialise tep handler with local events from * ftrace and irq systems in top instance\&. */ \&.\&.\&. } \&.\&.\&. tep_free(tep); \&.\&.\&. int parsing_failures; tep = tep_alloc(); if (!tep) { /* Failed to allocate a tep handler */ \&.\&.\&. } if (tracefs_fill_local_events(NULL, tep, &parsing_failures) < 0) { /* Failed to initialise tep handler with local events from top instance */ } tracefs_load_cmdlines(NULL, tep); \&.\&.\&. tep_free(tep); .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