xref: /aosp_15_r20/external/libtraceevent/Documentation/libtraceevent-plugins.txt (revision 436bf2bcd5202612ffffe471bbcc1f277cc8d28e)
1*436bf2bcSAndroid Build Coastguard Workerlibtraceevent(3)
2*436bf2bcSAndroid Build Coastguard Worker================
3*436bf2bcSAndroid Build Coastguard Worker
4*436bf2bcSAndroid Build Coastguard WorkerNAME
5*436bf2bcSAndroid Build Coastguard Worker----
6*436bf2bcSAndroid Build Coastguard Workertep_load_plugins, tep_unload_plugins, tep_load_plugins_hook, tep_add_plugin_path,
7*436bf2bcSAndroid Build Coastguard Workertep_plugin_add_option - Load / unload traceevent plugins.
8*436bf2bcSAndroid Build Coastguard Worker
9*436bf2bcSAndroid Build Coastguard WorkerSYNOPSIS
10*436bf2bcSAndroid Build Coastguard Worker--------
11*436bf2bcSAndroid Build Coastguard Worker[verse]
12*436bf2bcSAndroid Build Coastguard Worker--
13*436bf2bcSAndroid Build Coastguard Worker*#include <event-parse.h>*
14*436bf2bcSAndroid Build Coastguard Worker
15*436bf2bcSAndroid Build Coastguard Workerstruct tep_plugin_list pass:[*]*tep_load_plugins*(struct tep_handle pass:[*]_tep_);
16*436bf2bcSAndroid Build Coastguard Workervoid *tep_unload_plugins*(struct tep_plugin_list pass:[*]_plugin_list_, struct tep_handle pass:[*]_tep_);
17*436bf2bcSAndroid Build Coastguard Workervoid *tep_load_plugins_hook*(struct tep_handle pass:[*]_tep_, const char pass:[*]_suffix_,
18*436bf2bcSAndroid Build Coastguard Worker			   void (pass:[*]_load_plugin_)(struct tep_handle pass:[*]tep,
19*436bf2bcSAndroid Build Coastguard Worker					       const char pass:[*]path,
20*436bf2bcSAndroid Build Coastguard Worker					       const char pass:[*]name,
21*436bf2bcSAndroid Build Coastguard Worker					       void pass:[*]data),
22*436bf2bcSAndroid Build Coastguard Worker			   void pass:[*]_data_);
23*436bf2bcSAndroid Build Coastguard Workerint *tep_add_plugin_path*(struct tep_handle pass:[*]tep, char pass:[*]path,
24*436bf2bcSAndroid Build Coastguard Worker			  enum tep_plugin_load_priority prio);
25*436bf2bcSAndroid Build Coastguard Workerint *tep_plugin_add_option*(const char pass:[*]_name_, const char pass:[*]_val_);
26*436bf2bcSAndroid Build Coastguard Worker--
27*436bf2bcSAndroid Build Coastguard Worker
28*436bf2bcSAndroid Build Coastguard WorkerDESCRIPTION
29*436bf2bcSAndroid Build Coastguard Worker-----------
30*436bf2bcSAndroid Build Coastguard WorkerThe *tep_load_plugins()* function loads all plugins, located in the plugin
31*436bf2bcSAndroid Build Coastguard Workerdirectories. The _tep_ argument is trace event parser context.
32*436bf2bcSAndroid Build Coastguard WorkerThe plugin directories are :
33*436bf2bcSAndroid Build Coastguard Worker[verse]
34*436bf2bcSAndroid Build Coastguard Worker--
35*436bf2bcSAndroid Build Coastguard Worker	- Directories, specified in _tep_->plugins_dir with priority TEP_PLUGIN_FIRST
36*436bf2bcSAndroid Build Coastguard Worker	- System's plugin directory, defined at the library compile time. It
37*436bf2bcSAndroid Build Coastguard Worker	  depends on the library installation prefix and usually is
38*436bf2bcSAndroid Build Coastguard Worker	  _(install_preffix)/lib/traceevent/plugins_
39*436bf2bcSAndroid Build Coastguard Worker	- Directory, defined by the environment variable _TRACEEVENT_PLUGIN_DIR_
40*436bf2bcSAndroid Build Coastguard Worker	- User's plugin directory, located at _~/.local/lib/traceevent/plugins_
41*436bf2bcSAndroid Build Coastguard Worker	- Directories, specified in _tep_->plugins_dir with priority TEP_PLUGIN_LAST
42*436bf2bcSAndroid Build Coastguard Worker--
43*436bf2bcSAndroid Build Coastguard WorkerLoading of plugins can be controlled by the _tep_flags_, using the
44*436bf2bcSAndroid Build Coastguard Worker*tep_set_flag()* API:
45*436bf2bcSAndroid Build Coastguard Worker[verse]
46*436bf2bcSAndroid Build Coastguard Worker--
47*436bf2bcSAndroid Build Coastguard Worker	_TEP_DISABLE_SYS_PLUGINS_	- do not load plugins, located in
48*436bf2bcSAndroid Build Coastguard Worker					the system's plugin directory.
49*436bf2bcSAndroid Build Coastguard Worker	_TEP_DISABLE_PLUGINS_		- do not load any plugins.
50*436bf2bcSAndroid Build Coastguard Worker--
51*436bf2bcSAndroid Build Coastguard WorkerThe *tep_set_flag()* API needs to be called before *tep_load_plugins()*, if
52*436bf2bcSAndroid Build Coastguard Workerloading of all plugins is not the desired case.
53*436bf2bcSAndroid Build Coastguard Worker
54*436bf2bcSAndroid Build Coastguard WorkerThe *tep_unload_plugins()* function unloads the plugins, previously loaded by
55*436bf2bcSAndroid Build Coastguard Worker*tep_load_plugins()*. The _tep_ argument is trace event parser context. The
56*436bf2bcSAndroid Build Coastguard Worker_plugin_list_ is the list of loaded plugins, returned by
57*436bf2bcSAndroid Build Coastguard Workerthe *tep_load_plugins()* function.
58*436bf2bcSAndroid Build Coastguard Worker
59*436bf2bcSAndroid Build Coastguard WorkerThe *tep_load_plugins_hook()* function walks through all directories with plugins
60*436bf2bcSAndroid Build Coastguard Workerand calls user specified *load_plugin()* hook for each plugin file. Only files
61*436bf2bcSAndroid Build Coastguard Workerwith given _suffix_ are considered to be plugins. The _data_ is a user specified
62*436bf2bcSAndroid Build Coastguard Workercontext, passed to *load_plugin()*. Directories and the walk order are the same
63*436bf2bcSAndroid Build Coastguard Workeras in *tep_load_plugins()* API.
64*436bf2bcSAndroid Build Coastguard Worker
65*436bf2bcSAndroid Build Coastguard WorkerThe *tep_add_plugin_path()* functions adds additional directories with plugins in
66*436bf2bcSAndroid Build Coastguard Workerthe _tep_->plugins_dir list. It must be called before *tep_load_plugins()* in order
67*436bf2bcSAndroid Build Coastguard Workerfor the plugins from the new directories to be loaded. The _tep_ argument is
68*436bf2bcSAndroid Build Coastguard Workerthe trace event parser context. The _path_ is the full path to the new plugin
69*436bf2bcSAndroid Build Coastguard Workerdirectory. The _prio_ argument specifies the loading priority order for the
70*436bf2bcSAndroid Build Coastguard Workernew directory of plugins. The loading priority is important in case of different
71*436bf2bcSAndroid Build Coastguard Workerversions of the same plugin located in multiple plugin directories.The last loaded
72*436bf2bcSAndroid Build Coastguard Workerplugin wins. The priority can be:
73*436bf2bcSAndroid Build Coastguard Worker[verse]
74*436bf2bcSAndroid Build Coastguard Worker--
75*436bf2bcSAndroid Build Coastguard Worker	_TEP_PLUGIN_FIRST_	- Load plugins from this directory first
76*436bf2bcSAndroid Build Coastguard Worker	_TEP_PLUGIN_LAST_	- Load plugins from this directory last
77*436bf2bcSAndroid Build Coastguard Worker--
78*436bf2bcSAndroid Build Coastguard WorkerWhere the plugins in TEP_PLUGIN_LAST" will take precedence over the
79*436bf2bcSAndroid Build Coastguard Workerplugins in the other directories.
80*436bf2bcSAndroid Build Coastguard Worker
81*436bf2bcSAndroid Build Coastguard WorkerThe *tep_plugin_add_option()* sets options defined by a plugin. The _name_ is the
82*436bf2bcSAndroid Build Coastguard Workername of the option to set to _val_. Plugins can add options to change its behavior
83*436bf2bcSAndroid Build Coastguard Workerand *tep_plugin_add_option()* is used by the application to make those modifications.
84*436bf2bcSAndroid Build Coastguard Worker
85*436bf2bcSAndroid Build Coastguard Worker
86*436bf2bcSAndroid Build Coastguard WorkerRETURN VALUE
87*436bf2bcSAndroid Build Coastguard Worker------------
88*436bf2bcSAndroid Build Coastguard WorkerThe *tep_load_plugins()* function returns a list of successfully loaded plugins,
89*436bf2bcSAndroid Build Coastguard Workeror NULL in case no plugins are loaded.
90*436bf2bcSAndroid Build Coastguard WorkerThe *tep_add_plugin_path()* function returns -1 in case of an error, 0 otherwise.
91*436bf2bcSAndroid Build Coastguard Worker
92*436bf2bcSAndroid Build Coastguard WorkerEXAMPLE
93*436bf2bcSAndroid Build Coastguard Worker-------
94*436bf2bcSAndroid Build Coastguard Worker[source,c]
95*436bf2bcSAndroid Build Coastguard Worker--
96*436bf2bcSAndroid Build Coastguard Worker#include <event-parse.h>
97*436bf2bcSAndroid Build Coastguard Worker...
98*436bf2bcSAndroid Build Coastguard Workerstruct tep_handle *tep = tep_alloc();
99*436bf2bcSAndroid Build Coastguard Worker...
100*436bf2bcSAndroid Build Coastguard Workertep_add_plugin_path(tep, "~/dev_plugins", TEP_PLUGIN_LAST);
101*436bf2bcSAndroid Build Coastguard Worker...
102*436bf2bcSAndroid Build Coastguard Workerstruct tep_plugin_list *plugins = tep_load_plugins(tep);
103*436bf2bcSAndroid Build Coastguard Workerif (plugins == NULL) {
104*436bf2bcSAndroid Build Coastguard Worker	/* no plugins are loaded */
105*436bf2bcSAndroid Build Coastguard Worker}
106*436bf2bcSAndroid Build Coastguard Worker...
107*436bf2bcSAndroid Build Coastguard Workertep_unload_plugins(plugins, tep);
108*436bf2bcSAndroid Build Coastguard Worker...
109*436bf2bcSAndroid Build Coastguard Workervoid print_plugin(struct tep_handle *tep, const char *path,
110*436bf2bcSAndroid Build Coastguard Worker		  const char *name, void *data)
111*436bf2bcSAndroid Build Coastguard Worker{
112*436bf2bcSAndroid Build Coastguard Worker	pritnf("Found libtraceevent plugin %s/%s\n", path, name);
113*436bf2bcSAndroid Build Coastguard Worker}
114*436bf2bcSAndroid Build Coastguard Worker...
115*436bf2bcSAndroid Build Coastguard Workertep_load_plugins_hook(tep, ".so", print_plugin, NULL);
116*436bf2bcSAndroid Build Coastguard Worker...
117*436bf2bcSAndroid Build Coastguard Worker--
118*436bf2bcSAndroid Build Coastguard Worker
119*436bf2bcSAndroid Build Coastguard WorkerFILES
120*436bf2bcSAndroid Build Coastguard Worker-----
121*436bf2bcSAndroid Build Coastguard Worker[verse]
122*436bf2bcSAndroid Build Coastguard Worker--
123*436bf2bcSAndroid Build Coastguard Worker*event-parse.h*
124*436bf2bcSAndroid Build Coastguard Worker	Header file to include in order to have access to the library APIs.
125*436bf2bcSAndroid Build Coastguard Worker*-ltraceevent*
126*436bf2bcSAndroid Build Coastguard Worker	Linker switch to add when building a program that uses the library.
127*436bf2bcSAndroid Build Coastguard Worker--
128*436bf2bcSAndroid Build Coastguard Worker
129*436bf2bcSAndroid Build Coastguard WorkerSEE ALSO
130*436bf2bcSAndroid Build Coastguard Worker--------
131*436bf2bcSAndroid Build Coastguard Worker*libtraceevent*(3), *trace-cmd*(1), *tep_set_flag*(3)
132*436bf2bcSAndroid Build Coastguard Worker
133*436bf2bcSAndroid Build Coastguard WorkerAUTHOR
134*436bf2bcSAndroid Build Coastguard Worker------
135*436bf2bcSAndroid Build Coastguard Worker[verse]
136*436bf2bcSAndroid Build Coastguard Worker--
137*436bf2bcSAndroid Build Coastguard Worker*Steven Rostedt* <[email protected]>, author of *libtraceevent*.
138*436bf2bcSAndroid Build Coastguard Worker*Tzvetomir Stoyanov* <[email protected]>, author of this man page.
139*436bf2bcSAndroid Build Coastguard Worker--
140*436bf2bcSAndroid Build Coastguard WorkerREPORTING BUGS
141*436bf2bcSAndroid Build Coastguard Worker--------------
142*436bf2bcSAndroid Build Coastguard WorkerReport bugs to  <[email protected]>
143*436bf2bcSAndroid Build Coastguard Worker
144*436bf2bcSAndroid Build Coastguard WorkerLICENSE
145*436bf2bcSAndroid Build Coastguard Worker-------
146*436bf2bcSAndroid Build Coastguard Workerlibtraceevent is Free Software licensed under the GNU LGPL 2.1
147*436bf2bcSAndroid Build Coastguard Worker
148*436bf2bcSAndroid Build Coastguard WorkerRESOURCES
149*436bf2bcSAndroid Build Coastguard Worker---------
150*436bf2bcSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
151