xref: /OK3568_Linux_fs/kernel/tools/lib/traceevent/Documentation/libtraceevent-plugins.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyunlibtraceevent(3)
2*4882a593Smuzhiyun================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunNAME
5*4882a593Smuzhiyun----
6*4882a593Smuzhiyuntep_load_plugins, tep_unload_plugins, tep_load_plugins_hook - Load / unload traceevent plugins.
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunSYNOPSIS
9*4882a593Smuzhiyun--------
10*4882a593Smuzhiyun[verse]
11*4882a593Smuzhiyun--
12*4882a593Smuzhiyun*#include <event-parse.h>*
13*4882a593Smuzhiyun
14*4882a593Smuzhiyunstruct tep_plugin_list pass:[*]*tep_load_plugins*(struct tep_handle pass:[*]_tep_);
15*4882a593Smuzhiyunvoid *tep_unload_plugins*(struct tep_plugin_list pass:[*]_plugin_list_, struct tep_handle pass:[*]_tep_);
16*4882a593Smuzhiyunvoid *tep_load_plugins_hook*(struct tep_handle pass:[*]_tep_, const char pass:[*]_suffix_,
17*4882a593Smuzhiyun			   void (pass:[*]_load_plugin_)(struct tep_handle pass:[*]tep,
18*4882a593Smuzhiyun					       const char pass:[*]path,
19*4882a593Smuzhiyun					       const char pass:[*]name,
20*4882a593Smuzhiyun					       void pass:[*]data),
21*4882a593Smuzhiyun			   void pass:[*]_data_);
22*4882a593Smuzhiyun--
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunDESCRIPTION
25*4882a593Smuzhiyun-----------
26*4882a593SmuzhiyunThe _tep_load_plugins()_ function loads all plugins, located in the plugin
27*4882a593Smuzhiyundirectories. The _tep_ argument is trace event parser context.
28*4882a593SmuzhiyunThe plugin directories are :
29*4882a593Smuzhiyun[verse]
30*4882a593Smuzhiyun--
31*4882a593Smuzhiyun	- Directories, specified in _tep_->plugins_dir with priority TEP_PLUGIN_FIRST
32*4882a593Smuzhiyun	- System's plugin directory, defined at the library compile time. It
33*4882a593Smuzhiyun	  depends on the library installation prefix and usually is
34*4882a593Smuzhiyun	  _(install_preffix)/lib/traceevent/plugins_
35*4882a593Smuzhiyun	- Directory, defined by the environment variable _TRACEEVENT_PLUGIN_DIR_
36*4882a593Smuzhiyun	- User's plugin directory, located at _~/.local/lib/traceevent/plugins_
37*4882a593Smuzhiyun	- Directories, specified in _tep_->plugins_dir with priority TEP_PLUGIN_LAST
38*4882a593Smuzhiyun--
39*4882a593SmuzhiyunLoading of plugins can be controlled by the _tep_flags_, using the
40*4882a593Smuzhiyun_tep_set_flag()_ API:
41*4882a593Smuzhiyun[verse]
42*4882a593Smuzhiyun--
43*4882a593Smuzhiyun	_TEP_DISABLE_SYS_PLUGINS_	- do not load plugins, located in
44*4882a593Smuzhiyun					the system's plugin directory.
45*4882a593Smuzhiyun	_TEP_DISABLE_PLUGINS_		- do not load any plugins.
46*4882a593Smuzhiyun--
47*4882a593SmuzhiyunThe _tep_set_flag()_ API needs to be called before _tep_load_plugins()_, if
48*4882a593Smuzhiyunloading of all plugins is not the desired case.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunThe _tep_unload_plugins()_ function unloads the plugins, previously loaded by
51*4882a593Smuzhiyun_tep_load_plugins()_. The _tep_ argument is trace event parser context. The
52*4882a593Smuzhiyun_plugin_list_ is the list of loaded plugins, returned by
53*4882a593Smuzhiyunthe _tep_load_plugins()_ function.
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunThe _tep_load_plugins_hook_ function walks through all directories with plugins
56*4882a593Smuzhiyunand calls user specified _load_plugin()_ hook for each plugin file. Only files
57*4882a593Smuzhiyunwith given _suffix_ are considered to be plugins. The _data_ is a user specified
58*4882a593Smuzhiyuncontext, passed to _load_plugin()_. Directories and the walk order are the same
59*4882a593Smuzhiyunas in _tep_load_plugins()_ API.
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunRETURN VALUE
62*4882a593Smuzhiyun------------
63*4882a593SmuzhiyunThe _tep_load_plugins()_ function returns a list of successfully loaded plugins,
64*4882a593Smuzhiyunor NULL in case no plugins are loaded.
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunEXAMPLE
67*4882a593Smuzhiyun-------
68*4882a593Smuzhiyun[source,c]
69*4882a593Smuzhiyun--
70*4882a593Smuzhiyun#include <event-parse.h>
71*4882a593Smuzhiyun...
72*4882a593Smuzhiyunstruct tep_handle *tep = tep_alloc();
73*4882a593Smuzhiyun...
74*4882a593Smuzhiyunstruct tep_plugin_list *plugins = tep_load_plugins(tep);
75*4882a593Smuzhiyunif (plugins == NULL) {
76*4882a593Smuzhiyun	/* no plugins are loaded */
77*4882a593Smuzhiyun}
78*4882a593Smuzhiyun...
79*4882a593Smuzhiyuntep_unload_plugins(plugins, tep);
80*4882a593Smuzhiyun...
81*4882a593Smuzhiyunvoid print_plugin(struct tep_handle *tep, const char *path,
82*4882a593Smuzhiyun		  const char *name, void *data)
83*4882a593Smuzhiyun{
84*4882a593Smuzhiyun	pritnf("Found libtraceevent plugin %s/%s\n", path, name);
85*4882a593Smuzhiyun}
86*4882a593Smuzhiyun...
87*4882a593Smuzhiyuntep_load_plugins_hook(tep, ".so", print_plugin, NULL);
88*4882a593Smuzhiyun...
89*4882a593Smuzhiyun--
90*4882a593Smuzhiyun
91*4882a593SmuzhiyunFILES
92*4882a593Smuzhiyun-----
93*4882a593Smuzhiyun[verse]
94*4882a593Smuzhiyun--
95*4882a593Smuzhiyun*event-parse.h*
96*4882a593Smuzhiyun	Header file to include in order to have access to the library APIs.
97*4882a593Smuzhiyun*-ltraceevent*
98*4882a593Smuzhiyun	Linker switch to add when building a program that uses the library.
99*4882a593Smuzhiyun--
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunSEE ALSO
102*4882a593Smuzhiyun--------
103*4882a593Smuzhiyun_libtraceevent(3)_, _trace-cmd(1)_, _tep_set_flag(3)_
104*4882a593Smuzhiyun
105*4882a593SmuzhiyunAUTHOR
106*4882a593Smuzhiyun------
107*4882a593Smuzhiyun[verse]
108*4882a593Smuzhiyun--
109*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
110*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
111*4882a593Smuzhiyun--
112*4882a593SmuzhiyunREPORTING BUGS
113*4882a593Smuzhiyun--------------
114*4882a593SmuzhiyunReport bugs to  <linux-trace-devel@vger.kernel.org>
115*4882a593Smuzhiyun
116*4882a593SmuzhiyunLICENSE
117*4882a593Smuzhiyun-------
118*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1
119*4882a593Smuzhiyun
120*4882a593SmuzhiyunRESOURCES
121*4882a593Smuzhiyun---------
122*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
123