summaryrefslogtreecommitdiffstats
path: root/tools/lib/traceevent/Documentation/libtraceevent-plugins.txt
blob: 4d6394397d92e490ee7504bbd340bdd905db5ee3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
libtraceevent(3)
================

NAME
----
tep_load_plugins, tep_unload_plugins, tep_load_plugins_hook - Load / unload traceevent plugins.

SYNOPSIS
--------
[verse]
--
*#include <event-parse.h>*

struct tep_plugin_list pass:[*]*tep_load_plugins*(struct tep_handle pass:[*]_tep_);
void *tep_unload_plugins*(struct tep_plugin_list pass:[*]_plugin_list_, struct tep_handle pass:[*]_tep_);
void *tep_load_plugins_hook*(struct tep_handle pass:[*]_tep_, const char pass:[*]_suffix_,
			   void (pass:[*]_load_plugin_)(struct tep_handle pass:[*]tep,
					       const char pass:[*]path,
					       const char pass:[*]name,
					       void pass:[*]data),
			   void pass:[*]_data_);
--

DESCRIPTION
-----------
The _tep_load_plugins()_ function loads all plugins, located in the plugin
directories. The _tep_ argument is trace event parser context.
The plugin directories are :
[verse]
--
	- Directories, specified in _tep_->plugins_dir with priority TEP_PLUGIN_FIRST
	- System's plugin directory, defined at the library compile time. It
	  depends on the library installation prefix and usually is
	  _(install_preffix)/lib/traceevent/plugins_
	- Directory, defined by the environment variable _TRACEEVENT_PLUGIN_DIR_
	- User's plugin directory, located at _~/.local/lib/traceevent/plugins_
	- Directories, specified in _tep_->plugins_dir with priority TEP_PLUGIN_LAST
--
Loading of plugins can be controlled by the _tep_flags_, using the
_tep_set_flag()_ API:
[verse]
--
	_TEP_DISABLE_SYS_PLUGINS_	- do not load plugins, located in
					the system's plugin directory.
	_TEP_DISABLE_PLUGINS_		- do not load any plugins.
--
The _tep_set_flag()_ API needs to be called before _tep_load_plugins()_, if
loading of all plugins is not the desired case.

The _tep_unload_plugins()_ function unloads the plugins, previously loaded by
_tep_load_plugins()_. The _tep_ argument is trace event parser context. The
_plugin_list_ is the list of loaded plugins, returned by
the _tep_load_plugins()_ function.

The _tep_load_plugins_hook_ function walks through all directories with plugins
and calls user specified _load_plugin()_ hook for each plugin file. Only files
with given _suffix_ are considered to be plugins. The _data_ is a user specified
context, passed to _load_plugin()_. Directories and the walk order are the same
as in _tep_load_plugins()_ API.

RETURN VALUE
------------
The _tep_load_plugins()_ function returns a list of successfully loaded plugins,
or NULL in case no plugins are loaded.

EXAMPLE
-------
[source,c]
--
#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
struct tep_plugin_list *plugins = tep_load_plugins(tep);
if (plugins == NULL) {
	/* no plugins are loaded */
}
...
tep_unload_plugins(plugins, tep);
...
void print_plugin(struct tep_handle *tep, const char *path,
		  const char *name, void *data)
{
	pritnf("Found libtraceevent plugin %s/%s\n", path, name);
}
...
tep_load_plugins_hook(tep, ".so", print_plugin, NULL);
...
--

FILES
-----
[verse]
--
*event-parse.h*
	Header file to include in order to have access to the library APIs.
*-ltraceevent*
	Linker switch to add when building a program that uses the library.
--

SEE ALSO
--------
_libtraceevent(3)_, _trace-cmd(1)_, _tep_set_flag(3)_

AUTHOR
------
[verse]
--
*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
--
REPORTING BUGS
--------------
Report bugs to  <linux-trace-devel@vger.kernel.org>

LICENSE
-------
libtraceevent is Free Software licensed under the GNU LGPL 2.1

RESOURCES
---------
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git