xref: /aosp_15_r20/external/libtracefs/Documentation/libtracefs-events-tep.txt (revision 287e80b3a36113050663245e7f2c00d274188f18)
1libtracefs(3)
2=============
3
4NAME
5----
6tracefs_local_events, tracefs_local_events_system, tracefs_fill_local_events,
7tracefs_load_cmdlines -
8Initialize a tep handler with trace events from the local system.
9
10SYNOPSIS
11--------
12[verse]
13--
14*#include <tracefs.h>*
15
16struct tep_handle pass:[*]*tracefs_local_events*(const char pass:[*]_tracing_dir_);
17struct tep_handle pass:[*]*tracefs_local_events_system*(const char pass:[*]_tracing_dir_, const char pass:[*] const pass:[*]_sys_names_);
18int *tracefs_fill_local_events*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_, int pass:[*]_parsing_failures_);
19int *tracefs_load_cmdlines*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_);
20--
21
22DESCRIPTION
23-----------
24Functions for initializing a tep handler with trace events from the local system.
25
26The *tracefs_local_events()* function allocates a new _tep_ handler and
27initializes it with events from all trace systems, located in the given
28_tracing_dir_ directory. This could be NULL or the location of the tracefs
29mount point for the trace systems of the local machine, or it may be a path
30to a copy of the tracefs directory from another machine.
31
32The *tracefs_local_events_system()* function allocates a new _tep_ handler
33and initializes it with events from specified trace systems _sys_names_,
34located in the given _tracing_dir_ directory. This could be NULL or the
35location of the tracefs mount point for the trace systems of the local
36machine, or it may be a path to a copy of the tracefs directory from another
37machine. The _sys_names_ argument is an array of trace system names, that
38will be used for _tep_ handler initialization. The last element in that
39array must be a NULL pointer.
40
41The *tracefs_fill_local_events()* function initializes already allocated _tep_
42handler with events from all trace systems, located in the given _tracing_dir_
43directory. This could be NULL or the location of the tracefs mount point
44for the trace systems of the local machine, or it may be a path to a copy
45of the tracefs directory from another machine. The _tep_ argument must be
46a pointer to already allocated tep handler, that is going to be initialized.
47The _parsing_failures_ argument could be NULL or a pointer to an integer,
48where the number of failures while parsing the event files are returned.
49
50The above functions will also load the mappings between pids and the process
51command line names. In some cases the _tep_ handle is created with one
52of the above before tracing begins. As the mappings get updated during the
53trace, there may be a need to read the mappings again after the trace.
54The *tracefs_load_cmdlines()* does just that. The _tracing_dir_ is
55the directory of the mount point to load from, or NULL to use the
56mount point of the tracefs file system.
57
58RETURN VALUE
59------------
60The *tracefs_local_events()* and *tracefs_local_events_system()* functions
61return pointer to allocated and initialized _tep_ handler, or NULL in
62case of an error. The returned _tep_ handler must be freed with *tep_free*(3).
63
64The *tracefs_fill_local_events()* function returns -1 in case of an error or
650 otherwise.
66
67The *tracefs_load_cmdlines()* function returns -1 in case of an error, or
680 otherwise.
69
70EXAMPLE
71-------
72[source,c]
73--
74#include <tracefs.h>
75
76struct tep_handle *tep;
77...
78	tep = tracefs_local_events(NULL);
79	if (!tep) {
80		/* Failed to initialise tep handler with local events from top instance */
81		...
82	}
83...
84	tep_free(tep);
85...
86	const char *systems[] = {"ftrace", "irq", NULL};
87	tep = tracefs_local_events_system(NULL, systems);
88	if (!tep) {
89		/* Failed to initialise tep handler with local events from
90		 * ftrace and irq systems in top instance.
91		 */
92		...
93	}
94...
95	tep_free(tep);
96...
97	int parsing_failures;
98	tep = tep_alloc();
99	if (!tep) {
100		/* Failed to allocate a tep handler */
101		...
102	}
103	if (tracefs_fill_local_events(NULL, tep, &parsing_failures) < 0) {
104		/* Failed to initialise tep handler with local events from top instance */
105	}
106	tracefs_load_cmdlines(NULL, tep);
107...
108	tep_free(tep);
109--
110FILES
111-----
112[verse]
113--
114*tracefs.h*
115	Header file to include in order to have access to the library APIs.
116*-ltracefs*
117	Linker switch to add when building a program that uses the library.
118--
119
120SEE ALSO
121--------
122*libtracefs*(3),
123*libtraceevent*(3),
124*trace-cmd*(1)
125
126AUTHOR
127------
128[verse]
129--
130*Steven Rostedt* <[email protected]>
131*Tzvetomir Stoyanov* <[email protected]>
132--
133REPORTING BUGS
134--------------
135Report bugs to  <[email protected]>
136
137LICENSE
138-------
139libtracefs is Free Software licensed under the GNU LGPL 2.1
140
141RESOURCES
142---------
143https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
144
145COPYING
146-------
147Copyright \(C) 2020 VMware, Inc. Free use of this software is granted under
148the terms of the GNU Public License (GPL).
149