'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/15/2021 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.0.2 .\" Language: English .\" .TH "LIBTRACEFS" "3" "01/15/2021" "libtracefs 1\&.0\&.2" "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_event_systems, tracefs_system_events, tracefs_iterate_raw_events \- Work with trace systems and events\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR char **\fBtracefs_event_systems\fR(const char *\fItracing_dir\fR); char **\fBtracefs_system_events\fR(const char *\fItracing_dir\fR, const char *\fIsystem\fR); int \fBtracefs_iterate_raw_events\fR(struct tep_handle *\fItep\fR, struct tracefs_instance *\fIinstance\fR, cpu_set_t *\fIcpus\fR, int \fIcpu_size\fR, int (*\fIcallback\fR)(struct tep_event *, struct tep_record *, int, void *), void *\fIcallback_context\fR); .fi .SH "DESCRIPTION" .sp Trace systems and events related APIs\&. .sp The \fItracefs_event_systems()\fR function returns array of strings with the names of all registered 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 last entry in the array is a NULL pointer\&. The array must be freed with \fItracefs_list_free()\fR API\&. .sp The \fItracefs_system_events()\fR function returns array of strings with the names of all registered trace events for given trace system specified by \fIsystem\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 last entry in the array as a NULL pointer\&. The array must be freed with \fItracefs_list_free()\fR API\&. .sp The \fItracefs_interate_raw_events()\fR function will read the tracefs raw data buffers and call the specified \fIcallback\fR function for every event it encounters\&. An initialized \fItep\fR handler is required (See \fItracefs_local_events\fR(3))\&. If \fIinstance\fR is NULL, then the toplevel tracefs buffer is used, otherwise the buffer for the corresponding \fIinstance\fR is read\&. To filter only on a subset of CPUs, \fIcpus\fR and \fIcpu_size\fR may be set to only call \fIcallback\fR with events that occurred on the CPUs specified, otherwise if \fIcpus\fR is NULL then the \fIcallback\fR function will be called for all events, and \fIcpu_size\fR is ignored\&. The \fIcallback\fR function will be called with the following parameters: A pointer to a struct tep_event that corresponds to the type of event the record is; The record representing the event; The CPU that the event occurred on; and a pointer to user specified \fIcallback_context\fR\&. If the \fIcallback\fR returns non\-zero, the iteration stops\&. .SH "RETURN VALUE" .sp The \fItracefs_event_systems()\fR and \fI_tracefs_system_events()\fR functions return an array of strings\&. The last element in that array is a NULL pointer\&. The array must be freed with \fItracefs_list_free()\fR API\&. In case of an error, NULL is returned\&. .sp The \fItracefs_iterate_raw_events()\fR function returns \-1 in case of an error or 0 otherwise\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include char **systems = tracefs_event_systems(NULL); if (systems) { int i = 0; /* Got registered trace systems from the top trace instance */ while (systems[i]) { char **events = tracefs_system_events(NULL, systems[i]); if (events) { /* Got registered events in system[i] from the top trace instance */ int j = 0; while (events[j]) { /* Got event[j] in system[i] from the top trace instance */ j++; } tracefs_list_free(events); } i++; } tracefs_list_free(systems); } \&.\&.\&.\&. static int records_walk(struct tep_event *tep, struct tep_record *record, int cpu, void *context) { /* Got recorded event on cpu */ return 0; } \&.\&.\&. struct tep_event *tep = tracefs_local_events(NULL); if (!tep) { /* Failed to initialise tep handler with local events */ \&.\&.\&. } if (tracefs_iterate_raw_events(tep, NULL, NULL, 0, records_walk, NULL) < 0) { /* Error walking through the recorded raw events */ } 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 \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